guint do_register : 1;
guint default_quit : 1;
guint is_remote : 1;
+ guint registration_tried : 1;
guint actions_changed_id;
if (!_g_application_platform_init (app, cancellable, error))
return FALSE;
- if (app->priv->do_register &&
- !_g_application_platform_register (app, &unique, cancellable ,error))
+ if (app->priv->do_register
+ && !_g_application_platform_register (app, &unique, cancellable ,error))
return FALSE;
return TRUE;
* initialized, but this behavior is controlled by the
* GApplication:register property. If it was given as %FALSE at
* construction time, this function allows you to later attempt
- * to ensure uniqueness.
+ * to ensure uniqueness. Note that the GApplication:default-quit
+ * property no longer applies at this point; if this function returns
+ * %FALSE, platform activation will occur, but the current process
+ * will not be terminated.
+ *
+ * It is an error to call this function more than once. It is
+ * also an error to call this function if the GApplication:register
+ * property was %TRUE at construction time.
*
* Returns: %TRUE if registration was successful
*/
g_return_val_if_fail (G_IS_APPLICATION (application), FALSE);
g_return_val_if_fail (application->priv->is_remote, FALSE);
+ g_return_val_if_fail (!application->priv->registration_tried, FALSE);
if (!_g_application_platform_register (application, &unique, NULL, NULL))
return FALSE;
case PROP_REGISTER:
app->priv->do_register = g_value_get_boolean (value);
+ /* If we're not registering, the default_quit no longer applies */
+ if (!app->priv->do_register)
+ app->priv->default_quit = FALSE;
break;
case PROP_ARGV:
/**
* GApplication:default-quit:
*
- * By default, if a different process is running this application, the
- * process will be exited. Set this property to %FALSE to allow custom
+ * By default, if the GApplication:register property is %TRUE, and a
+ * different process is running this application, the process will
+ * be exited. Set this property to %FALSE to allow custom
* interaction with the remote process.
*
*/
gboolean result;
guint registration_id;
+ /* Callers should have verified this */
+ g_assert (app->priv->registration_tried == FALSE);
+ app->priv->registration_tried = TRUE;
+
registration_id = g_dbus_connection_register_object (app->priv->session_bus,
app->priv->dbus_path,
&application_dbus_interface_info,
{
app->priv->is_remote = FALSE;
}
- else if (app->priv->default_quit)
+ else
{
GVariantBuilder builder;
GVariant *message;
if (result)
g_variant_unref (result);
- exit (0);
+ if (app->priv->default_quit)
+ exit (0);
}
done: