← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~mterry/indicator-applet/global-desc-update-callback into lp:indicator-applet

 

Michael Terry has proposed merging lp:~mterry/indicator-applet/global-desc-update-callback into lp:indicator-applet.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)
Related bugs:
  Bug #745115 in indicator-application (Ubuntu): "indicator-applet-complete crashed with SIGSEGV in g_cclosure_marshal_VOID__POINTER()"
  https://bugs.launchpad.net/ubuntu/+source/indicator-application/+bug/745115

For more details, see:
https://code.launchpad.net/~mterry/indicator-applet/global-desc-update-callback/+merge/57533

Every time an indicator-applet adds an entry, it connects to the global IndicatorObject INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE signal with the new entry menuitem as an argument.

But it never cleaned it up, meaning that we could crash after the menuitem goes away and another entry emits the DESC_UPDATE signal.

This branch changes it to just one signal connection and has the applet search for the right entry.  This matches how it handles other global signals.

This might fix linked bug 745115.
-- 
https://code.launchpad.net/~mterry/indicator-applet/global-desc-update-callback/+merge/57533
Your team ayatana-commits is subscribed to branch lp:indicator-applet.
=== modified file 'src/applet-main.c'
--- src/applet-main.c	2011-03-22 20:35:19 +0000
+++ src/applet-main.c	2011-04-13 16:29:30 +0000
@@ -266,10 +266,22 @@
 }
 
 static void
-accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menuitem)
-{
-	g_return_if_fail(GTK_IS_WIDGET(menuitem));
-	update_accessible_desc(entry, menuitem);
+accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != userdata) {
+		return;
+	}
+
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
+	update_accessible_desc(entry, widget);
+}
+
+static void
+accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+{
+	gtk_container_foreach(GTK_CONTAINER(menubar), accessible_desc_update_cb, entry);
 	return;
 }
 
@@ -350,8 +362,6 @@
 
 	gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
 
-	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menuitem);
-
 	if (something_visible) {
 		if (entry->accessible_desc != NULL) {
 			update_accessible_desc(entry, menuitem);
@@ -529,6 +539,7 @@
 	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed),  menubar);
 	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED,   G_CALLBACK(entry_moved),    menubar);
 	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW,     G_CALLBACK(menu_show),      menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar);
 
 	/* Work on the entries */
 	GList * entries = indicator_object_get_entries(io);


Follow ups