Merge lp:~chrisccoulson/libdbusmenu/set-cached-menuitem into lp:libdbusmenu/0.5

Proposed by Chris Coulson
Status: Merged
Merged at revision: 258
Proposed branch: lp:~chrisccoulson/libdbusmenu/set-cached-menuitem
Merge into: lp:libdbusmenu/0.5
Diff against target: 22 lines (+5/-0)
1 file modified
libdbusmenu-gtk/parser.c (+5/-0)
To merge this branch: bzr merge lp:~chrisccoulson/libdbusmenu/set-cached-menuitem
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+52624@code.launchpad.net

Description of the change

Whilst investigating bug 723463, I wrote a small Python test application which just rapidly added/removed menus from the menubar at random, and noticed that under most conditions, menus were not being removed from the menubar when being removed from the application.

Initially, it seemed this might be related to bug 723463, but after some more digging I realised this problem was actually occurring on the application side (I wasn't seeing menuitem_child_removed being called in DbusmenuServer, and other weird things were happening such as widget_notfy_cb was being called in the parser with pscpec=submenu, but no DbusmenuMenuitem associated with the widget).

Then, I realised that we never actually set CACHED_MENUITEM anywhere in the parser!

This branch fixes this. As a side-effect of this, calling dbusmenu_gtk_parse_menu_structure more than once on the same GtkWidget will result in the immediate children of that widget already having another DbusmenuMenuitem parent (the original root item), so we have to unreparent these where this happens.

To post a comment you must log in.
Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Oh, this actually fixes bug 729128

Revision history for this message
Ted Gould (ted) wrote :

Heh, I actually had a branch fixing this. You Desktopers are too fast! I'll get you next time! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-gtk/parser.c'
2--- libdbusmenu-gtk/parser.c 2011-03-01 17:41:58 +0000
3+++ libdbusmenu-gtk/parser.c 2011-03-08 23:11:57 +0000
4@@ -219,6 +219,7 @@
5
6 pdata->widget = widget;
7 g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->widget);
8+ g_object_set_data(G_OBJECT(widget), CACHED_MENUITEM, item);
9
10 return item;
11 }
12@@ -311,6 +312,10 @@
13
14 /* Oops, let's tell our parents about us */
15 if (peek == NULL) {
16+ if (dbusmenu_menuitem_get_parent(thisitem) != NULL) {
17+ dbusmenu_menuitem_unparent(thisitem);
18+ }
19+
20 gint pos = get_child_position (widget);
21 if (pos >= 0)
22 dbusmenu_menuitem_child_add_position (recurse->parent,

Subscribers

People subscribed via source and target branches