From 92e9e60cd027e8b1f79bc04a79005129c8149293 Mon Sep 17 00:00:00 2001 From: jean Date: Sat, 2 May 2020 21:10:38 -0700 Subject: [PATCH] Fix the crash that occurs when opening a new book when the transaction-matching dialog has been opened then closed. --- gnucash/import-export/import-main-matcher.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.c index 8851da8b21..b9889ee760 100644 --- a/gnucash/import-export/import-main-matcher.c +++ b/gnucash/import-export/import-main-matcher.c @@ -68,6 +68,7 @@ struct _main_matcher_info GNCImportPendingMatches *pending_matches; GtkTreeViewColumn *account_column; gboolean add_toggled; // flag to indicate that add has been toggled to stop selection + gint id; }; enum downloaded_cols @@ -171,6 +172,7 @@ void gnc_gen_trans_list_delete (GNCImportMainMatcher *info) { gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->main_widget)); gnc_import_Settings_delete (info->user_settings); + gnc_unregister_gui_component (info->id); gtk_widget_destroy (GTK_WIDGET (info->main_widget)); } else @@ -924,7 +926,6 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, GtkStyleContext *stylectxt; GdkRGBA color; GtkWidget *button; - gint id; info = g_new0 (GNCImportMainMatcher, 1); info->pending_matches = gnc_import_PendingMatches_new(); @@ -981,12 +982,12 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, g_object_unref (G_OBJECT(builder)); // Register this UI, it needs to be closed when the session is closed. - id = gnc_register_gui_component (IMPORT_MAIN_MATCHER_CM_CLASS, - NULL, /* no refresh handler */ - (GNCComponentCloseHandler)gnc_gen_trans_list_delete, - info); + info->id = gnc_register_gui_component (IMPORT_MAIN_MATCHER_CM_CLASS, + NULL, /* no refresh handler */ + (GNCComponentCloseHandler)gnc_gen_trans_list_delete, + info); // This ensure this dialog is closed when the session is closed. - gnc_gui_component_set_session (id, gnc_get_current_session()); + gnc_gui_component_set_session (info->id, gnc_get_current_session()); return info; }