Merge lp:~charlesk/libdbusmenu/lp-1154701 into lp:libdbusmenu/13.10

Proposed by Ted Gould
Status: Merged
Approved by: Ted Gould
Approved revision: 448
Merged at revision: 450
Proposed branch: lp:~charlesk/libdbusmenu/lp-1154701
Merge into: lp:libdbusmenu/13.10
Diff against target: 898 lines (+313/-363)
5 files modified
libdbusmenu-gtk/parser.c (+55/-33)
tests/Makefile.am (+138/-328)
tests/test-glib-simple-items.c (+1/-1)
tests/test-gtk-remove-server.c (+118/-0)
tests/test-gtk-reorder-server.c (+1/-1)
To merge this branch: bzr merge lp:~charlesk/libdbusmenu/lp-1154701
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Approve
Review via email: mp+170645@code.launchpad.net

Commit message

Fix a bug caused by keeping signals connected to menuitems that we're not using anymore.

Description of the change

This patch does an extract-method on the code from our dispose() method that disconnects from a widget's signals and clears our ref to the widget. We call this new method() in our item_removed() handler s.t. we don't listen to events on a widget after it's been removed.

BACKGROUND

Drew Bliss reported an issue in dbusmenu that was triggered by creating an app indicator, passing it a gtkmenu, and then doing multiple insert/removes on the menu before returning control to the main loop.

The visible symptom of this bug was to dump out a series of g_warnings() to the terminal.

Inside libdbusmenu-gtk, we kept a pointer to a GtkMenuItem even after it was removed from the GtkMenu that we were mirroring. We also kept listening for notify events and other events from it and tried to do work on those events, which is where the g_warning() symptoms appeared.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:448
http://jenkins.qa.ubuntu.com/job/libdbusmenu-ci/7/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/libdbusmenu-saucy-amd64-ci/11

