Correct erroneous g_object_unref calls
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 28 Apr 2012 10:41:05 +0000 (12:41 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 28 Apr 2012 10:41:05 +0000 (12:41 +0200)
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
src/ui/gui/regression-dialog.c

index dc67b7c070fdb66811ffda29f9c7f40b6d0dc59b..023be7d0cc7311e9ce1643512a5ec04431d5d92c 100644 (file)
@@ -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);
index 7c0608fd5b2032e4bc6817060367ecd1f53f68cb..a4a4501c3c5a11c760cf9e5727ff49f4fa222d37 100644 (file)
@@ -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);
 }