[gnumeric] GUI: Fix reference to deleted WBCGtk on exit



commit b7fa80bff77f59de0af64e5ed914f78e17f96199
Author: Morten Welinder <terra gnome org>
Date:   Sun Nov 26 19:42:49 2017 -0500

    GUI: Fix reference to deleted WBCGtk on exit
    
    This happened, for example, when hitting Ctrl-Q while the function selector
    was open.

 NEWS           |    1 +
 src/workbook.c |    9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 1c50d82..3f09403 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Morten:
        * Extend range of NT_PI.
        * Improve xlsx export of cell comments.  [#790756]
        * Plug leaks.
+       * Fix potential crash on exit.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.36
diff --git a/src/workbook.c b/src/workbook.c
index f2b1385..75fc6d0 100644
--- a/src/workbook.c
+++ b/src/workbook.c
@@ -130,6 +130,7 @@ workbook_dispose (GObject *wb_object)
 {
        Workbook *wb = WORKBOOK (wb_object);
        GSList *sheets, *ptr;
+       GSList *controls = NULL;
 
        wb->during_destruction = TRUE;
 
@@ -139,8 +140,11 @@ workbook_dispose (GObject *wb_object)
                workbook_set_saveinfo (wb, GO_FILE_FL_WRITE_ONLY, NULL);
        workbook_set_last_export_uri (wb, NULL);
 
-       /* Remove all the sheet controls to avoid displaying while we exit */
+       // Remove all the sheet controls to avoid displaying while we exit
+       // However, hold on to a ref for each -- dialogs like to refer
+       // to ->wbcg during destruction
        WORKBOOK_FOREACH_CONTROL (wb, view, control,
+               controls = g_slist_prepend (controls, g_object_ref (control));
                wb_control_sheet_remove_all (control););
 
        /* Get rid of all the views */
@@ -178,6 +182,9 @@ workbook_dispose (GObject *wb_object)
        }
        g_slist_free (sheets);
 
+       // Now get rid of the control refs
+       g_slist_free_full (controls, g_object_unref);
+
        workbook_parent_class->dispose (wb_object);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]