Click here to trigger a rebuild:
http://s-jenkins:8080/job/libdbusmenu-ci/7/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'docs/libdbusmenu-glib/reference/html'
2=== removed directory 'docs/libdbusmenu-gtk/reference/html'
3=== modified file 'libdbusmenu-gtk/parser.c'
4--- libdbusmenu-gtk/parser.c 2012-11-21 18:13:53 +0000
5+++ libdbusmenu-gtk/parser.c 2013-06-20 15:18:46 +0000
6@@ -273,10 +273,47 @@
7 DbusmenuMenuitem *
8 dbusmenu_gtk_parse_get_cached_item (GtkWidget * widget)
9 {
10- if (!GTK_IS_MENU_ITEM(widget)) {
11- return NULL;
12- }
13- return DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM));
14+ GObject * o = NULL;
15+ DbusmenuMenuitem * ret = NULL;
16+
17+ if (GTK_IS_MENU_ITEM (widget))
18+ o = g_object_get_data (G_OBJECT(widget), CACHED_MENUITEM);
19+
20+ if (o && DBUSMENU_IS_MENUITEM(o))
21+ ret = DBUSMENU_MENUITEM (o);
22+
23+ return ret;
24+}
25+
26+/* remove our dbusmenuitem's hooks to a GtkWidget,
27+ such as when either of them are being destroyed */
28+static void
29+disconnect_from_widget (GtkWidget * widget)
30+{
31+ ParserData * pdata = parser_data_get_from_widget (widget);
32+
33+ if (pdata && pdata->widget)
34+ {
35+ GObject * o;
36+
37+ g_assert (pdata->widget == widget);
38+
39+ /* stop listening to signals from the widget */
40+ o = G_OBJECT (pdata->widget);
41+ dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_notify_handler_id);
42+ dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_add_handler_id);
43+ dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_accel_handler_id);
44+ dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_toggle_handler_id);
45+ dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_visible_handler_id);
46+ dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_screen_changed_handler_id);
47+
48+ /* clear the menuitem's widget pointer */
49+ g_object_remove_weak_pointer (o, (gpointer*)&pdata->widget);
50+ pdata->widget = NULL;
51+
52+ /* clear the widget's menuitem pointer */
53+ g_object_set_data(o, CACHED_MENUITEM, NULL);
54+ }
55 }
56
57 static void
58@@ -297,17 +334,7 @@
59 }
60
61 if (pdata->widget != NULL) {
62- GObject * o = G_OBJECT(pdata->widget);
63- dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_notify_handler_id);
64- dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_add_handler_id);
65- dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_accel_handler_id);
66- dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_toggle_handler_id);
67- dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_visible_handler_id);
68- dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_screen_changed_handler_id);
69- g_object_remove_weak_pointer(o, (gpointer*)&pdata->widget);
70-
71- /* since the DbusmenuMenuitem is being destroyed, uncache it from the GtkWidget */
72- g_object_steal_data(o, CACHED_MENUITEM);
73+ disconnect_from_widget (pdata->widget);
74 }
75
76 if (pdata->settings != NULL) {
77@@ -379,7 +406,7 @@
78
79 pdata->widget = widget;
80 g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->widget);
81- g_object_set_data(G_OBJECT(widget), CACHED_MENUITEM, item);
82+ g_object_set_data_full(G_OBJECT(widget), CACHED_MENUITEM, g_object_ref(item), g_object_unref);
83
84 return item;
85 }
86@@ -1387,24 +1414,19 @@
87
88 /* A child item was removed from a menu we're watching. */
89 static void
90-item_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data)
91+item_removed_cb (GtkContainer *parent_w, GtkWidget *child_w, gpointer data)
92 {
93- gpointer pmi = g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM);
94- if (pmi == NULL) {
95- return;
96- }
97-
98- DbusmenuMenuitem * child = DBUSMENU_MENUITEM(pmi);
99-
100- pmi = g_object_get_data(G_OBJECT(menu), CACHED_MENUITEM);
101- if (pmi == NULL) {
102- return;
103- }
104-
105- DbusmenuMenuitem * parent = DBUSMENU_MENUITEM(pmi);
106-
107- dbusmenu_menuitem_child_delete(parent, child);
108- return;
109+ DbusmenuMenuitem * child_mi;
110+
111+ if ((child_mi = dbusmenu_gtk_parse_get_cached_item (child_w)))
112+ {
113+ DbusmenuMenuitem * parent_mi;
114+
115+ if ((parent_mi = dbusmenu_gtk_parse_get_cached_item (GTK_WIDGET(parent_w))))
116+ dbusmenu_menuitem_child_delete (parent_mi, child_mi);
117+
118+ disconnect_from_widget (child_w);
119+ }
120 }
121
122 static gboolean
123
124=== modified file 'tests/Makefile.am'
125--- tests/Makefile.am 2013-06-04 20:09:24 +0000
126+++ tests/Makefile.am 2013-06-20 15:18:46 +0000
127@@ -1,4 +1,3 @@
128-
129 DBUS_RUNNER=dbus-test-runner --max-wait=0
130
131 CLEANFILES=
132@@ -29,6 +28,7 @@
133 test-gtk-label \
134 test-gtk-shortcut \
135 test-gtk-reorder \
136+ test-gtk-remove \
137 test-gtk-parser-test
138 # Not working with GTK3 and a critical grab that is in
139 # the GTK3 code.
140@@ -81,6 +81,7 @@
141 test-gtk-label-server \
142 test-gtk-shortcut-client \
143 test-gtk-shortcut-server \
144+ test-gtk-remove-server \
145 test-gtk-reorder-server \
146 test-gtk-submenu-server \
147 test-gtk-submenu-client \
148@@ -92,6 +93,22 @@
149 # for the GI tests, prefer/use the typelibs from the local build tree
150 TESTS_ENVIRONMENT = env GI_TYPELIB_PATH=$(top_builddir)/libdbusmenu-glib:$(top_builddir)/libdbusmenu-gtk:$(GI_TYPELIB_PATH)
151
152+############################################
153+# Shared vars for the dbusmenu-glib tests
154+############################################
155+
156+DBUSMENU_GLIB_TEST_CFLAGS = \
157+ -Wall -Werror \
158+ -DG_DISABLE_DEPRECATED \
159+ -I$(top_srcdir) \
160+ $(DBUSMENUTESTS_CFLAGS) \
161+ $(DBUSMENUGLIB_CFLAGS)
162+
163+DBUSMENU_GLIB_TEST_LDADD = \
164+ $(top_builddir)/libdbusmenu-glib/libdbusmenu-glib.la \
165+ $(DBUSMENUGLIB_LIBS) \
166+ $(DBUSMENUTESTS_LIBS)
167+
168 ######################
169 # JSON Loader lib
170 ######################
171@@ -113,18 +130,11 @@
172 -export-symbols-regex "^[^_].*"
173
174 libdbusmenu_jsonloader_la_CFLAGS = \
175- $(DBUSMENUGLIB_CFLAGS) \
176- $(DBUSMENUTESTS_CFLAGS) \
177- -I $(srcdir)/.. \
178- -Wall \
179- -Werror \
180- -DG_DISABLE_DEPRECATED \
181+ $(DBUSMENU_GLIB_TEST_CFLAGS) \
182 -DG_LOG_DOMAIN="\"LIBDBUSMENU-JSONLOADER\""
183
184 libdbusmenu_jsonloader_la_LIBADD = \
185- ../libdbusmenu-glib/libdbusmenu-glib.la \
186- $(DBUSMENUGLIB_LIBS) \
187- $(DBUSMENUTESTS_LIBS)
188+ $(DBUSMENU_GLIB_TEST_LDADD)
189
190 pkgconfig_DATA = dbusmenu-jsonloader-0.4.pc
191 pkgconfigdir = $(libdir)/pkgconfig
192@@ -133,16 +143,9 @@
193 # Test GLib server
194 ######################
195
196-glib_server_nomenu_SOURCES = \
197- glib-server-nomenu.c
198-
199-glib_server_nomenu_CFLAGS = \
200- -I $(srcdir)/.. \
201- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
202-
203-glib_server_nomenu_LDADD = \
204- ../libdbusmenu-glib/libdbusmenu-glib.la \
205- $(DBUSMENUGLIB_LIBS)
206+glib_server_nomenu_SOURCES = glib-server-nomenu.c
207+glib_server_nomenu_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
208+glib_server_nomenu_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
209
210 ######################
211 # Test Glib Layout
212@@ -155,29 +158,13 @@
213 @echo $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@
214 @chmod +x $@
215
216-test_glib_layout_server_SOURCES = \
217- test-glib-layout.h \
218- test-glib-layout-server.c
219-
220-test_glib_layout_server_CFLAGS = \
221- -I $(srcdir)/.. \
222- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
223-
224-test_glib_layout_server_LDADD = \
225- ../libdbusmenu-glib/libdbusmenu-glib.la \
226- $(DBUSMENUGLIB_LIBS)
227-
228-test_glib_layout_client_SOURCES = \
229- test-glib-layout.h \
230- test-glib-layout-client.c
231-
232-test_glib_layout_client_CFLAGS = \
233- -I $(srcdir)/.. \
234- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
235-
236-test_glib_layout_client_LDADD = \
237- ../libdbusmenu-glib/libdbusmenu-glib.la \
238- $(DBUSMENUGLIB_LIBS)
239+test_glib_layout_server_SOURCES = test-glib-layout.h test-glib-layout-server.c
240+test_glib_layout_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
241+test_glib_layout_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
242+
243+test_glib_layout_client_SOURCES = test-glib-layout.h test-glib-layout-client.c
244+test_glib_layout_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
245+test_glib_layout_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
246
247 ######################
248 # Test Glib Events
249@@ -190,27 +177,13 @@
250 @echo $(DBUS_RUNNER) --task ./test-glib-events-client --task-name Client --task ./test-glib-events-server --task-name Server --ignore-return >> $@
251 @chmod +x $@
252
253-test_glib_events_server_SOURCES = \
254- test-glib-events-server.c
255-
256-test_glib_events_server_CFLAGS = \
257- -I $(srcdir)/.. \
258- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
259-
260-test_glib_events_server_LDADD = \
261- ../libdbusmenu-glib/libdbusmenu-glib.la \
262- $(DBUSMENUGLIB_LIBS)
263-
264-test_glib_events_client_SOURCES = \
265- test-glib-events-client.c
266-
267-test_glib_events_client_CFLAGS = \
268- -I $(srcdir)/.. \
269- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
270-
271-test_glib_events_client_LDADD = \
272- ../libdbusmenu-glib/libdbusmenu-glib.la \
273- $(DBUSMENUGLIB_LIBS)
274+test_glib_events_server_SOURCES = test-glib-events-server.c
275+test_glib_events_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
276+test_glib_events_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
277+
278+test_glib_events_client_SOURCES = test-glib-events-client.c
279+test_glib_events_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
280+test_glib_events_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
281
282 ################################
283 # Test Glib Events No Grouping
284@@ -223,16 +196,9 @@
285 @echo $(DBUS_RUNNER) --task ./test-glib-events-nogroup-client --task-name Client --task ./test-glib-events-server --task-name Server --ignore-return >> $@
286 @chmod +x $@
287
288-test_glib_events_nogroup_client_SOURCES = \
289- test-glib-events-nogroup-client.c
290-
291-test_glib_events_nogroup_client_CFLAGS = \
292- -I $(srcdir)/.. \
293- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
294-
295-test_glib_events_nogroup_client_LDADD = \
296- ../libdbusmenu-glib/libdbusmenu-glib.la \
297- $(DBUSMENUGLIB_LIBS)
298+test_glib_events_nogroup_client_SOURCES = test-glib-events-nogroup-client.c
299+test_glib_events_nogroup_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
300+test_glib_events_nogroup_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
301
302 ######################
303 # Test JSON
304@@ -253,30 +219,17 @@
305 test-json-server.c
306
307 test_json_server_CFLAGS = \
308- -I $(srcdir)/.. \
309- -I $(srcdir) \
310- $(DBUSMENUGLIB_CFLAGS) \
311- $(DBUSMENUTESTS_CFLAGS) \
312- $(DBUSMENUTESTSVALGRIND_CFLAGS) \
313- -Wall -Werror
314+ $(DBUSMENU_GLIB_TEST_CFLAGS) \
315+ -I$(srcdir) \
316+ $(DBUSMENUTESTSVALGRIND_CFLAGS)
317
318 test_json_server_LDADD = \
319- ../libdbusmenu-glib/libdbusmenu-glib.la \
320 libdbusmenu-jsonloader.la \
321- $(DBUSMENUTESTS_LIBS) \
322- $(DBUSMENUGLIB_LIBS)
323-
324-test_json_client_SOURCES = \
325- test-json-client.c
326-
327-test_json_client_CFLAGS = \
328- -I $(srcdir)/.. \
329- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
330-
331-test_json_client_LDADD = \
332- ../libdbusmenu-glib/libdbusmenu-glib.la \
333- $(DBUSMENUTESTS_LIBS) \
334- $(DBUSMENUGLIB_LIBS)
335+ $(DBUSMENU_GLIB_TEST_LDADD)
336+
337+test_json_client_SOURCES = test-json-client.c
338+test_json_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
339+test_json_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
340
341 #########################
342 # Test JSON Instructions
343@@ -308,29 +261,13 @@
344 @echo $(DBUS_RUNNER) --task ./test-glib-submenu-client --task-name Client --task ./test-glib-submenu-server --task-name Server --ignore-return >> $@
345 @chmod +x $@
346
347-test_glib_submenu_server_SOURCES = \
348- test-glib-submenu.h \
349- test-glib-submenu-server.c
350-
351-test_glib_submenu_server_CFLAGS = \
352- -I $(srcdir)/.. \
353- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
354-
355-test_glib_submenu_server_LDADD = \
356- ../libdbusmenu-glib/libdbusmenu-glib.la \
357- $(DBUSMENUGLIB_LIBS)
358-
359-test_glib_submenu_client_SOURCES = \
360- test-glib-submenu.h \
361- test-glib-submenu-client.c
362-
363-test_glib_submenu_client_CFLAGS = \
364- -I $(srcdir)/.. \
365- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
366-
367-test_glib_submenu_client_LDADD = \
368- ../libdbusmenu-glib/libdbusmenu-glib.la \
369- $(DBUSMENUGLIB_LIBS)
370+test_glib_submenu_server_SOURCES = test-glib-submenu.h test-glib-submenu-server.c
371+test_glib_submenu_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
372+test_glib_submenu_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
373+
374+test_glib_submenu_client_SOURCES = test-glib-submenu.h test-glib-submenu-client.c
375+test_glib_submenu_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
376+test_glib_submenu_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
377
378 ######################
379 # Test Glib Object
380@@ -345,16 +282,9 @@
381 @echo $(DBUS_RUNNER) --task gtester --task-name test --parameter --verbose --parameter -k --parameter -o --parameter $(OBJECT_XML_REPORT) --parameter ./test-glib-objects >> $@
382 @chmod +x $@
383
384-test_glib_objects_SOURCES = \
385- test-glib-objects.c
386-
387-test_glib_objects_CFLAGS = \
388- -I $(srcdir)/.. \
389- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
390-
391-test_glib_objects_LDADD = \
392- ../libdbusmenu-glib/libdbusmenu-glib.la \
393- $(DBUSMENUGLIB_LIBS)
394+test_glib_objects_SOURCES = test-glib-objects.c
395+test_glib_objects_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
396+test_glib_objects_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
397
398 DISTCLEANFILES += $(OBJECT_XML_REPORT)
399
400@@ -369,29 +299,13 @@
401 @echo $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> $@
402 @chmod +x $@
403
404-test_glib_properties_server_SOURCES = \
405- test-glib-properties.h \
406- test-glib-properties-server.c
407-
408-test_glib_properties_server_CFLAGS = \
409- -I $(srcdir)/.. \
410- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
411-
412-test_glib_properties_server_LDADD = \
413- ../libdbusmenu-glib/libdbusmenu-glib.la \
414- $(DBUSMENUGLIB_LIBS)
415-
416-test_glib_properties_client_SOURCES = \
417- test-glib-properties.h \
418- test-glib-properties-client.c
419-
420-test_glib_properties_client_CFLAGS = \
421- -I $(srcdir)/.. \
422- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
423-
424-test_glib_properties_client_LDADD = \
425- ../libdbusmenu-glib/libdbusmenu-glib.la \
426- $(DBUSMENUGLIB_LIBS)
427+test_glib_properties_server_SOURCES = test-glib-properties.h test-glib-properties-server.c
428+test_glib_properties_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
429+test_glib_properties_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
430+
431+test_glib_properties_client_SOURCES = test-glib-properties.h test-glib-properties-client.c
432+test_glib_properties_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
433+test_glib_properties_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
434
435 ######################
436 # Test Glib Proxy
437@@ -409,59 +323,41 @@
438 @echo --task ./test-glib-proxy-proxy --parameter test.proxy.last_proxy --parameter test.proxy.server --task-name Proxy05 --ignore-return >> $@
439 @chmod +x $@
440
441-test_glib_proxy_server_SOURCES = \
442- test-glib-proxy.h \
443- test-glib-proxy-server.c
444-
445-test_glib_proxy_server_CFLAGS = \
446- -I $(srcdir)/.. \
447- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
448-
449-test_glib_proxy_server_LDADD = \
450- ../libdbusmenu-glib/libdbusmenu-glib.la \
451- $(DBUSMENUGLIB_LIBS)
452-
453-test_glib_proxy_client_SOURCES = \
454- test-glib-proxy.h \
455- test-glib-proxy-client.c
456-
457-test_glib_proxy_client_CFLAGS = \
458- -I $(srcdir)/.. \
459- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
460-
461-test_glib_proxy_client_LDADD = \
462- ../libdbusmenu-glib/libdbusmenu-glib.la \
463- $(DBUSMENUGLIB_LIBS)
464-
465-test_glib_proxy_proxy_SOURCES = \
466- test-glib-proxy.h \
467- test-glib-proxy-proxy.c
468-
469-test_glib_proxy_proxy_CFLAGS = \
470- -I $(srcdir)/.. \
471- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
472-
473-test_glib_proxy_proxy_LDADD = \
474- ../libdbusmenu-glib/libdbusmenu-glib.la \
475- $(DBUSMENUGLIB_LIBS)
476+test_glib_proxy_server_SOURCES = test-glib-proxy.h test-glib-proxy-server.c
477+test_glib_proxy_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
478+test_glib_proxy_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
479+
480+test_glib_proxy_client_SOURCES = test-glib-proxy.h test-glib-proxy-client.c
481+test_glib_proxy_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
482+test_glib_proxy_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
483+
484+test_glib_proxy_proxy_SOURCES = test-glib-proxy.h test-glib-proxy-proxy.c
485+test_glib_proxy_proxy_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
486+test_glib_proxy_proxy_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
487
488 #########################
489 # Test Glib Simple Items
490 #########################
491
492-test_glib_simple_items_SOURCES = \
493- test-glib-simple-items.c
494-
495-test_glib_simple_items_CFLAGS = \
496- -I $(srcdir)/.. \
497- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
498-
499-test_glib_simple_items_LDADD = \
500- ../libdbusmenu-glib/libdbusmenu-glib.la \
501- $(DBUSMENUGLIB_LIBS)
502+test_glib_simple_items_SOURCES = test-glib-simple-items.c
503+test_glib_simple_items_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
504+test_glib_simple_items_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
505
506 EXTRA_DIST += test-glib-simple-items.py
507
508+############################################
509+# Shared vars for the dbusmenu-gtk tests
510+############################################
511+
512+DBUSMENU_GTK_TEST_CFLAGS = \
513+ $(DBUSMENUGTK_CFLAGS) \
514+ $(DBUSMENU_GLIB_TEST_CFLAGS)
515+
516+DBUSMENU_GTK_TEST_LDADD = \
517+ $(top_builddir)/libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
518+ $(DBUSMENUGTK_LIBS) \
519+ $(DBUSMENU_GLIB_TEST_LDADD)
520+
521 ######################
522 # Test GTK Object
523 ######################
524@@ -476,21 +372,9 @@
525 @echo $(DBUS_RUNNER) --task gtester --task-name test --parameter --verbose --parameter -k --parameter -o --parameter $(GTK_OBJECT_XML_REPORT) --parameter ./test-gtk-objects >> $@
526 @chmod +x $@
527
528-test_gtk_objects_SOURCES = \
529- test-gtk-objects.c
530-
531-test_gtk_objects_CFLAGS = \
532- -I $(srcdir)/.. \
533- $(DBUSMENUGLIB_CFLAGS) \
534- $(DBUSMENUGTK_CFLAGS) \
535- -DSRCDIR="\"$(srcdir)\"" \
536- -Wall -Werror
537-
538-test_gtk_objects_LDADD = \
539- ../libdbusmenu-glib/libdbusmenu-glib.la \
540- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
541- $(DBUSMENUGLIB_LIBS) \
542- $(DBUSMENUGTK_LIBS)
543+test_gtk_objects_SOURCES = test-gtk-objects.c
544+test_gtk_objects_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS) -DSRCDIR="\"$(srcdir)\""
545+test_gtk_objects_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
546
547 DISTCLEANFILES += $(GTK_OBJECT_XML_REPORT)
548
549@@ -508,21 +392,9 @@
550 @echo gtester --verbose -k -o $(GTK_PARSER_XML_REPORT) ./test-gtk-parser >> $@
551 @chmod +x $@
552
553-test_gtk_parser_SOURCES = \
554- test-gtk-parser.c
555-
556-test_gtk_parser_CFLAGS = \
557- -I $(srcdir)/.. \
558- $(DBUSMENUGLIB_CFLAGS) \
559- $(DBUSMENUGTK_CFLAGS) \
560- -DSRCDIR="\"$(srcdir)\"" \
561- -Wall -Werror
562-
563-test_gtk_parser_LDADD = \
564- ../libdbusmenu-glib/libdbusmenu-glib.la \
565- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
566- $(DBUSMENUGLIB_LIBS) \
567- $(DBUSMENUGTK_LIBS)
568+test_gtk_parser_SOURCES = test-gtk-parser.c
569+test_gtk_parser_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS) -DSRCDIR="\"$(srcdir)\""
570+test_gtk_parser_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
571
572 DISTCLEANFILES += $(GTK_PARSER_XML_REPORT)
573
574@@ -538,36 +410,13 @@
575 @echo $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@
576 @chmod +x $@
577
578-test_gtk_label_server_SOURCES = \
579- test-gtk-label-server.c
580-
581-test_gtk_label_server_CFLAGS = \
582- -I $(srcdir)/.. \
583- $(DBUSMENUGTK_CFLAGS) \
584- $(DBUSMENUTESTS_CFLAGS) \
585- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
586-
587-test_gtk_label_server_LDADD = \
588- ../libdbusmenu-glib/libdbusmenu-glib.la \
589- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
590- libdbusmenu-jsonloader.la \
591- $(DBUSMENUGTK_LIBS) \
592- $(DBUSMENUTESTS_LIBS)
593-
594-test_gtk_label_client_SOURCES = \
595- test-gtk-label-client.c
596-
597-test_gtk_label_client_CFLAGS = \
598- -I $(srcdir)/.. \
599- $(DBUSMENUGTK_CFLAGS) \
600- $(DBUSMENUTESTS_CFLAGS) \
601- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
602-
603-test_gtk_label_client_LDADD = \
604- ../libdbusmenu-glib/libdbusmenu-glib.la \
605- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
606- $(DBUSMENUGTK_LIBS) \
607- $(DBUSMENUTESTS_LIBS)
608+test_gtk_label_server_SOURCES = test-gtk-label-server.c
609+test_gtk_label_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
610+test_gtk_label_server_LDADD = libdbusmenu-jsonloader.la $(DBUSMENU_GTK_TEST_LDADD)
611+
612+test_gtk_label_client_SOURCES = test-gtk-label-client.c
613+test_gtk_label_client_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
614+test_gtk_label_client_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
615
616 #########################
617 # Test GTK Shortcut
618@@ -581,35 +430,13 @@
619 @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@
620 @chmod +x $@
621
622-test_gtk_shortcut_server_SOURCES = \
623- test-gtk-shortcut-server.c
624-
625-test_gtk_shortcut_server_CFLAGS = \
626- -I $(srcdir)/.. \
627- $(DBUSMENUGTK_CFLAGS) \
628- $(DBUSMENUTESTS_CFLAGS) \
629- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
630-
631-test_gtk_shortcut_server_LDADD = \
632- ../libdbusmenu-glib/libdbusmenu-glib.la \
633- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
634- $(DBUSMENUGTK_LIBS) \
635- $(DBUSMENUTESTS_LIBS)
636-
637-test_gtk_shortcut_client_SOURCES = \
638- test-gtk-shortcut-client.c
639-
640-test_gtk_shortcut_client_CFLAGS = \
641- -I $(srcdir)/.. \
642- $(DBUSMENUGTK_CFLAGS) \
643- $(DBUSMENUTESTS_CFLAGS) \
644- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
645-
646-test_gtk_shortcut_client_LDADD = \
647- ../libdbusmenu-glib/libdbusmenu-glib.la \
648- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
649- $(DBUSMENUGTK_LIBS) \
650- $(DBUSMENUTESTS_LIBS)
651+test_gtk_shortcut_server_SOURCES = test-gtk-shortcut-server.c
652+test_gtk_shortcut_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
653+test_gtk_shortcut_server_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
654+
655+test_gtk_shortcut_client_SOURCES = test-gtk-shortcut-client.c
656+test_gtk_shortcut_client_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
657+test_gtk_shortcut_client_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
658
659 #########################
660 # Test GTK Shortcut Python
661@@ -627,6 +454,22 @@
662 CLEANFILES += test-gtk-shortcut-client.pyc
663
664 #########################
665+# Test GTK Remove
666+#########################
667+
668+test-gtk-remove: test-gtk-remove-server Makefile.am
669+ @echo "#!/bin/bash" > $@
670+ @echo export UBUNTU_MENUPROXY="" >> $@
671+ @echo export G_DEBUG=fatal_criticals >> $@
672+ @echo $(XVFB_RUN) >> $@
673+ @echo $(DBUS_RUNNER) --task ./test-gtk-remove-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@
674+ @chmod +x $@
675+
676+test_gtk_remove_server_SOURCES = test-gtk-remove-server.c
677+test_gtk_remove_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
678+test_gtk_remove_server_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
679+
680+#########################
681 # Test GTK Reorder
682 #########################
683
684@@ -638,20 +481,9 @@
685 @echo $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-reorder-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@
686 @chmod +x $@
687
688-test_gtk_reorder_server_SOURCES = \
689- test-gtk-reorder-server.c
690-
691-test_gtk_reorder_server_CFLAGS = \
692- -I $(srcdir)/.. \
693- $(DBUSMENUGTK_CFLAGS) \
694- $(DBUSMENUTESTS_CFLAGS) \
695- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
696-
697-test_gtk_reorder_server_LDADD = \
698- ../libdbusmenu-glib/libdbusmenu-glib.la \
699- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
700- $(DBUSMENUGTK_LIBS) \
701- $(DBUSMENUTESTS_LIBS)
702+test_gtk_reorder_server_SOURCES = test-gtk-reorder-server.c
703+test_gtk_reorder_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
704+test_gtk_reorder_server_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
705
706 #########################
707 # Test GTK Submenu
708@@ -665,35 +497,13 @@
709 @echo $(DBUS_RUNNER) --task ./test-gtk-submenu-client --task-name Client --task ./test-gtk-submenu-server --task-name Server --ignore-return >> $@
710 @chmod +x $@
711
712-test_gtk_submenu_server_SOURCES = \
713- test-gtk-submenu-server.c
714-
715-test_gtk_submenu_server_CFLAGS = \
716- -I $(srcdir)/.. \
717- $(DBUSMENUGTK_CFLAGS) \
718- $(DBUSMENUTESTS_CFLAGS) \
719- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
720-
721-test_gtk_submenu_server_LDADD = \
722- ../libdbusmenu-glib/libdbusmenu-glib.la \
723- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
724- $(DBUSMENUGTK_LIBS) \
725- $(DBUSMENUTESTS_LIBS)
726-
727-test_gtk_submenu_client_SOURCES = \
728- test-gtk-submenu-client.c
729-
730-test_gtk_submenu_client_CFLAGS = \
731- -I $(srcdir)/.. \
732- $(DBUSMENUGTK_CFLAGS) \
733- $(DBUSMENUTESTS_CFLAGS) \
734- $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
735-
736-test_gtk_submenu_client_LDADD = \
737- ../libdbusmenu-glib/libdbusmenu-glib.la \
738- ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
739- $(DBUSMENUGTK_LIBS) \
740- $(DBUSMENUTESTS_LIBS)
741+test_gtk_submenu_server_SOURCES = test-gtk-submenu-server.c
742+test_gtk_submenu_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
743+test_gtk_submenu_server_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
744+
745+test_gtk_submenu_client_SOURCES = test-gtk-submenu-client.c
746+test_gtk_submenu_client_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
747+test_gtk_submenu_client_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
748
749 #########################
750 # Test Mago
751
752=== modified file 'tests/test-glib-simple-items.c'
753--- tests/test-glib-simple-items.c 2013-01-21 16:04:47 +0000
754+++ tests/test-glib-simple-items.c 2013-06-20 15:18:46 +0000
755@@ -25,7 +25,7 @@
756 static gboolean
757 quititall (gpointer data)
758 {
759- g_main_quit(mainloop);
760+ g_main_loop_quit(mainloop);
761 return FALSE;
762 }
763
764
765=== added file 'tests/test-gtk-remove-server.c'
766--- tests/test-gtk-remove-server.c 1970-01-01 00:00:00 +0000
767+++ tests/test-gtk-remove-server.c 2013-06-20 15:18:46 +0000
768@@ -0,0 +1,118 @@
769+/*
770+ Confirm that no warnings/criticals get generated by including
771+ multiple add/removes in a match w/o waiting on the mainloop to iterate.
772+
773+ Copyright 2013 Canonical Ltd.
774+
775+ Original sample code by Drew Bliss <drewb@valvesoftware.com>
776+ Modified for automatic testing by Charles Kerr <charles.kerr@canonical.com>
777+ */
778+
779+#include <stdlib.h> /* exit() */
780+#include <gtk/gtk.h>
781+#include <libdbusmenu-glib/server.h>
782+#include <libdbusmenu-gtk/menu.h>
783+#include <libdbusmenu-gtk/parser.h>
784+
785+static GMainLoop * loop = NULL;
786+static GtkWidget * top_gtk = NULL;
787+static DbusmenuMenuitem * top_dbusmenu = NULL;
788+static DbusmenuServer * menuservice = NULL;
789+
790+static void
791+rebuild_menu (void)
792+{
793+ GList * l;
794+ GList * children;
795+ int i;
796+ const int n = 10;
797+ static int count = 0;
798+
799+ if (top_gtk == NULL)
800+ {
801+ top_gtk = gtk_menu_new ();
802+ gtk_widget_show (top_gtk);
803+ top_dbusmenu = dbusmenu_gtk_parse_menu_structure (top_gtk);
804+ menuservice = dbusmenu_server_new ("/org/ayatana/NotificationItem/test/Menu");
805+ dbusmenu_server_set_root (menuservice, top_dbusmenu);
806+ }
807+
808+ // remove all the previous children
809+ children = gtk_container_get_children (GTK_CONTAINER(top_gtk));
810+ for (l=children; l!=NULL; l=l->next)
811+ gtk_widget_destroy (GTK_WIDGET (l->data));
812+
813+ // add a handful of new children
814+ for (i=0; i<n; ++i)
815+ {
816+ char buf[80];
817+ GtkWidget * child;
818+
819+ g_snprintf (buf, sizeof(buf), "Test item %d", ++count);
820+ child = gtk_menu_item_new_with_label (buf);
821+ gtk_menu_shell_append (GTK_MENU_SHELL(top_gtk), child);
822+ gtk_widget_show (child);
823+ }
824+}
825+
826+/*
827+ * Periodically rebuild the menu.
828+ *
829+ * After we've looped a couple of times with only one rebuild,
830+ * attempt to reproduce the bug Drew reported by rebuilding multiple
831+ * times before returning control to the main loop.
832+ *
833+ * If we survive doing this a handful of times without encountering
834+ * a g_warning or g_critical, pass the test.
835+ */
836+static gint
837+on_timer (gpointer unused G_GNUC_UNUSED)
838+{
839+ static int iteration = 0;
840+
841+ ++iteration;
842+
843+ if (iteration > 5)
844+ {
845+ g_main_loop_quit (loop);
846+ return G_SOURCE_REMOVE;
847+ }
848+
849+ if (iteration <= 2)
850+ {
851+ rebuild_menu ();
852+ }
853+ else
854+ {
855+ int i;
856+
857+ for (i=0; i<iteration; ++i)
858+ rebuild_menu ();
859+ }
860+
861+ return G_SOURCE_CONTINUE;
862+}
863+
864+static void
865+warning_counter (const gchar * log_domain,
866+ GLogLevelFlags log_level G_GNUC_UNUSED,
867+ const gchar * message,
868+ gpointer user_data G_GNUC_UNUSED)
869+{
870+ g_message ("Failing the test due to warning: %s %s", log_domain, message);
871+ exit (EXIT_FAILURE);
872+}
873+
874+int
875+main (int argc, char ** argv)
876+{
877+ g_log_set_handler ("LIBDBUSMENU-GLIB", G_LOG_LEVEL_WARNING|G_LOG_LEVEL_CRITICAL, warning_counter, NULL);
878+
879+
880+ gtk_init (&argc, &argv);
881+ loop = g_main_loop_new (NULL, FALSE);
882+ g_timeout_add (200, on_timer, NULL);
883+ g_main_loop_run (loop);
884+
885+ return 0;
886+}
887
888=== modified file 'tests/test-gtk-reorder-server.c'
889--- tests/test-gtk-reorder-server.c 2013-01-21 16:04:47 +0000
890+++ tests/test-gtk-reorder-server.c 2013-06-20 15:18:46 +0000
891@@ -52,7 +52,7 @@
892 timer_func (gpointer data)
893 {
894 if (test == NUMBER_TESTS) {
895- g_main_quit(mainloop);
896+ g_main_loop_quit(mainloop);
897 return FALSE;
898 }
899

Subscribers

People subscribed via source and target branches

to all changes: