static void
_g_application_platform_init (GApplication *app)
{
- GError *error = NULL;
- guint registration_id;
-
- ensure_bus (app);
-
- registration_id = g_dbus_connection_register_object (app->priv->session_bus,
- app->priv->dbus_path,
- &application_dbus_interface_info,
- &application_dbus_vtable,
- app, NULL,
- &error);
- if (registration_id == 0)
- {
- g_error ("%s", error->message);
- g_error_free (error);
- }
}
static gboolean
{
GVariant *request_result;
guint32 request_status;
+ gboolean result;
+ guint registration_id;
ensure_bus (app);
+
if (app->priv->session_bus == NULL)
return FALSE;
+ registration_id = g_dbus_connection_register_object (app->priv->session_bus,
+ app->priv->dbus_path,
+ &application_dbus_interface_info,
+ &application_dbus_vtable,
+ app,
+ NULL,
+ error);
+ if (registration_id == 0)
+ return FALSE;
+
request_result = g_dbus_connection_call_sync (app->priv->session_bus,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
NULL, 0, -1, NULL, error);
if (request_result == NULL)
- return FALSE;
+ {
+ result = FALSE;
+ goto done;
+ }
if (g_variant_is_of_type (request_result, G_VARIANT_TYPE ("(u)")))
g_variant_get (request_result, "(u)", &request_status);
else
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown error");
- return FALSE;
+ result = FALSE;
+ goto done;
}
- return TRUE;
+ result = TRUE;
+
+done:
+ if (!result)
+ g_dbus_connection_unregister_object (app->priv->session_bus, registration_id);
+
+ return result;
}
static void
on_name_disappeared_quit,
loop,
NULL);
-
- /* We need a timeout here, since we may otherwise end up calling
- * Quit after the application took the name, but before it registered
- * the object.
- */
- g_timeout_add (500, call_quit, NULL);
+ call_quit (NULL);
g_main_loop_run (loop);