← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/indicator-application/a-couple-race-fixups into lp:indicator-application

 

Ted Gould has proposed merging lp:~ted/indicator-application/a-couple-race-fixups into lp:indicator-application.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)


A fix for a possible race condition that I think is happening with startup where applications fallback and don't recover.
-- 
https://code.launchpad.net/~ted/indicator-application/a-couple-race-fixups/+merge/39669
Your team ayatana-commits is subscribed to branch lp:indicator-application.
=== modified file 'src/app-indicator.c'
--- src/app-indicator.c	2010-09-21 19:22:16 +0000
+++ src/app-indicator.c	2010-10-29 22:52:47 +0000
@@ -32,6 +32,8 @@
 #endif
 
 #include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+
 #include <libdbusmenu-glib/server.h>
 #include <libdbusmenu-gtk/client.h>
 
@@ -1052,6 +1054,23 @@
 	return;
 }
 
+/* Checking to see if someone already has the name we're looking for */
+static void
+check_owner_cb (DBusGProxy *proxy, gboolean exists, GError *error, gpointer userdata)
+{
+	if (error != NULL) {
+		g_warning("Unable to check for '" NOTIFICATION_WATCHER_DBUS_ADDR "' on DBus.  No worries, but concerning.");
+		return;
+	}
+
+	if (exists) {
+		g_debug("Woah, we actually has a race condition with dbus");
+		dbus_owner_change(proxy, NOTIFICATION_WATCHER_DBUS_ADDR, NULL, "Non NULL", userdata);
+	}
+
+	return;
+}
+
 /* This is an idle function to create the proxy.  This is mostly
    because start_fallback_timer can get called in the distruction
    of a proxy and thus the proxy manager gets confused when creating
@@ -1074,6 +1093,11 @@
 		                        G_TYPE_INVALID);
 		dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged",
 		                            G_CALLBACK(dbus_owner_change), data, NULL);
+
+		/* Check to see if anyone has the name we're looking for
+		   just incase we missed it changing. */
+
+		org_freedesktop_DBus_name_has_owner_async(priv->dbus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, check_owner_cb, data);
 	}
 
 	return FALSE;


Follow ups