mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
GApplication: fix name unregister logic
We were attempting to unregister our ownership of our D-Bus name even in the case that we were non-unique (ie: we didn't actually own the name). Rework the logic a bit to prevent that: for non-unique, we leave impl->bus_name as NULL and we only register/unregister if it is non-NULL.
This commit is contained in:
parent
5c3e862776
commit
a5caa564b7
@ -218,7 +218,6 @@ application_path_from_appid (const gchar *appid)
|
|||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
g_application_impl_attempt_primary (GApplicationImpl *impl,
|
g_application_impl_attempt_primary (GApplicationImpl *impl,
|
||||||
gboolean non_unique,
|
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -268,7 +267,7 @@ g_application_impl_attempt_primary (GApplicationImpl *impl,
|
|||||||
if (impl->actions_id == 0)
|
if (impl->actions_id == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (non_unique)
|
if (impl->bus_name == NULL)
|
||||||
{
|
{
|
||||||
/* If this is a non-unique application then it is sufficient to
|
/* If this is a non-unique application then it is sufficient to
|
||||||
* have our object paths registered. We can return now.
|
* have our object paths registered. We can return now.
|
||||||
@ -324,7 +323,7 @@ g_application_impl_stop_primary (GApplicationImpl *impl)
|
|||||||
impl->actions_id = 0;
|
impl->actions_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl->primary)
|
if (impl->primary && impl->bus_name)
|
||||||
{
|
{
|
||||||
g_dbus_connection_call (impl->session_bus, "org.freedesktop.DBus",
|
g_dbus_connection_call (impl->session_bus, "org.freedesktop.DBus",
|
||||||
"/org/freedesktop/DBus", "org.freedesktop.DBus",
|
"/org/freedesktop/DBus", "org.freedesktop.DBus",
|
||||||
@ -363,7 +362,10 @@ g_application_impl_register (GApplication *application,
|
|||||||
|
|
||||||
impl->app = application;
|
impl->app = application;
|
||||||
impl->exported_actions = exported_actions;
|
impl->exported_actions = exported_actions;
|
||||||
impl->bus_name = appid;
|
|
||||||
|
/* non-unique applications do not attempt to acquire a bus name */
|
||||||
|
if (~flags & G_APPLICATION_NON_UNIQUE)
|
||||||
|
impl->bus_name = appid;
|
||||||
|
|
||||||
impl->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, NULL);
|
impl->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, NULL);
|
||||||
|
|
||||||
@ -383,11 +385,7 @@ g_application_impl_register (GApplication *application,
|
|||||||
*/
|
*/
|
||||||
if (~flags & G_APPLICATION_IS_LAUNCHER)
|
if (~flags & G_APPLICATION_IS_LAUNCHER)
|
||||||
{
|
{
|
||||||
gboolean non_unique;
|
if (!g_application_impl_attempt_primary (impl, cancellable, error))
|
||||||
|
|
||||||
non_unique = (flags & G_APPLICATION_NON_UNIQUE) != 0;
|
|
||||||
|
|
||||||
if (!g_application_impl_attempt_primary (impl, non_unique, cancellable, error))
|
|
||||||
{
|
{
|
||||||
g_application_impl_destroy (impl);
|
g_application_impl_destroy (impl);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user