EDataBookFactory: Work around a GDBus name watching bug.
authorMatthew Barnes <mbarnes@redhat.com>
Thu, 15 Aug 2013 20:14:56 +0000 (16:14 -0400)
committerMatthew Barnes <mbarnes@redhat.com>
Thu, 15 Aug 2013 21:04:55 +0000 (17:04 -0400)
Calling g_bus_unwatch_name() from a GBusNameVanished callback will
corrupt the function arguments.  Work around this GDBus bug [1] by
unwatching the bus name last in the callback.

[1] https://bugzilla.gnome.org/706088

addressbook/libedata-book/e-data-book-factory.c

index 1e1b2ec..19a32d5 100644 (file)
@@ -175,12 +175,20 @@ data_book_factory_name_vanished_cb (GDBusConnection *connection,
        factory = g_weak_ref_get (weak_ref);
 
        if (factory != NULL) {
+               data_book_factory_connections_remove (factory, name, NULL);
+
+               /* Unwatching the bus name from here will corrupt the
+                * 'name' argument, and possibly also the 'user_data'.
+                *
+                * This is a GDBus bug.  Work around it by unwatching
+                * the bus name last.
+                *
+                * See: https://bugzilla.gnome.org/706088
+                */
                g_mutex_lock (&factory->priv->watched_names_lock);
                g_hash_table_remove (factory->priv->watched_names, name);
                g_mutex_unlock (&factory->priv->watched_names_lock);
 
-               data_book_factory_connections_remove (factory, name, NULL);
-
                g_object_unref (factory);
        }
 }