Merge lp:~larsu/indicator-appmenu/dont-disconnect-non-existing-signals into lp:indicator-appmenu/14.04

Proposed by Lars Karlitski
Status: Merged
Approved by: Charles Kerr
Approved revision: 247
Merged at revision: 249
Proposed branch: lp:~larsu/indicator-appmenu/dont-disconnect-non-existing-signals
Merge into: lp:indicator-appmenu/14.04
Diff against target: 86 lines (+21/-33)
1 file modified
src/window-menu-model.c (+21/-33)
To merge this branch: bzr merge lp:~larsu/indicator-appmenu/dont-disconnect-non-existing-signals
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+192799@code.launchpad.net

Description of the change

window-menu-model: disconnect entry signal handlers by func instead of id

entry_object_free disconnected signal handlers by id. This throws warnings when entry_object_free is called when disposing an object, because signals are already disconnected at that point.

This patch uses g_signal_handlers_disconnect_by_func(), which works both when the entry is alive and being disposed.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/window-menu-model.c'
2--- src/window-menu-model.c 2013-10-24 12:58:52 +0000
3+++ src/window-menu-model.c 2013-10-27 00:49:24 +0000
4@@ -263,38 +263,8 @@
5 IndicatorObjectEntry entry;
6
7 GtkMenuItem * gmi;
8-
9- gulong label_sig;
10- gulong sensitive_sig;
11- gulong visible_sig;
12 };
13
14-/* Destroy and unref the items of the object entry */
15-static void
16-entry_object_free (gpointer inentry)
17-{
18- WindowMenuEntry * entry = (WindowMenuEntry *)inentry;
19-
20- if (entry->label_sig != 0) {
21- g_signal_handler_disconnect(entry->gmi, entry->label_sig);
22- }
23-
24- if (entry->sensitive_sig != 0) {
25- g_signal_handler_disconnect(entry->gmi, entry->sensitive_sig);
26- }
27-
28- if (entry->visible_sig != 0) {
29- g_signal_handler_disconnect(entry->gmi, entry->visible_sig);
30- }
31-
32- g_clear_object(&entry->entry.label);
33- g_clear_object(&entry->entry.image);
34- g_clear_object(&entry->entry.menu);
35-
36- g_free(entry);
37- return;
38-}
39-
40 /* Sync the menu label changing to the label object */
41 static void
42 entry_label_notify (GObject * obj, GParamSpec * pspec, gpointer user_data)
43@@ -354,6 +324,24 @@
44 return;
45 }
46
47+/* Destroy and unref the items of the object entry */
48+static void
49+entry_object_free (gpointer inentry)
50+{
51+ WindowMenuEntry * entry = (WindowMenuEntry *)inentry;
52+
53+ g_signal_handlers_disconnect_by_func (entry->gmi, entry_label_notify, entry);
54+ g_signal_handlers_disconnect_by_func (entry->gmi, entry_sensitive_notify, entry);
55+ g_signal_handlers_disconnect_by_func (entry->gmi, entry_visible_notify, entry);
56+
57+ g_clear_object(&entry->entry.label);
58+ g_clear_object(&entry->entry.image);
59+ g_clear_object(&entry->entry.menu);
60+
61+ g_free(entry);
62+ return;
63+}
64+
65 /* Put an entry on a menu item */
66 static void
67 entry_on_menuitem (WindowMenuModel * menu, GtkMenuItem * gmi)
68@@ -385,7 +373,7 @@
69
70 entry->entry.label = GTK_LABEL(gtk_label_new(label));
71 gtk_widget_show(GTK_WIDGET(entry->entry.label));
72- entry->label_sig = g_signal_connect(G_OBJECT(gmi), "notify::label", G_CALLBACK(entry_label_notify), entry->entry.label);
73+ g_signal_connect(G_OBJECT(gmi), "notify::label", G_CALLBACK(entry_label_notify), entry);
74 }
75
76 if (entry->entry.label != NULL) {
77@@ -400,8 +388,8 @@
78 g_object_ref_sink(entry->entry.menu);
79 }
80
81- entry->sensitive_sig = g_signal_connect(G_OBJECT(gmi), "notify::sensitive", G_CALLBACK(entry_sensitive_notify), entry);
82- entry->visible_sig = g_signal_connect(G_OBJECT(gmi), "notify::visible", G_CALLBACK(entry_visible_notify), entry);
83+ g_signal_connect(G_OBJECT(gmi), "notify::sensitive", G_CALLBACK(entry_sensitive_notify), entry);
84+ g_signal_connect(G_OBJECT(gmi), "notify::visible", G_CALLBACK(entry_visible_notify), entry);
85
86 g_object_set_data_full(G_OBJECT(gmi), ENTRY_DATA, entry, entry_object_free);
87

Subscribers

People subscribed via source and target branches