Use app_hash to find app to remove in response to NameOwnerChanged
authorMike Gorse <mgorse@suse.com>
Thu, 11 Sep 2014 19:31:51 +0000 (14:31 -0500)
committerMike Gorse <mgorse@suse.com>
Thu, 11 Sep 2014 19:31:51 +0000 (14:31 -0500)
Previously, we were fetching the desktop, and apparently this may return
NULL if the registry is gone. I'm not sure if this should be happening,
and I have no idea if there may be other NULL pointer dereferences in
that case, but this removes one of them and simplifies the code a bit.

atspi/atspi-misc.c

index 4c35df8..84669a4 100644 (file)
@@ -384,17 +384,11 @@ handle_name_owner_changed (DBusConnection *bus, DBusMessage *message, void *user
     else if (!new[0])
       registry_lost = TRUE;
   }
-  else
+  else if (app_hash)
   {
-    AtspiAccessible *desktop = atspi_get_desktop (0);
-    GList *l;
-    for (l = desktop->children; l; l = l->next)
-    {
-      AtspiAccessible *child = l->data;
-      if (!strcmp (child->parent.app->bus_name, old))
-        g_object_run_dispose (G_OBJECT (child->parent.app));
-    }
-    g_object_unref (desktop);
+    AtspiApplication *app = g_hash_table_lookup (app_hash, old);
+    if (app)
+      g_object_run_dispose (G_OBJECT (app));
   }
   return DBUS_HANDLER_RESULT_HANDLED;
 }