Merge lp:~mterry/indicator-appmenu/one-too-many-refs into lp:indicator-appmenu/0.3

Proposed by Michael Terry on 2011-09-23
Status: Merged
Merged at revision: 130
Proposed branch: lp:~mterry/indicator-appmenu/one-too-many-refs
Merge into: lp:indicator-appmenu/0.3
Diff against target: 37 lines (+4/-4)
2 files modified
src/Makefile.am (+2/-2)
src/window-menus.c (+2/-2)
To merge this branch: bzr merge lp:~mterry/indicator-appmenu/one-too-many-refs
Reviewer Review Type Date Requested Status
Indicator Applet Developers 2011-09-23 Pending
Review via email: mp+76809@code.launchpad.net

Description of the change

In the course of tracking down the memory in bug 835646, I found this leak. It fixes part of the problem, but seemingly not all of it.

The problem here is that a ref is made before a call, thinking the call will unref it. But it doesn't. The call does a ref/unref pair.

(it's slightly more complicated than that. the call thinks that by disconnecting a signal, it will unref a ref that it expects to be made by the outer function (thus, reffing once and unreffing twice) -- but this particular code path doesn't do that, so the outer function ref isn't needed)

To post a comment you must log in.
Michael Terry (mterry) wrote :

(and I threw in a Makefile.am fix for free)

129. By Michael Terry on 2011-09-23

don't add an extra ref for new menuitems

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Makefile.am'
2--- src/Makefile.am 2011-01-12 23:59:56 +0000
3+++ src/Makefile.am 2011-09-23 21:05:15 +0000
4@@ -45,14 +45,14 @@
5
6 gen-%.xml.c: %.xml
7 @echo "Building $@ from $<"
8- @echo "const char * _$(subst -,_,$(subst .,_,$(basename $<))) = " > $@
9+ @echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@
10 @$(XSLT_PROC) $(srcdir)/clean-namespaces.xslt $< | \
11 sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": >> $@
12 @echo ";" >> $@
13
14 gen-%.xml.h: %.xml
15 @echo "Building $@ from $<"
16- @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $<)));" > $@
17+ @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<))));" > $@
18
19 BUILT_SOURCES += \
20 gen-application-menu-renderer.xml.c \
21
22=== modified file 'src/window-menus.c'
23--- src/window-menus.c 2011-06-07 19:38:59 +0000
24+++ src/window-menus.c 2011-09-23 21:05:15 +0000
25@@ -669,10 +669,10 @@
26 } else {
27 gpointer * data = g_new(gpointer, 2);
28 data[0] = user_data;
29- data[1] = g_object_ref(newentry);
30- /* child_realized does an unref */
31+ data[1] = newentry;
32
33 menu_child_realized(NULL, data);
34+ g_free (data);
35 }
36
37 return;

Subscribers

People subscribed via source and target branches