[nautilus-actions] Duplicate the candidate profile, setting its parent to Null



commit e8d84dde3c25e9921a945244930c79fba992e172
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Apr 14 21:32:33 2010 +0200

    Duplicate the candidate profile, setting its parent to Null
    
    This prevents Nautilus to crash when trying to unref the previous profile, thus trying to unref
    a no-more existing parent.

 ChangeLog                          |    3 +++
 src/plugin-menu/nautilus-actions.c |    7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ff7b2a1..620ba31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-04-14 Pierre Wieser <pwieser trychlos org>
 
+	* src/plugin-menu/nautilus-actions.c (create_item_from_profile):
+	Duplicate the candidate profile, set the parent to null.
+
 	* src/core/na-selected-info.c (na_selected_info_get_location):
 	Increment the reference count of the returned location.
 
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index 9f4fb4d..bfa10f7 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -646,8 +646,11 @@ create_item_from_profile( NAObjectProfile *profile, guint target, GList *files )
 {
 	NautilusMenuItem *item;
 	NAObjectAction *action;
+	NAObjectProfile *duplicate;
 
 	action = NA_OBJECT_ACTION( na_object_get_parent( profile ));
+	duplicate = NA_OBJECT_PROFILE( na_object_duplicate( profile ));
+	na_object_set_parent( duplicate, NULL );
 
 	item = create_menu_item( NA_OBJECT_ITEM( action ));
 
@@ -657,9 +660,9 @@ create_item_from_profile( NAObjectProfile *profile, guint target, GList *files )
 	g_signal_connect( item,
 				"activate",
 				G_CALLBACK( execute_action ),
-				g_object_ref( profile ));
+				duplicate );
 
-	g_object_weak_ref( G_OBJECT( item ), ( GWeakNotify ) weak_notify_profile, profile );
+	g_object_weak_ref( G_OBJECT( item ), ( GWeakNotify ) weak_notify_profile, duplicate );
 
 	g_object_set_data_full( G_OBJECT( item ),
 			"nautilus-actions-files",



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