[nautilus-actions] NactTreeView: exhibits a ref_count error



commit 493594dc801b90f4891c31399a81f648f199652a
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Jan 29 18:30:24 2012 +0100

    NactTreeView: exhibits a ref_count error

 ChangeLog                  |    4 ++++
 src/nact/nact-tree-model.c |   27 ++++++++++++++++++---------
 src/nact/nact-tree-view.c  |   19 +++++++++++--------
 3 files changed, 33 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ac5ce0c..0b24882 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2012-01-29 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-tree-model.c (nact_tree_model_new): Unref filter model.
+
+	* src/nact/nact-tree-view.c (instance_dispose): Debug NactTreeModel ref count.
+
 	* src/nact/nact-preferences-editor.c (instance_init):
 	Remove signal connections already done in instance_contructed().
 
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 8184156..2749fc1 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -320,6 +320,7 @@ nact_tree_model_new( BaseWindow *window, GtkTreeView *treeview, NactTreeMode mod
 	/* create the filter model
 	 */
 	model = g_object_new( NACT_TYPE_TREE_MODEL, "child-model", ts_model, NULL );
+	g_object_unref( ts_model );
 
 	gtk_tree_model_filter_set_visible_func(
 			GTK_TREE_MODEL_FILTER( model ), ( GtkTreeModelFilterVisibleFunc ) filter_visible, model, NULL );
@@ -400,13 +401,22 @@ on_initialize_model( BaseWindow *window, gpointer user_data )
 			/*base_window_signal_connect( window,
 					G_OBJECT( model->private->treeview ), "drag-drop", G_CALLBACK( on_drag_drop ));*/
 
-			base_window_signal_connect( window,
-					G_OBJECT( model->private->treeview ), "drag-end", G_CALLBACK( nact_tree_model_dnd_on_drag_end ));
-
-			na_settings_register_key_callback( NA_IPREFS_ITEMS_LIST_ORDER_MODE, G_CALLBACK( on_settings_order_mode_changed ), model );
-
-			base_window_signal_connect( window,
-					G_OBJECT( window ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, G_CALLBACK( on_tab_updatable_item_updated ));
+			base_window_signal_connect(
+					window,
+					G_OBJECT( model->private->treeview ),
+					"drag-end",
+					G_CALLBACK( nact_tree_model_dnd_on_drag_end ));
+
+			na_settings_register_key_callback(
+					NA_IPREFS_ITEMS_LIST_ORDER_MODE,
+					G_CALLBACK( on_settings_order_mode_changed ),
+					model );
+
+			base_window_signal_connect(
+					window,
+					G_OBJECT( window ),
+					TAB_UPDATABLE_SIGNAL_ITEM_UPDATED,
+					G_CALLBACK( on_tab_updatable_item_updated ));
 		}
 	}
 }
@@ -443,12 +453,11 @@ static void
 on_tab_updatable_item_updated( BaseWindow *window, NAIContext *context, guint data, gpointer user_data )
 {
 	static const gchar *thisfn = "nact_tree_model_on_tab_updatable_item_updated";
-	NactTreeModel *model;
 	GtkTreePath *path;
 	GtkTreeStore *store;
 	GtkTreeIter iter;
 
-	model = NACT_TREE_MODEL( g_object_get_data( G_OBJECT( window ), WINDOW_DATA_TREE_MODEL ));
+	WINDOW_MODEL_VOID( window );
 
 	if( !model->private->dispose_has_run ){
 		g_debug( "%s: window=%p, context=%p (%s), data=%u, user_data=%p",
diff --git a/src/nact/nact-tree-view.c b/src/nact/nact-tree-view.c
index 1aaa7cf..488eff7 100644
--- a/src/nact/nact-tree-view.c
+++ b/src/nact/nact-tree-view.c
@@ -54,14 +54,15 @@ struct _NactTreeViewClassPrivate {
 /* private instance data
  */
 struct _NactTreeViewPrivate {
-	gboolean      dispose_has_run;
+	gboolean       dispose_has_run;
 
 	/* properties set at instanciation time
 	 */
-	BaseWindow   *window;
-	GtkContainer *parent;
-	gchar        *widget_name;
-	guint         mode;
+	BaseWindow    *window;
+	GtkContainer  *parent;
+	gchar         *widget_name;
+	guint          mode;
+	gboolean       notify_allowed;
 
 	/* runtime data
 	 *
@@ -81,9 +82,8 @@ struct _NactTreeViewPrivate {
 	 * initialize the view. So force a call to the handler from
 	 * on_base_initialize_view() handler.
 	 */
-	GtkTreeView  *tree_view;
-	gboolean      notify_allowed;
-	gboolean      gtk_initialized;
+	GtkTreeView   *tree_view;
+	gboolean       gtk_initialized;
 };
 
 /* instance properties
@@ -624,6 +624,9 @@ instance_dispose( GObject *object )
 		gtk_tree_store_clear( ts_model );
 		g_debug( "%s: tree store cleared", thisfn );
 
+		g_debug( "%s: nact_tree_model_ref_count=%d", thisfn, G_OBJECT( model )->ref_count );
+		g_object_unref( model );
+
 		if( self->private->mode == TREE_MODE_EDITION ){
 			nact_tree_ieditable_terminate( NACT_TREE_IEDITABLE( self ));
 		}



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