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
=== removed directory 'docs/libdbusmenu-glib/reference/html'
=== removed directory 'docs/libdbusmenu-gtk/reference/html'
=== modified file 'libdbusmenu-gtk/parser.c'
--- libdbusmenu-gtk/parser.c 2012-11-21 18:13:53 +0000
+++ libdbusmenu-gtk/parser.c 2013-06-20 15:18:46 +0000
@@ -273,10 +273,47 @@
273DbusmenuMenuitem *273DbusmenuMenuitem *
274dbusmenu_gtk_parse_get_cached_item (GtkWidget * widget)274dbusmenu_gtk_parse_get_cached_item (GtkWidget * widget)
275{275{
276 if (!GTK_IS_MENU_ITEM(widget)) {276 GObject * o = NULL;
277 return NULL;277 DbusmenuMenuitem * ret = NULL;
278 }278
279 return DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM));279 if (GTK_IS_MENU_ITEM (widget))
280 o = g_object_get_data (G_OBJECT(widget), CACHED_MENUITEM);
281
282 if (o && DBUSMENU_IS_MENUITEM(o))
283 ret = DBUSMENU_MENUITEM (o);
284
285 return ret;
286}
287
288/* remove our dbusmenuitem's hooks to a GtkWidget,
289 such as when either of them are being destroyed */
290static void
291disconnect_from_widget (GtkWidget * widget)
292{
293 ParserData * pdata = parser_data_get_from_widget (widget);
294
295 if (pdata && pdata->widget)
296 {
297 GObject * o;
298
299 g_assert (pdata->widget == widget);
300
301 /* stop listening to signals from the widget */
302 o = G_OBJECT (pdata->widget);
303 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_notify_handler_id);
304 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_add_handler_id);
305 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_accel_handler_id);
306 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_toggle_handler_id);
307 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_visible_handler_id);
308 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_screen_changed_handler_id);
309
310 /* clear the menuitem's widget pointer */
311 g_object_remove_weak_pointer (o, (gpointer*)&pdata->widget);
312 pdata->widget = NULL;
313
314 /* clear the widget's menuitem pointer */
315 g_object_set_data(o, CACHED_MENUITEM, NULL);
316 }
280}317}
281318
282static void319static void
@@ -297,17 +334,7 @@
297 }334 }
298335
299 if (pdata->widget != NULL) {336 if (pdata->widget != NULL) {
300 GObject * o = G_OBJECT(pdata->widget);337 disconnect_from_widget (pdata->widget);
301 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_notify_handler_id);
302 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_add_handler_id);
303 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_accel_handler_id);
304 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_toggle_handler_id);
305 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_visible_handler_id);
306 dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_screen_changed_handler_id);
307 g_object_remove_weak_pointer(o, (gpointer*)&pdata->widget);
308
309 /* since the DbusmenuMenuitem is being destroyed, uncache it from the GtkWidget */
310 g_object_steal_data(o, CACHED_MENUITEM);
311 }338 }
312339
313 if (pdata->settings != NULL) {340 if (pdata->settings != NULL) {
@@ -379,7 +406,7 @@
379406
380 pdata->widget = widget;407 pdata->widget = widget;
381 g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->widget);408 g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->widget);
382 g_object_set_data(G_OBJECT(widget), CACHED_MENUITEM, item);409 g_object_set_data_full(G_OBJECT(widget), CACHED_MENUITEM, g_object_ref(item), g_object_unref);
383410
384 return item;411 return item;
385}412}
@@ -1387,24 +1414,19 @@
13871414
1388/* A child item was removed from a menu we're watching. */1415/* A child item was removed from a menu we're watching. */
1389static void1416static void
1390item_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data)1417item_removed_cb (GtkContainer *parent_w, GtkWidget *child_w, gpointer data)
1391{1418{
1392 gpointer pmi = g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM);1419 DbusmenuMenuitem * child_mi;
1393 if (pmi == NULL) {1420
1394 return;1421 if ((child_mi = dbusmenu_gtk_parse_get_cached_item (child_w)))
1395 }1422 {
13961423 DbusmenuMenuitem * parent_mi;
1397 DbusmenuMenuitem * child = DBUSMENU_MENUITEM(pmi);1424
13981425 if ((parent_mi = dbusmenu_gtk_parse_get_cached_item (GTK_WIDGET(parent_w))))
1399 pmi = g_object_get_data(G_OBJECT(menu), CACHED_MENUITEM);1426 dbusmenu_menuitem_child_delete (parent_mi, child_mi);
1400 if (pmi == NULL) {1427
1401 return;1428 disconnect_from_widget (child_w);
1402 }1429 }
1403
1404 DbusmenuMenuitem * parent = DBUSMENU_MENUITEM(pmi);
1405
1406 dbusmenu_menuitem_child_delete(parent, child);
1407 return;
1408}1430}
14091431
1410static gboolean1432static gboolean
14111433
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2013-06-04 20:09:24 +0000
+++ tests/Makefile.am 2013-06-20 15:18:46 +0000
@@ -1,4 +1,3 @@
1
2DBUS_RUNNER=dbus-test-runner --max-wait=01DBUS_RUNNER=dbus-test-runner --max-wait=0
32
4CLEANFILES=3CLEANFILES=
@@ -29,6 +28,7 @@
29 test-gtk-label \28 test-gtk-label \
30 test-gtk-shortcut \29 test-gtk-shortcut \
31 test-gtk-reorder \30 test-gtk-reorder \
31 test-gtk-remove \
32 test-gtk-parser-test32 test-gtk-parser-test
33# Not working with GTK3 and a critical grab that is in33# Not working with GTK3 and a critical grab that is in
34# the GTK3 code.34# the GTK3 code.
@@ -81,6 +81,7 @@
81 test-gtk-label-server \81 test-gtk-label-server \
82 test-gtk-shortcut-client \82 test-gtk-shortcut-client \
83 test-gtk-shortcut-server \83 test-gtk-shortcut-server \
84 test-gtk-remove-server \
84 test-gtk-reorder-server \85 test-gtk-reorder-server \
85 test-gtk-submenu-server \86 test-gtk-submenu-server \
86 test-gtk-submenu-client \87 test-gtk-submenu-client \
@@ -92,6 +93,22 @@
92# for the GI tests, prefer/use the typelibs from the local build tree93# for the GI tests, prefer/use the typelibs from the local build tree
93TESTS_ENVIRONMENT = env GI_TYPELIB_PATH=$(top_builddir)/libdbusmenu-glib:$(top_builddir)/libdbusmenu-gtk:$(GI_TYPELIB_PATH)94TESTS_ENVIRONMENT = env GI_TYPELIB_PATH=$(top_builddir)/libdbusmenu-glib:$(top_builddir)/libdbusmenu-gtk:$(GI_TYPELIB_PATH)
9495
96############################################
97# Shared vars for the dbusmenu-glib tests
98############################################
99
100DBUSMENU_GLIB_TEST_CFLAGS = \
101 -Wall -Werror \
102 -DG_DISABLE_DEPRECATED \
103 -I$(top_srcdir) \
104 $(DBUSMENUTESTS_CFLAGS) \
105 $(DBUSMENUGLIB_CFLAGS)
106
107DBUSMENU_GLIB_TEST_LDADD = \
108 $(top_builddir)/libdbusmenu-glib/libdbusmenu-glib.la \
109 $(DBUSMENUGLIB_LIBS) \
110 $(DBUSMENUTESTS_LIBS)
111
95######################112######################
96# JSON Loader lib113# JSON Loader lib
97######################114######################
@@ -113,18 +130,11 @@
113 -export-symbols-regex "^[^_].*"130 -export-symbols-regex "^[^_].*"
114131
115libdbusmenu_jsonloader_la_CFLAGS = \132libdbusmenu_jsonloader_la_CFLAGS = \
116 $(DBUSMENUGLIB_CFLAGS) \133 $(DBUSMENU_GLIB_TEST_CFLAGS) \
117 $(DBUSMENUTESTS_CFLAGS) \
118 -I $(srcdir)/.. \
119 -Wall \
120 -Werror \
121 -DG_DISABLE_DEPRECATED \
122 -DG_LOG_DOMAIN="\"LIBDBUSMENU-JSONLOADER\""134 -DG_LOG_DOMAIN="\"LIBDBUSMENU-JSONLOADER\""
123135
124libdbusmenu_jsonloader_la_LIBADD = \136libdbusmenu_jsonloader_la_LIBADD = \
125 ../libdbusmenu-glib/libdbusmenu-glib.la \137 $(DBUSMENU_GLIB_TEST_LDADD)
126 $(DBUSMENUGLIB_LIBS) \
127 $(DBUSMENUTESTS_LIBS)
128138
129pkgconfig_DATA = dbusmenu-jsonloader-0.4.pc139pkgconfig_DATA = dbusmenu-jsonloader-0.4.pc
130pkgconfigdir = $(libdir)/pkgconfig140pkgconfigdir = $(libdir)/pkgconfig
@@ -133,16 +143,9 @@
133# Test GLib server143# Test GLib server
134######################144######################
135145
136glib_server_nomenu_SOURCES = \146glib_server_nomenu_SOURCES = glib-server-nomenu.c
137 glib-server-nomenu.c147glib_server_nomenu_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
138148glib_server_nomenu_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
139glib_server_nomenu_CFLAGS = \
140 -I $(srcdir)/.. \
141 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
142
143glib_server_nomenu_LDADD = \
144 ../libdbusmenu-glib/libdbusmenu-glib.la \
145 $(DBUSMENUGLIB_LIBS)
146149
147######################150######################
148# Test Glib Layout151# Test Glib Layout
@@ -155,29 +158,13 @@
155 @echo $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@158 @echo $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@
156 @chmod +x $@159 @chmod +x $@
157160
158test_glib_layout_server_SOURCES = \161test_glib_layout_server_SOURCES = test-glib-layout.h test-glib-layout-server.c
159 test-glib-layout.h \162test_glib_layout_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
160 test-glib-layout-server.c163test_glib_layout_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
161164
162test_glib_layout_server_CFLAGS = \165test_glib_layout_client_SOURCES = test-glib-layout.h test-glib-layout-client.c
163 -I $(srcdir)/.. \166test_glib_layout_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
164 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror167test_glib_layout_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
165
166test_glib_layout_server_LDADD = \
167 ../libdbusmenu-glib/libdbusmenu-glib.la \
168 $(DBUSMENUGLIB_LIBS)
169
170test_glib_layout_client_SOURCES = \
171 test-glib-layout.h \
172 test-glib-layout-client.c
173
174test_glib_layout_client_CFLAGS = \
175 -I $(srcdir)/.. \
176 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
177
178test_glib_layout_client_LDADD = \
179 ../libdbusmenu-glib/libdbusmenu-glib.la \
180 $(DBUSMENUGLIB_LIBS)
181168
182######################169######################
183# Test Glib Events170# Test Glib Events
@@ -190,27 +177,13 @@
190 @echo $(DBUS_RUNNER) --task ./test-glib-events-client --task-name Client --task ./test-glib-events-server --task-name Server --ignore-return >> $@177 @echo $(DBUS_RUNNER) --task ./test-glib-events-client --task-name Client --task ./test-glib-events-server --task-name Server --ignore-return >> $@
191 @chmod +x $@178 @chmod +x $@
192179
193test_glib_events_server_SOURCES = \180test_glib_events_server_SOURCES = test-glib-events-server.c
194 test-glib-events-server.c181test_glib_events_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
195182test_glib_events_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
196test_glib_events_server_CFLAGS = \183
197 -I $(srcdir)/.. \184test_glib_events_client_SOURCES = test-glib-events-client.c
198 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror185test_glib_events_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
199186test_glib_events_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
200test_glib_events_server_LDADD = \
201 ../libdbusmenu-glib/libdbusmenu-glib.la \
202 $(DBUSMENUGLIB_LIBS)
203
204test_glib_events_client_SOURCES = \
205 test-glib-events-client.c
206
207test_glib_events_client_CFLAGS = \
208 -I $(srcdir)/.. \
209 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
210
211test_glib_events_client_LDADD = \
212 ../libdbusmenu-glib/libdbusmenu-glib.la \
213 $(DBUSMENUGLIB_LIBS)
214187
215################################188################################
216# Test Glib Events No Grouping189# Test Glib Events No Grouping
@@ -223,16 +196,9 @@
223 @echo $(DBUS_RUNNER) --task ./test-glib-events-nogroup-client --task-name Client --task ./test-glib-events-server --task-name Server --ignore-return >> $@196 @echo $(DBUS_RUNNER) --task ./test-glib-events-nogroup-client --task-name Client --task ./test-glib-events-server --task-name Server --ignore-return >> $@
224 @chmod +x $@197 @chmod +x $@
225198
226test_glib_events_nogroup_client_SOURCES = \199test_glib_events_nogroup_client_SOURCES = test-glib-events-nogroup-client.c
227 test-glib-events-nogroup-client.c200test_glib_events_nogroup_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
228201test_glib_events_nogroup_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
229test_glib_events_nogroup_client_CFLAGS = \
230 -I $(srcdir)/.. \
231 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
232
233test_glib_events_nogroup_client_LDADD = \
234 ../libdbusmenu-glib/libdbusmenu-glib.la \
235 $(DBUSMENUGLIB_LIBS)
236202
237######################203######################
238# Test JSON204# Test JSON
@@ -253,30 +219,17 @@
253 test-json-server.c219 test-json-server.c
254220
255test_json_server_CFLAGS = \221test_json_server_CFLAGS = \
256 -I $(srcdir)/.. \222 $(DBUSMENU_GLIB_TEST_CFLAGS) \
257 -I $(srcdir) \223 -I$(srcdir) \
258 $(DBUSMENUGLIB_CFLAGS) \224 $(DBUSMENUTESTSVALGRIND_CFLAGS)
259 $(DBUSMENUTESTS_CFLAGS) \
260 $(DBUSMENUTESTSVALGRIND_CFLAGS) \
261 -Wall -Werror
262225
263test_json_server_LDADD = \226test_json_server_LDADD = \
264 ../libdbusmenu-glib/libdbusmenu-glib.la \
265 libdbusmenu-jsonloader.la \227 libdbusmenu-jsonloader.la \
266 $(DBUSMENUTESTS_LIBS) \228 $(DBUSMENU_GLIB_TEST_LDADD)
267 $(DBUSMENUGLIB_LIBS)229
268230test_json_client_SOURCES = test-json-client.c
269test_json_client_SOURCES = \231test_json_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
270 test-json-client.c232test_json_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
271
272test_json_client_CFLAGS = \
273 -I $(srcdir)/.. \
274 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
275
276test_json_client_LDADD = \
277 ../libdbusmenu-glib/libdbusmenu-glib.la \
278 $(DBUSMENUTESTS_LIBS) \
279 $(DBUSMENUGLIB_LIBS)
280233
281#########################234#########################
282# Test JSON Instructions235# Test JSON Instructions
@@ -308,29 +261,13 @@
308 @echo $(DBUS_RUNNER) --task ./test-glib-submenu-client --task-name Client --task ./test-glib-submenu-server --task-name Server --ignore-return >> $@261 @echo $(DBUS_RUNNER) --task ./test-glib-submenu-client --task-name Client --task ./test-glib-submenu-server --task-name Server --ignore-return >> $@
309 @chmod +x $@262 @chmod +x $@
310263
311test_glib_submenu_server_SOURCES = \264test_glib_submenu_server_SOURCES = test-glib-submenu.h test-glib-submenu-server.c
312 test-glib-submenu.h \265test_glib_submenu_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
313 test-glib-submenu-server.c266test_glib_submenu_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
314267
315test_glib_submenu_server_CFLAGS = \268test_glib_submenu_client_SOURCES = test-glib-submenu.h test-glib-submenu-client.c
316 -I $(srcdir)/.. \269test_glib_submenu_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
317 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror270test_glib_submenu_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
318
319test_glib_submenu_server_LDADD = \
320 ../libdbusmenu-glib/libdbusmenu-glib.la \
321 $(DBUSMENUGLIB_LIBS)
322
323test_glib_submenu_client_SOURCES = \
324 test-glib-submenu.h \
325 test-glib-submenu-client.c
326
327test_glib_submenu_client_CFLAGS = \
328 -I $(srcdir)/.. \
329 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
330
331test_glib_submenu_client_LDADD = \
332 ../libdbusmenu-glib/libdbusmenu-glib.la \
333 $(DBUSMENUGLIB_LIBS)
334271
335######################272######################
336# Test Glib Object273# Test Glib Object
@@ -345,16 +282,9 @@
345 @echo $(DBUS_RUNNER) --task gtester --task-name test --parameter --verbose --parameter -k --parameter -o --parameter $(OBJECT_XML_REPORT) --parameter ./test-glib-objects >> $@282 @echo $(DBUS_RUNNER) --task gtester --task-name test --parameter --verbose --parameter -k --parameter -o --parameter $(OBJECT_XML_REPORT) --parameter ./test-glib-objects >> $@
346 @chmod +x $@283 @chmod +x $@
347284
348test_glib_objects_SOURCES = \285test_glib_objects_SOURCES = test-glib-objects.c
349 test-glib-objects.c286test_glib_objects_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
350287test_glib_objects_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
351test_glib_objects_CFLAGS = \
352 -I $(srcdir)/.. \
353 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
354
355test_glib_objects_LDADD = \
356 ../libdbusmenu-glib/libdbusmenu-glib.la \
357 $(DBUSMENUGLIB_LIBS)
358288
359DISTCLEANFILES += $(OBJECT_XML_REPORT)289DISTCLEANFILES += $(OBJECT_XML_REPORT)
360290
@@ -369,29 +299,13 @@
369 @echo $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> $@299 @echo $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> $@
370 @chmod +x $@300 @chmod +x $@
371301
372test_glib_properties_server_SOURCES = \302test_glib_properties_server_SOURCES = test-glib-properties.h test-glib-properties-server.c
373 test-glib-properties.h \303test_glib_properties_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
374 test-glib-properties-server.c304test_glib_properties_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
375305
376test_glib_properties_server_CFLAGS = \306test_glib_properties_client_SOURCES = test-glib-properties.h test-glib-properties-client.c
377 -I $(srcdir)/.. \307test_glib_properties_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
378 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror308test_glib_properties_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
379
380test_glib_properties_server_LDADD = \
381 ../libdbusmenu-glib/libdbusmenu-glib.la \
382 $(DBUSMENUGLIB_LIBS)
383
384test_glib_properties_client_SOURCES = \
385 test-glib-properties.h \
386 test-glib-properties-client.c
387
388test_glib_properties_client_CFLAGS = \
389 -I $(srcdir)/.. \
390 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
391
392test_glib_properties_client_LDADD = \
393 ../libdbusmenu-glib/libdbusmenu-glib.la \
394 $(DBUSMENUGLIB_LIBS)
395309
396######################310######################
397# Test Glib Proxy311# Test Glib Proxy
@@ -409,59 +323,41 @@
409 @echo --task ./test-glib-proxy-proxy --parameter test.proxy.last_proxy --parameter test.proxy.server --task-name Proxy05 --ignore-return >> $@323 @echo --task ./test-glib-proxy-proxy --parameter test.proxy.last_proxy --parameter test.proxy.server --task-name Proxy05 --ignore-return >> $@
410 @chmod +x $@324 @chmod +x $@
411325
412test_glib_proxy_server_SOURCES = \326test_glib_proxy_server_SOURCES = test-glib-proxy.h test-glib-proxy-server.c
413 test-glib-proxy.h \327test_glib_proxy_server_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
414 test-glib-proxy-server.c328test_glib_proxy_server_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
415329
416test_glib_proxy_server_CFLAGS = \330test_glib_proxy_client_SOURCES = test-glib-proxy.h test-glib-proxy-client.c
417 -I $(srcdir)/.. \331test_glib_proxy_client_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
418 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror332test_glib_proxy_client_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
419333
420test_glib_proxy_server_LDADD = \334test_glib_proxy_proxy_SOURCES = test-glib-proxy.h test-glib-proxy-proxy.c
421 ../libdbusmenu-glib/libdbusmenu-glib.la \335test_glib_proxy_proxy_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
422 $(DBUSMENUGLIB_LIBS)336test_glib_proxy_proxy_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
423
424test_glib_proxy_client_SOURCES = \
425 test-glib-proxy.h \
426 test-glib-proxy-client.c
427
428test_glib_proxy_client_CFLAGS = \
429 -I $(srcdir)/.. \
430 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
431
432test_glib_proxy_client_LDADD = \
433 ../libdbusmenu-glib/libdbusmenu-glib.la \
434 $(DBUSMENUGLIB_LIBS)
435
436test_glib_proxy_proxy_SOURCES = \
437 test-glib-proxy.h \
438 test-glib-proxy-proxy.c
439
440test_glib_proxy_proxy_CFLAGS = \
441 -I $(srcdir)/.. \
442 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
443
444test_glib_proxy_proxy_LDADD = \
445 ../libdbusmenu-glib/libdbusmenu-glib.la \
446 $(DBUSMENUGLIB_LIBS)
447337
448#########################338#########################
449# Test Glib Simple Items339# Test Glib Simple Items
450#########################340#########################
451341
452test_glib_simple_items_SOURCES = \342test_glib_simple_items_SOURCES = test-glib-simple-items.c
453 test-glib-simple-items.c343test_glib_simple_items_CFLAGS = $(DBUSMENU_GLIB_TEST_CFLAGS)
454344test_glib_simple_items_LDADD = $(DBUSMENU_GLIB_TEST_LDADD)
455test_glib_simple_items_CFLAGS = \
456 -I $(srcdir)/.. \
457 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
458
459test_glib_simple_items_LDADD = \
460 ../libdbusmenu-glib/libdbusmenu-glib.la \
461 $(DBUSMENUGLIB_LIBS)
462345
463EXTRA_DIST += test-glib-simple-items.py346EXTRA_DIST += test-glib-simple-items.py
464347
348############################################
349# Shared vars for the dbusmenu-gtk tests
350############################################
351
352DBUSMENU_GTK_TEST_CFLAGS = \
353 $(DBUSMENUGTK_CFLAGS) \
354 $(DBUSMENU_GLIB_TEST_CFLAGS)
355
356DBUSMENU_GTK_TEST_LDADD = \
357 $(top_builddir)/libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
358 $(DBUSMENUGTK_LIBS) \
359 $(DBUSMENU_GLIB_TEST_LDADD)
360
465######################361######################
466# Test GTK Object362# Test GTK Object
467######################363######################
@@ -476,21 +372,9 @@
476 @echo $(DBUS_RUNNER) --task gtester --task-name test --parameter --verbose --parameter -k --parameter -o --parameter $(GTK_OBJECT_XML_REPORT) --parameter ./test-gtk-objects >> $@372 @echo $(DBUS_RUNNER) --task gtester --task-name test --parameter --verbose --parameter -k --parameter -o --parameter $(GTK_OBJECT_XML_REPORT) --parameter ./test-gtk-objects >> $@
477 @chmod +x $@373 @chmod +x $@
478374
479test_gtk_objects_SOURCES = \375test_gtk_objects_SOURCES = test-gtk-objects.c
480 test-gtk-objects.c376test_gtk_objects_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS) -DSRCDIR="\"$(srcdir)\""
481377test_gtk_objects_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
482test_gtk_objects_CFLAGS = \
483 -I $(srcdir)/.. \
484 $(DBUSMENUGLIB_CFLAGS) \
485 $(DBUSMENUGTK_CFLAGS) \
486 -DSRCDIR="\"$(srcdir)\"" \
487 -Wall -Werror
488
489test_gtk_objects_LDADD = \
490 ../libdbusmenu-glib/libdbusmenu-glib.la \
491 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
492 $(DBUSMENUGLIB_LIBS) \
493 $(DBUSMENUGTK_LIBS)
494378
495DISTCLEANFILES += $(GTK_OBJECT_XML_REPORT)379DISTCLEANFILES += $(GTK_OBJECT_XML_REPORT)
496380
@@ -508,21 +392,9 @@
508 @echo gtester --verbose -k -o $(GTK_PARSER_XML_REPORT) ./test-gtk-parser >> $@392 @echo gtester --verbose -k -o $(GTK_PARSER_XML_REPORT) ./test-gtk-parser >> $@
509 @chmod +x $@393 @chmod +x $@
510394
511test_gtk_parser_SOURCES = \395test_gtk_parser_SOURCES = test-gtk-parser.c
512 test-gtk-parser.c396test_gtk_parser_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS) -DSRCDIR="\"$(srcdir)\""
513397test_gtk_parser_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
514test_gtk_parser_CFLAGS = \
515 -I $(srcdir)/.. \
516 $(DBUSMENUGLIB_CFLAGS) \
517 $(DBUSMENUGTK_CFLAGS) \
518 -DSRCDIR="\"$(srcdir)\"" \
519 -Wall -Werror
520
521test_gtk_parser_LDADD = \
522 ../libdbusmenu-glib/libdbusmenu-glib.la \
523 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
524 $(DBUSMENUGLIB_LIBS) \
525 $(DBUSMENUGTK_LIBS)
526398
527DISTCLEANFILES += $(GTK_PARSER_XML_REPORT)399DISTCLEANFILES += $(GTK_PARSER_XML_REPORT)
528400
@@ -538,36 +410,13 @@
538 @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 >> $@410 @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 >> $@
539 @chmod +x $@411 @chmod +x $@
540412
541test_gtk_label_server_SOURCES = \413test_gtk_label_server_SOURCES = test-gtk-label-server.c
542 test-gtk-label-server.c414test_gtk_label_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
543415test_gtk_label_server_LDADD = libdbusmenu-jsonloader.la $(DBUSMENU_GTK_TEST_LDADD)
544test_gtk_label_server_CFLAGS = \416
545 -I $(srcdir)/.. \417test_gtk_label_client_SOURCES = test-gtk-label-client.c
546 $(DBUSMENUGTK_CFLAGS) \418test_gtk_label_client_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
547 $(DBUSMENUTESTS_CFLAGS) \419test_gtk_label_client_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
548 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
549
550test_gtk_label_server_LDADD = \
551 ../libdbusmenu-glib/libdbusmenu-glib.la \
552 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
553 libdbusmenu-jsonloader.la \
554 $(DBUSMENUGTK_LIBS) \
555 $(DBUSMENUTESTS_LIBS)
556
557test_gtk_label_client_SOURCES = \
558 test-gtk-label-client.c
559
560test_gtk_label_client_CFLAGS = \
561 -I $(srcdir)/.. \
562 $(DBUSMENUGTK_CFLAGS) \
563 $(DBUSMENUTESTS_CFLAGS) \
564 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
565
566test_gtk_label_client_LDADD = \
567 ../libdbusmenu-glib/libdbusmenu-glib.la \
568 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
569 $(DBUSMENUGTK_LIBS) \
570 $(DBUSMENUTESTS_LIBS)
571420
572#########################421#########################
573# Test GTK Shortcut422# Test GTK Shortcut
@@ -581,35 +430,13 @@
581 @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@430 @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@
582 @chmod +x $@431 @chmod +x $@
583432
584test_gtk_shortcut_server_SOURCES = \433test_gtk_shortcut_server_SOURCES = test-gtk-shortcut-server.c
585 test-gtk-shortcut-server.c434test_gtk_shortcut_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
586435test_gtk_shortcut_server_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
587test_gtk_shortcut_server_CFLAGS = \436
588 -I $(srcdir)/.. \437test_gtk_shortcut_client_SOURCES = test-gtk-shortcut-client.c
589 $(DBUSMENUGTK_CFLAGS) \438test_gtk_shortcut_client_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
590 $(DBUSMENUTESTS_CFLAGS) \439test_gtk_shortcut_client_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
591 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
592
593test_gtk_shortcut_server_LDADD = \
594 ../libdbusmenu-glib/libdbusmenu-glib.la \
595 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
596 $(DBUSMENUGTK_LIBS) \
597 $(DBUSMENUTESTS_LIBS)
598
599test_gtk_shortcut_client_SOURCES = \
600 test-gtk-shortcut-client.c
601
602test_gtk_shortcut_client_CFLAGS = \
603 -I $(srcdir)/.. \
604 $(DBUSMENUGTK_CFLAGS) \
605 $(DBUSMENUTESTS_CFLAGS) \
606 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
607
608test_gtk_shortcut_client_LDADD = \
609 ../libdbusmenu-glib/libdbusmenu-glib.la \
610 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
611 $(DBUSMENUGTK_LIBS) \
612 $(DBUSMENUTESTS_LIBS)
613440
614#########################441#########################
615# Test GTK Shortcut Python442# Test GTK Shortcut Python
@@ -627,6 +454,22 @@
627CLEANFILES += test-gtk-shortcut-client.pyc454CLEANFILES += test-gtk-shortcut-client.pyc
628455
629#########################456#########################
457# Test GTK Remove
458#########################
459
460test-gtk-remove: test-gtk-remove-server Makefile.am
461 @echo "#!/bin/bash" > $@
462 @echo export UBUNTU_MENUPROXY="" >> $@
463 @echo export G_DEBUG=fatal_criticals >> $@
464 @echo $(XVFB_RUN) >> $@
465 @echo $(DBUS_RUNNER) --task ./test-gtk-remove-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@
466 @chmod +x $@
467
468test_gtk_remove_server_SOURCES = test-gtk-remove-server.c
469test_gtk_remove_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
470test_gtk_remove_server_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
471
472#########################
630# Test GTK Reorder473# Test GTK Reorder
631#########################474#########################
632475
@@ -638,20 +481,9 @@
638 @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 >> $@481 @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 >> $@
639 @chmod +x $@482 @chmod +x $@
640483
641test_gtk_reorder_server_SOURCES = \484test_gtk_reorder_server_SOURCES = test-gtk-reorder-server.c
642 test-gtk-reorder-server.c485test_gtk_reorder_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
643486test_gtk_reorder_server_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
644test_gtk_reorder_server_CFLAGS = \
645 -I $(srcdir)/.. \
646 $(DBUSMENUGTK_CFLAGS) \
647 $(DBUSMENUTESTS_CFLAGS) \
648 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
649
650test_gtk_reorder_server_LDADD = \
651 ../libdbusmenu-glib/libdbusmenu-glib.la \
652 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
653 $(DBUSMENUGTK_LIBS) \
654 $(DBUSMENUTESTS_LIBS)
655487
656#########################488#########################
657# Test GTK Submenu489# Test GTK Submenu
@@ -665,35 +497,13 @@
665 @echo $(DBUS_RUNNER) --task ./test-gtk-submenu-client --task-name Client --task ./test-gtk-submenu-server --task-name Server --ignore-return >> $@497 @echo $(DBUS_RUNNER) --task ./test-gtk-submenu-client --task-name Client --task ./test-gtk-submenu-server --task-name Server --ignore-return >> $@
666 @chmod +x $@498 @chmod +x $@
667499
668test_gtk_submenu_server_SOURCES = \500test_gtk_submenu_server_SOURCES = test-gtk-submenu-server.c
669 test-gtk-submenu-server.c501test_gtk_submenu_server_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
670502test_gtk_submenu_server_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
671test_gtk_submenu_server_CFLAGS = \503
672 -I $(srcdir)/.. \504test_gtk_submenu_client_SOURCES = test-gtk-submenu-client.c
673 $(DBUSMENUGTK_CFLAGS) \505test_gtk_submenu_client_CFLAGS = $(DBUSMENU_GTK_TEST_CFLAGS)
674 $(DBUSMENUTESTS_CFLAGS) \506test_gtk_submenu_client_LDADD = $(DBUSMENU_GTK_TEST_LDADD)
675 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
676
677test_gtk_submenu_server_LDADD = \
678 ../libdbusmenu-glib/libdbusmenu-glib.la \
679 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
680 $(DBUSMENUGTK_LIBS) \
681 $(DBUSMENUTESTS_LIBS)
682
683test_gtk_submenu_client_SOURCES = \
684 test-gtk-submenu-client.c
685
686test_gtk_submenu_client_CFLAGS = \
687 -I $(srcdir)/.. \
688 $(DBUSMENUGTK_CFLAGS) \
689 $(DBUSMENUTESTS_CFLAGS) \
690 $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
691
692test_gtk_submenu_client_LDADD = \
693 ../libdbusmenu-glib/libdbusmenu-glib.la \
694 ../libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \
695 $(DBUSMENUGTK_LIBS) \
696 $(DBUSMENUTESTS_LIBS)
697507
698#########################508#########################
699# Test Mago509# Test Mago
700510
=== modified file 'tests/test-glib-simple-items.c'
--- tests/test-glib-simple-items.c 2013-01-21 16:04:47 +0000
+++ tests/test-glib-simple-items.c 2013-06-20 15:18:46 +0000
@@ -25,7 +25,7 @@
25static gboolean25static gboolean
26quititall (gpointer data)26quititall (gpointer data)
27{27{
28 g_main_quit(mainloop);28 g_main_loop_quit(mainloop);
29 return FALSE;29 return FALSE;
30}30}
3131
3232
=== added file 'tests/test-gtk-remove-server.c'
--- tests/test-gtk-remove-server.c 1970-01-01 00:00:00 +0000
+++ tests/test-gtk-remove-server.c 2013-06-20 15:18:46 +0000
@@ -0,0 +1,118 @@
1/*
2 Confirm that no warnings/criticals get generated by including
3 multiple add/removes in a match w/o waiting on the mainloop to iterate.
4
5 Copyright 2013 Canonical Ltd.
6
7 Original sample code by Drew Bliss <drewb@valvesoftware.com>
8 Modified for automatic testing by Charles Kerr <charles.kerr@canonical.com>
9 */
10
11#include <stdlib.h> /* exit() */
12#include <gtk/gtk.h>
13#include <libdbusmenu-glib/server.h>
14#include <libdbusmenu-gtk/menu.h>
15#include <libdbusmenu-gtk/parser.h>
16
17static GMainLoop * loop = NULL;
18static GtkWidget * top_gtk = NULL;
19static DbusmenuMenuitem * top_dbusmenu = NULL;
20static DbusmenuServer * menuservice = NULL;
21
22static void
23rebuild_menu (void)
24{
25 GList * l;
26 GList * children;
27 int i;
28 const int n = 10;
29 static int count = 0;
30
31 if (top_gtk == NULL)
32 {
33 top_gtk = gtk_menu_new ();
34 gtk_widget_show (top_gtk);
35 top_dbusmenu = dbusmenu_gtk_parse_menu_structure (top_gtk);
36 menuservice = dbusmenu_server_new ("/org/ayatana/NotificationItem/test/Menu");
37 dbusmenu_server_set_root (menuservice, top_dbusmenu);
38 }
39
40 // remove all the previous children
41 children = gtk_container_get_children (GTK_CONTAINER(top_gtk));
42 for (l=children; l!=NULL; l=l->next)
43 gtk_widget_destroy (GTK_WIDGET (l->data));
44
45 // add a handful of new children
46 for (i=0; i<n; ++i)
47 {
48 char buf[80];
49 GtkWidget * child;
50
51 g_snprintf (buf, sizeof(buf), "Test item %d", ++count);
52 child = gtk_menu_item_new_with_label (buf);
53 gtk_menu_shell_append (GTK_MENU_SHELL(top_gtk), child);
54 gtk_widget_show (child);
55 }
56}
57
58/*
59 * Periodically rebuild the menu.
60 *
61 * After we've looped a couple of times with only one rebuild,
62 * attempt to reproduce the bug Drew reported by rebuilding multiple
63 * times before returning control to the main loop.
64 *
65 * If we survive doing this a handful of times without encountering
66 * a g_warning or g_critical, pass the test.
67 */
68static gint
69on_timer (gpointer unused G_GNUC_UNUSED)
70{
71 static int iteration = 0;
72
73 ++iteration;
74
75 if (iteration > 5)
76 {
77 g_main_loop_quit (loop);
78 return G_SOURCE_REMOVE;
79 }
80
81 if (iteration <= 2)
82 {
83 rebuild_menu ();
84 }
85 else
86 {
87 int i;
88
89 for (i=0; i<iteration; ++i)
90 rebuild_menu ();
91 }
92
93 return G_SOURCE_CONTINUE;
94}
95
96static void
97warning_counter (const gchar * log_domain,
98 GLogLevelFlags log_level G_GNUC_UNUSED,
99 const gchar * message,
100 gpointer user_data G_GNUC_UNUSED)
101{
102 g_message ("Failing the test due to warning: %s %s", log_domain, message);
103 exit (EXIT_FAILURE);
104}
105
106int
107main (int argc, char ** argv)
108{
109 g_log_set_handler ("LIBDBUSMENU-GLIB", G_LOG_LEVEL_WARNING|G_LOG_LEVEL_CRITICAL, warning_counter, NULL);
110
111
112 gtk_init (&argc, &argv);
113 loop = g_main_loop_new (NULL, FALSE);
114 g_timeout_add (200, on_timer, NULL);
115 g_main_loop_run (loop);
116
117 return 0;
118}
0119
=== modified file 'tests/test-gtk-reorder-server.c'
--- tests/test-gtk-reorder-server.c 2013-01-21 16:04:47 +0000
+++ tests/test-gtk-reorder-server.c 2013-06-20 15:18:46 +0000
@@ -52,7 +52,7 @@
52timer_func (gpointer data)52timer_func (gpointer data)
53{53{
54 if (test == NUMBER_TESTS) {54 if (test == NUMBER_TESTS) {
55 g_main_quit(mainloop);55 g_main_loop_quit(mainloop);
56 return FALSE;56 return FALSE;
57 }57 }
5858

Subscribers

People subscribed via source and target branches

to all changes: