[nautilus-actions] Attach each child to its parent when building the initial hierarchy
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Attach each child to its parent when building the initial hierarchy
- Date: Tue, 16 Mar 2010 21:37:15 +0000 (UTC)
commit 71dbd8f9d1648e898d36633ee50d6421581d2168
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Mar 10 21:13:12 2010 +0100
Attach each child to its parent when building the initial hierarchy
This prevents the 'is not a G_OBJECT' warning when disposing a menu.
ChangeLog | 8 ++++++++
src/core/na-io-provider.c | 10 ++++++----
src/core/na-object-id.c | 2 ++
src/core/na-object-item.c | 1 +
src/core/na-object.c | 3 +++
5 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bac7e23..739a012 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2009-03-10 Pierre Wieser <pwieser trychlos org>
+ * src/core/na-io-provider.c (build_hierarchy):
+ Attach the child item to its parent.
+
+ * src/core/na-object-id.c (instance_dispose):
+ * src/core/na-object-item.c (instance_dispose):
+ * src/core/na-object.c (instance_dispose):
+ Add debug messages.
+
* src/core/na-dbus-tracker.h: Remove no more used file.
* src/core/Makefile.am: Updated accordingly.
diff --git a/src/core/na-io-provider.c b/src/core/na-io-provider.c
index 487891f..d7e68da 100644
--- a/src/core/na-io-provider.c
+++ b/src/core/na-io-provider.c
@@ -87,7 +87,7 @@ static GList *add_io_providers_from_prefs( const NAPivot *pivot, GList *runtime_
static void dump( const NAIOProvider *provider );
static GList *get_merged_items_list( const NAPivot *pivot, GList *providers, GSList **messages );
-static GList *build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty );
+static GList *build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObjectItem *parent );
static gint search_item( const NAObject *obj, const gchar *uuid );
static GList *sort_tree( const NAPivot *pivot, GList *tree, GCompareFunc fn );
static GList *filter_unwanted_items( const NAPivot *pivot, GList *merged );
@@ -639,7 +639,7 @@ na_io_provider_read_items( const NAPivot *pivot, GSList **messages )
merged = get_merged_items_list( pivot, providers, messages );
level_zero = na_iprefs_read_string_list( NA_IPREFS( pivot ), IPREFS_LEVEL_ZERO_ITEMS, NULL );
- hierarchy = build_hierarchy( &merged, level_zero, TRUE );
+ hierarchy = build_hierarchy( &merged, level_zero, TRUE, NULL );
/* items that stay left in the merged list are simply appended
* to the built hierarchy, and level zero is updated accordingly
@@ -729,7 +729,7 @@ get_merged_items_list( const NAPivot *pivot, GList *providers, GSList **messages
* when releasing initial merged tree
*/
static GList *
-build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty )
+build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObjectItem *parent )
{
static const gchar *thisfn = "na_io_provider_build_hierarchy";
GList *hierarchy, *it;
@@ -745,6 +745,7 @@ build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty )
it = g_list_find_custom( *tree, ilevel->data, ( GCompareFunc ) search_item );
if( it ){
hierarchy = g_list_append( hierarchy, it->data );
+ na_object_set_parent( it->data, parent );
g_debug( "%s: uuid=%s: %s (%p) appended to hierarchy %p",
thisfn, ( gchar * ) ilevel->data, G_OBJECT_TYPE_NAME( it->data ), ( void * ) it->data, ( void * ) hierarchy );
@@ -753,7 +754,7 @@ build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty )
if( NA_IS_OBJECT_MENU( it->data )){
subitems_ids = na_object_get_items_slist( it->data );
- subitems = build_hierarchy( tree, subitems_ids, FALSE );
+ subitems = build_hierarchy( tree, subitems_ids, FALSE, NA_OBJECT_ITEM( it->data ));
na_object_set_items( it->data, subitems );
na_core_utils_slist_free( subitems_ids );
}
@@ -766,6 +767,7 @@ build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty )
else if( list_if_empty ){
for( it = *tree ; it ; it = it->next ){
hierarchy = g_list_append( hierarchy, it->data );
+ na_object_set_parent( it->data, parent );
}
g_list_free( *tree );
*tree = NULL;
diff --git a/src/core/na-object-id.c b/src/core/na-object-id.c
index 9f5ca10..541e1b7 100644
--- a/src/core/na-object-id.c
+++ b/src/core/na-object-id.c
@@ -161,6 +161,8 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
parent = na_object_get_parent( object );
+ g_debug( "%s: parent=%p (%s)",
+ thisfn, ( void * ) parent, parent ? G_OBJECT_TYPE_NAME( parent ) : "(n/a)" );
if( parent ){
na_object_remove_item( parent, object );
na_object_set_parent( object, NULL );
diff --git a/src/core/na-object-item.c b/src/core/na-object-item.c
index 135a755..f304904 100644
--- a/src/core/na-object-item.c
+++ b/src/core/na-object-item.c
@@ -173,6 +173,7 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
children = na_object_get_items( self );
+ g_debug( "%s: children=%p (count=%d)", thisfn, ( void * ) children, g_list_length( children ));
na_object_set_items( self, NULL );
na_object_unref_items( children );
diff --git a/src/core/na-object.c b/src/core/na-object.c
index da6da91..bbd43f7 100644
--- a/src/core/na-object.c
+++ b/src/core/na-object.c
@@ -205,10 +205,13 @@ instance_dispose( GObject *object )
static void
instance_finalize( GObject *object )
{
+ static const gchar *thisfn = "na_object_instance_finalize";
NAObject *self;
g_return_if_fail( NA_IS_OBJECT( object ));
+ g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+
self = NA_OBJECT( object );
g_free( self->private );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]