Re: Releasing context menu items ?



> From: Alexander Larsson <alexl redhat com>
 
> On Thu, 2010-03-04 at 14:14 +0100, Pierre Wieser wrote:
> > Hi guys,
> > 
> > It appeared to me yesterday (or very soon this morning ;-)) that 
> > (at least) context menu items created by a menu provider extension
> > are only released when changing current folder, not when changing 
> > the selection, and, when releasing, only those corresponding to the
> > latest selection are, not those for previous selections.
> > 
> > Does someone may confirm this ?
> 
> I haven't tried this, but looking at the  code it *seems* like it
> should free the items in reset_extension_actions_menu, i.e. whenever
> updating the context menu. However, the way it happens is a bit convolted,
> via the nautilus_ui_unmerge_ui() call unreferencing the actions and thus
> the items, so it could very well be an issue hiding in this complexity
> somewhere.
> 
> It would be nice if you could look into this in more detail.
> 
> -- 

Well I've looked into this a bit more, yes.

The context is :
- for each menu action, I allocate a new profile, thus having a
  trace as 'na_object_profile_instance_init'..
- I add a weak reference on the NautilusMenuItem in order to be able to
  unref and dispose this profile
- I also install a notification on NautilusMenuitem with g_object_set_data_full
  (so using a GDestroyNotify function) in order to nautilus_file_info_list_free()
  the list of selected items.

I paste a trace below ; sorry if it is long, but executive summary is:

- when actions are at the level zero of the context menu, all works fine
- when actions are inside of a menu (I don't have tried with a menu in a menu),
  then the weak notify function is actually called on the menu, but not
  on its subitems
- in this later case, only when entering a directory, the first profile
  is disposed and the destroy notify is called on the selected items list.

Maybe I should'nt add a ref on subitems on the menus ?
This would appear to me rather like a work-around ?

I'm of course willing to go through Nautilus code but I go to ski next week,
so more on this on next one ;-)

Regards
Pierre

-------------------------------- begin of trace

Having just one action added to the context menu

Mar  5 17:36:51 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x1b338d0 (NAObjectProfile), klass=0x167e0a0
Mar  5 17:36:52 kermit nautilus: nautilus_actions_weak_notify_profile: profile=0x1bda390 (ref_count=1)
Mar  5 17:36:52 kermit nautilus: [NA-core] na_object_profile_instance_dispose: object=0x1bda390 (NAObjectProfile)
Mar  5 17:36:52 kermit nautilus: nautilus_actions_destroy_notify_file_list

moving the selection

Mar  5 17:36:55 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x1cfb470 (NAObjectProfile), klass=0x167e0a0
Mar  5 17:36:56 kermit nautilus: nautilus_actions_weak_notify_profile: profile=0x1b338d0 (ref_count=1)
Mar  5 17:36:56 kermit nautilus: [NA-core] na_object_profile_instance_dispose: object=0x1b338d0 (NAObjectProfile)
Mar  5 17:36:56 kermit nautilus: nautilus_actions_destroy_notify_file_list

moving the selection

Mar  5 17:36:56 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x7f3978028730 (NAObjectProfile), klass=0x167e0a0
Mar  5 17:36:57 kermit nautilus: nautilus_actions_weak_notify_profile: profile=0x1cfb470 (ref_count=1)
Mar  5 17:36:57 kermit nautilus: [NA-core] na_object_profile_instance_dispose: object=0x1cfb470 (NAObjectProfile)
Mar  5 17:36:57 kermit nautilus: nautilus_actions_destroy_notify_file_list

Having the same action inside of a menu (i.e. a submenu from context menu)
killall nautilus

Mar  5 18:53:35 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x20c1c60 (NAObjectProfile), klass=0x1bf51d0

select first item

Mar  5 18:53:35 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x20c1c60 (NAObjectProfile), klass=0x1bf51d0

move the selection

Mar  5 18:54:18 kermit nautilus: nautilus_actions_weak_notify_menu: menu=0x1bd9480 (ref_count=1)
Mar  5 18:54:22 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x20bd670 (NAObjectProfile), klass=0x1bf51d0

move the selection

Mar  5 18:54:50 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x7f36e4014d80 (NAObjectProfile), klass=0x1bf51d0
Mar  5 18:54:50 kermit nautilus: nautilus_actions_weak_notify_menu: menu=0x1bd9480 (ref_count=1)

entering a directory

Mar  5 18:55:21 kermit nautilus: nautilus_actions_weak_notify_menu: menu=0x1bd9480 (ref_count=1)
Mar  5 18:55:21 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x20c3150 (NAObjectProfile), klass=0x1bf51d0
Mar  5 18:55:21 kermit nautilus: nautilus_actions_weak_notify_profile: profile=0x20c1c60 (ref_count=1)
Mar  5 18:55:21 kermit nautilus: [NA-core] na_object_profile_instance_dispose: object=0x20c1c60 (NAObjectProfile)
Mar  5 18:55:21 kermit nautilus: nautilus_actions_destroy_notify_file_list

select first item

Mar  5 18:55:58 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x7f36dc006f80 (NAObjectProfile), klass=0x1bf51d0

moving the selection

Mar  5 18:56:17 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x7f36dc009260 (NAObjectProfile), klass=0x1bf51d0
Mar  5 18:56:17 kermit nautilus: nautilus_actions_weak_notify_menu: menu=0x1bd9480 (ref_count=1)

moving the selection

Mar  5 19:08:28 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x225ab00 (NAObjectProfile), klass=0x1bf51d0
Mar  5 19:08:28 kermit nautilus: nautilus_actions_weak_notify_menu: menu=0x1bd9480 (ref_count=1)

entering a directory

Mar  5 19:08:54 kermit nautilus: nautilus_actions_weak_notify_profile: profile=0x20c3150 (ref_count=1)
Mar  5 19:08:54 kermit nautilus: [NA-core] na_object_profile_instance_dispose: object=0x20c3150 (NAObjectProfile)
Mar  5 19:08:54 kermit nautilus: nautilus_actions_destroy_notify_file_list
Mar  5 19:08:54 kermit nautilus: [NA-core] na_object_profile_instance_init: instance=0x20a7d60 (NAObjectProfile), klass=0x1bf51d0
Mar  5 19:08:54 kermit nautilus: nautilus_actions_weak_notify_menu: menu=0x1bd9480 (ref_count=1)

-------------------------------- end of trace


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