From e8fb3677342a64a1d93825e5f158d1612561a033 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 7 Jul 2012 23:44:37 -0700 Subject: [PATCH] psppire-data-window: Delete dataset when closing window. When the user closes the window it means that he wants to close the underlying dataset also. Otherwise the dataset essentially leaks (in theory it's still there in the list of datasets but in practice that takes a DATASET ACTIVATE WINDOW=FRONT command to show it). This also fixes a Gtk-CRITICAL and following crash in the following scenario brought up by John Darrington: 1. Start psppire 2. File | Open and load x.sav (dataset1) 3. File | New | Data (a new data window will appear: dataset2) 4. Using the window manager close the window for dataset1 5. In dataset2: File | Open and load x.sav I'm not 100% certain of the reason that this fixes it but I think that there's some lingering association between the dataset and the window that this change eliminates, by eliminating the dataset along with the window. The code added to psppire_data_window_dispose() in this commit should probably go in a "finalize" function instead but there seems to be a separate problem with references to PsppireVarSheet such that if this new code is in "finalize" then dataset_destroy() will call dict_clear() which will invoke the callbacks for PsppireDict which will try to access the destroyed window. On the other hand, with this code in "dispose" the window isn't fully destroyed yet so while the same code path gets followed it isn't fatal. --- src/ui/gui/psppire-data-window.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index c22f7bb293..2149a89dbd 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -1212,6 +1212,18 @@ psppire_data_window_dispose (GObject *object) { PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (object); + if (dw->dataset) + { + struct dataset *dataset = dw->dataset; + struct session *session = dataset_session (dataset); + + dw->dataset = NULL; + + dataset_set_callbacks (dataset, NULL, NULL); + session_set_active_dataset (session, NULL); + dataset_destroy (dataset); + } + if (dw->builder != NULL) { g_object_unref (dw->builder); -- 2.30.2