From 3391f492daa7069de23f93a513ba361c59dedf72 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 28 Apr 2012 12:41:05 +0200 Subject: [PATCH] Correct erroneous g_object_unref calls commit e89158e8abd2dae27d985e3574eb5aa1d265fc66 placed g_object_unref calls after every instance of *_set_model - In most instances this was correct, but not all. When (for example) gtk_tree_view_set_model (view, model) is called, it takes a ref to model, but it will then unref it upon the next call to _set_model and/or when view is destroyed. Unreffing the model ourself, is therefore appropriate only when we have created it ourselves. This change fixes the few instances where this was not the case. --- src/ui/gui/psppire-dictview.c | 1 + src/ui/gui/regression-dialog.c | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ui/gui/psppire-dictview.c b/src/ui/gui/psppire-dictview.c index dc67b7c070..023be7d0cc 100644 --- a/src/ui/gui/psppire-dictview.c +++ b/src/ui/gui/psppire-dictview.c @@ -121,6 +121,7 @@ set_model (PsppireDictView *dict_view) else { model = GTK_TREE_MODEL (dict_view->dict); + g_object_ref (model); } gtk_tree_view_set_model (GTK_TREE_VIEW (dict_view), model); diff --git a/src/ui/gui/regression-dialog.c b/src/ui/gui/regression-dialog.c index 7c0608fd5b..a4a4501c3c 100644 --- a/src/ui/gui/regression-dialog.c +++ b/src/ui/gui/regression-dialog.c @@ -109,16 +109,12 @@ on_statistics_clicked (struct regression_dialog *rd) ret = psppire_dialog_run (PSPPIRE_DIALOG (rd->stat_dialog)); - if ( ret == PSPPIRE_RESPONSE_CONTINUE ) - { - g_object_unref (liststore); - } - else + if ( ret != PSPPIRE_RESPONSE_CONTINUE ) { - g_object_unref (rd->stat); gtk_tree_view_set_model (GTK_TREE_VIEW (rd->stat_view) , GTK_TREE_MODEL (liststore)); rd->stat = GTK_TREE_MODEL (liststore); } + g_object_unref (liststore); } static void @@ -298,5 +294,4 @@ regression_dialog (PsppireDataWindow *de) } g_object_unref (xml); - g_object_unref (rd.stat); } -- 2.30.2