[nautilus-actions] Fix infinite unref of child items



commit 37c39cc450855a956d81af4efa2bd07d8d77eea4
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Jun 20 09:22:05 2010 +0200

    Fix infinite unref of child items

 ChangeLog                  |   10 +++++++++-
 src/core/na-object.c       |   18 +++++++++++++-----
 src/nact/nact-tree-model.c |   14 ++++++++------
 3 files changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 04e6d7c..6519add 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-20 Pierre Wieser <pwieser trychlos org>
+
+	* src/core/na-object.c (na_object_object_unref):
+	Fix infinite unref of child items.
+
+	* src/nact/nact-tree-model.c (nact_tree_model_display):
+	Set debug messages.
+
 2010-06-18 Pierre Wieser <pwieser trychlos org>
 
 	* src/core/na-object.c (na_object_object_unref):
@@ -11,7 +19,7 @@
 	Explicitely write the numeric version to GConf.
 
 	* src/core/na-object-item-factory.c:
-	Provider data is no more duplicable by NAObjectFactory.
+	Provider data is no more duplicable by NAIFactoryObject.
 
 	* src/core/na-object-item.c (object_copy):
 	Explicitely triggers NAIOProvider::duplicate_data method.
diff --git a/src/core/na-object.c b/src/core/na-object.c
index e160a4b..01b8882 100644
--- a/src/core/na-object.c
+++ b/src/core/na-object.c
@@ -711,25 +711,33 @@ void
 na_object_object_unref( NAObject *object )
 {
 	GList *children;
-
-	g_debug( "na_object_object_unref:enter: object=%p (%s, ref_count=%d)",
-			( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count );
+	GList *ic, *icnext;
 
 	g_return_if_fail( NA_IS_OBJECT( object ));
 
 	if( !object->private->dispose_has_run ){
 
+		g_debug( "na_object_object_unref:enter: object=%p (%s, ref_count=%d)",
+				( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count );
+
 		if( NA_IS_OBJECT_ITEM( object )){
+
+#if 0
 			while( TRUE ){
 				children = na_object_get_items( object );
-
 				if( children ){
 					na_object_unref( children->data );
-
 				} else {
 					break;
 				}
 			}
+#endif
+
+			children = na_object_get_items( object );
+			for( ic = children ; ic ; ic = icnext ){
+				icnext = ic->next;
+				g_object_unref( ic->data );
+			}
 		}
 
 		g_debug( "na_object_object_unref:about_to_unref: object=%p (%s, ref_count=%d)",
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 692e407..fa28232 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -445,16 +445,18 @@ nact_tree_model_dispose( NactTreeModel *model )
 void
 nact_tree_model_display( NactTreeModel *model, NAObject *object )
 {
-	/*static const gchar *thisfn = "nact_tree_model_display";*/
+	static const gchar *thisfn = "nact_tree_model_display";
 	GtkTreeStore *store;
 	GtkTreeIter iter;
 	GtkTreePath *path;
 
-	/*g_debug( "%s: model=%p (%s), object=%p (%s)", thisfn,
-			( void * ) model, G_OBJECT_TYPE_NAME( model ),
-			( void * ) object, G_OBJECT_TYPE_NAME( object ));*/
 	g_return_if_fail( NACT_IS_TREE_MODEL( model ));
 
+	g_debug( "%s: model=%p (%s), object=%p (%s)",
+			thisfn,
+			( void * ) model, G_OBJECT_TYPE_NAME( model ),
+			( void * ) object, G_OBJECT_TYPE_NAME( object ));
+
 	if( !model->private->dispose_has_run ){
 
 		store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
@@ -1013,8 +1015,8 @@ iter_on_store_item( NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *iter
 	 * unchanged in dump_store
 	 */
 	g_object_unref( object );
-	/*g_debug( "nact_tree_model_iter_on_store_item: object=%p (%s, ref_count=%d)",
-			( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count );*/
+	g_debug( "nact_tree_model_iter_on_store_item: object=%p (%s, ref_count=%d)",
+			( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count );
 
 	path = gtk_tree_model_get_path( store, iter );
 



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