Skip to content

Commit 9b7b69a

Browse files
agwekixjjralls
authored andcommitted
Reset gui component session
When saving a new file, including Save As of an existing book, reset the managed gui components to the new session prior to clearing the old session.
1 parent 1e3027e commit 9b7b69a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

gnucash/gnome-utils/gnc-component-manager.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,20 @@ gnc_gui_component_set_session (gint component_id, gpointer session)
819819
ci->session = session;
820820
}
821821

822+
void
823+
gnc_gui_component_reset_session (gpointer old_session, gpointer new_session)
824+
{
825+
GList *node;
826+
827+
for (node = components; node; node = node->next)
828+
{
829+
ComponentInfo *ci = node->data;
830+
831+
if (ci->session == old_session)
832+
ci->session = new_session;
833+
}
834+
}
835+
822836
void
823837
gnc_close_gui_component_by_session (gpointer session)
824838
{

gnucash/gnome-utils/gnc-component-manager.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ gint gnc_register_gui_component (const char *component_class,
163163
*/
164164
void gnc_gui_component_set_session (gint component_id, gpointer session);
165165

166+
/* gnc_gui_component_reset_session
167+
* Reset the associated session of all components with the original session
168+
*
169+
* old_session: the original session
170+
* new_session: the new session
171+
*/
172+
void gnc_gui_component_reset_session (gpointer old_session, gpointer new_session);
173+
166174
/* gnc_gui_component_watch_entity
167175
* Add an entity to the list of those being watched by the component.
168176
* Only entities with refresh handlers should add watches.

gnucash/gnome-utils/gnc-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,7 @@ gnc_file_do_save_as (GtkWindow *parent, const char* filename)
17141714
{
17151715
/* Yay! Save was successful, we can dump the old session */
17161716
qof_event_suspend();
1717+
gnc_gui_component_reset_session (session, new_session);
17171718
gnc_clear_current_session();
17181719
gnc_set_current_session( new_session );
17191720
qof_event_resume();

0 commit comments

Comments
 (0)