Merge lp:~mterry/indicator-appmenu/double-ref-of-entry-label into lp:indicator-appmenu/0.3

Proposed by Michael Terry on 2011-10-05
Status: Merged
Merged at revision: 132
Proposed branch: lp:~mterry/indicator-appmenu/double-ref-of-entry-label
Merge into: lp:indicator-appmenu/0.3
Diff against target: 12 lines (+1/-1)
1 file modified
src/window-menus.c (+1/-1)
To merge this branch: bzr merge lp:~mterry/indicator-appmenu/double-ref-of-entry-label
Reviewer Review Type Date Requested Status
Indicator Applet Developers 2011-10-05 Pending
Review via email: mp+78300@code.launchpad.net

Description of the change

indicator-appmenu is creating a label for an IndicatorObjectEntry object then immediately ref'ing it. I believe this is because it wants to own the label and have it persist across container adds/removes.

Which works if it is added to a container. (the container will then claim the floating ref and remove it when done). But if not added to a container (and I can't see where that happens, so I'm guessing it doesn't?...), the floating ref will never be claimed and memory will be leaked.

It's better to just sink the ref ourselves. That way, we own the floating ref and free it, and other containers or users of the label can use normal ref semantics.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/window-menus.c'
2--- src/window-menus.c 2011-09-23 21:01:19 +0000
3+++ src/window-menus.c 2011-10-05 18:17:25 +0000
4@@ -742,7 +742,7 @@
5 entry->label = GTK_LABEL(gtk_label_new_with_mnemonic(dbusmenu_menuitem_property_get(newentry, DBUSMENU_MENUITEM_PROP_LABEL)));
6
7 if (entry->label != NULL) {
8- g_object_ref(entry->label);
9+ g_object_ref_sink(entry->label);
10 }
11
12 entry->accessible_desc = dbusmenu_menuitem_property_get(newentry, DBUSMENU_MENUITEM_PROP_LABEL);

Subscribers

People subscribed via source and target branches