mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
GtkApplicationImplDBus: Cancel DBus method calls on shutdown
We do that for method calls where we pass a valid GAsyncReadyCallback Fixes #5775
This commit is contained in:
parent
6dd9048c6d
commit
cd5cdad31d
@ -275,8 +275,10 @@ ss_get_active_cb (GObject *source,
|
|||||||
ret = g_dbus_proxy_call_finish (proxy, result, &error);
|
ret = g_dbus_proxy_call_finish (proxy, result, &error);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
{
|
{
|
||||||
g_warning ("Getting screensaver status failed: %s", error->message);
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||||
g_error_free (error);
|
g_warning ("Getting screensaver status failed: %s",
|
||||||
|
error ? error->message : "");
|
||||||
|
g_clear_error (&error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,8 +299,10 @@ create_monitor_cb (GObject *source,
|
|||||||
ret = g_dbus_proxy_call_finish (proxy, result, &error);
|
ret = g_dbus_proxy_call_finish (proxy, result, &error);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
{
|
{
|
||||||
g_warning ("Creating a portal monitor failed: %s", error->message);
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||||
g_error_free (error);
|
g_warning ("Creating a portal monitor failed: %s",
|
||||||
|
error ? error->message : "");
|
||||||
|
g_clear_error (&error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,6 +336,8 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|||||||
if (gdk_should_use_portal ())
|
if (gdk_should_use_portal ())
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
dbus->cancellable = g_cancellable_new ();
|
||||||
|
|
||||||
g_debug ("Connecting to session manager");
|
g_debug ("Connecting to session manager");
|
||||||
|
|
||||||
/* Try the GNOME session manager first */
|
/* Try the GNOME session manager first */
|
||||||
@ -398,7 +404,7 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|||||||
NULL,
|
NULL,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
G_MAXINT,
|
G_MAXINT,
|
||||||
NULL,
|
dbus->cancellable,
|
||||||
ss_get_active_cb,
|
ss_get_active_cb,
|
||||||
dbus);
|
dbus);
|
||||||
}
|
}
|
||||||
@ -545,7 +551,7 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|||||||
g_variant_new ("(sa{sv})", "", &opt_builder),
|
g_variant_new ("(sa{sv})", "", &opt_builder),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
G_MAXINT,
|
G_MAXINT,
|
||||||
NULL,
|
dbus->cancellable,
|
||||||
create_monitor_cb, dbus);
|
create_monitor_cb, dbus);
|
||||||
g_free (token);
|
g_free (token);
|
||||||
}
|
}
|
||||||
@ -555,6 +561,8 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|||||||
static void
|
static void
|
||||||
gtk_application_impl_dbus_shutdown (GtkApplicationImpl *impl)
|
gtk_application_impl_dbus_shutdown (GtkApplicationImpl *impl)
|
||||||
{
|
{
|
||||||
|
GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl;
|
||||||
|
g_cancellable_cancel (dbus->cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
GQuark gtk_application_impl_dbus_export_id_quark (void);
|
GQuark gtk_application_impl_dbus_export_id_quark (void);
|
||||||
@ -898,6 +906,7 @@ gtk_application_impl_dbus_finalize (GObject *object)
|
|||||||
if (dbus->ss_proxy)
|
if (dbus->ss_proxy)
|
||||||
g_signal_handlers_disconnect_by_func (dbus->ss_proxy, screensaver_signal_session, dbus->impl.application);
|
g_signal_handlers_disconnect_by_func (dbus->ss_proxy, screensaver_signal_session, dbus->impl.application);
|
||||||
g_clear_object (&dbus->ss_proxy);
|
g_clear_object (&dbus->ss_proxy);
|
||||||
|
g_clear_object (&dbus->cancellable);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_application_impl_dbus_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gtk_application_impl_dbus_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,7 @@ typedef struct
|
|||||||
GtkApplicationImpl impl;
|
GtkApplicationImpl impl;
|
||||||
|
|
||||||
GDBusConnection *session;
|
GDBusConnection *session;
|
||||||
|
GCancellable *cancellable;
|
||||||
|
|
||||||
const char *application_id;
|
const char *application_id;
|
||||||
const char *unique_name;
|
const char *unique_name;
|
||||||
|
Loading…
Reference in New Issue
Block a user