Merge lp:~bratsche/indicator-me/disconnect-some-signals into lp:indicator-me

Proposed by Cody Russell
Status: Merged
Approved by: David Barth
Approved revision: 110
Merged at revision: 108
Proposed branch: lp:~bratsche/indicator-me/disconnect-some-signals
Merge into: lp:indicator-me
Diff against target: 87 lines (+37/-2)
1 file modified
src/indicator-me.c (+37/-2)
To merge this branch: bzr merge lp:~bratsche/indicator-me/disconnect-some-signals
Reviewer Review Type Date Requested Status
David Barth Approve
Review via email: mp+36249@code.launchpad.net
To post a comment you must log in.
109. By Cody Russell

Don't unref the widget, destroy it. But also disconnect stuff first.

110. By Cody Russell

Remove some output.

Revision history for this message
David Barth (dbarth) wrote :

Awesome, I've tested it a bit and it does survive several service restarts and doesn't crash when trying to interact with the entry. So obvious, now that I see the change. Thanks for the fix!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-me.c'
2--- src/indicator-me.c 2010-09-16 14:49:20 +0000
3+++ src/indicator-me.c 2010-09-22 04:29:39 +0000
4@@ -90,6 +90,8 @@
5 static gboolean new_entry_item (DbusmenuMenuitem * newitem,
6 DbusmenuMenuitem * parent,
7 DbusmenuClient * client);
8+static void entry_activate_cb (GtkEntry *entry, DbusmenuMenuitem *mi);
9+static void entry_prop_change_cb (DbusmenuMenuitem *mi, gchar *prop, GValue *value, GtkEntry *entry);
10
11 G_DEFINE_TYPE (IndicatorMe, indicator_me, INDICATOR_OBJECT_TYPE);
12
13@@ -205,6 +207,19 @@
14 }
15
16 static void
17+item_destroyed_cb (GtkObject *item,
18+ gpointer user_data)
19+{
20+ g_signal_handlers_disconnect_by_func (user_data,
21+ G_CALLBACK (entry_activate_cb),
22+ item);
23+
24+ g_signal_handlers_disconnect_by_func (user_data,
25+ G_CALLBACK (entry_prop_change_cb),
26+ item);
27+}
28+
29+static void
30 connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata)
31 {
32 if (connected) {
33@@ -238,6 +253,17 @@
34 /* query the service for the username to display */
35 org_ayatana_indicator_me_service_pretty_user_name_async(status_proxy, username_cb, NULL);
36 } else {
37+ DbusmenuMenuitem *mi = g_object_get_data (G_OBJECT (ido_entry),
38+ "dbusmenuitem");
39+
40+ g_signal_handlers_disconnect_by_func (ido_entry,
41+ G_CALLBACK (entry_activate_cb),
42+ mi);
43+
44+ g_signal_handlers_disconnect_by_func (ido_entry,
45+ G_CALLBACK (entry_prop_change_cb),
46+ mi);
47+
48 /* If we're disconnecting, go back to offline */
49 status_icon_cb(NULL, DEFAULT_ICON, NULL, NULL);
50
51@@ -245,7 +271,7 @@
52 status_proxy = NULL;
53
54 if (ido_entry != NULL) {
55- g_object_unref (ido_entry);
56+ gtk_widget_destroy (GTK_WIDGET (ido_entry));
57 ido_entry = NULL;
58 }
59 }
60@@ -394,6 +420,10 @@
61 entry_set_hint (entry, dbusmenu_menuitem_property_get (newitem, DBUSMENU_ENTRY_MENUITEM_PROP_HINT));
62 }
63
64+ g_object_set_data (G_OBJECT (ido),
65+ "dbusmenitem",
66+ newitem);
67+
68 gtk_entry_set_width_chars (entry, 23); /* set some nice aspect ratio for the menu */
69 gtk_entry_set_max_length (entry, 140); /* enforce current gwibber limit */
70
71@@ -424,10 +454,15 @@
72
73 g_signal_connect (entry,
74 "grab-focus", G_CALLBACK (entry_focus_grab_cb),
75- entry);
76+ NULL);
77
78 g_signal_connect (entry,
79 "grab-broken-event", G_CALLBACK (entry_focus_ungrab_cb),
80+ NULL);
81+
82+ g_signal_connect (newitem,
83+ "destroy",
84+ G_CALLBACK (item_destroyed_cb),
85 entry);
86
87 return TRUE;

Subscribers

People subscribed via source and target branches