104 lines
3.8 KiB
Diff
104 lines
3.8 KiB
Diff
From: Luca Bacci <luca.bacci982@gmail.com>
|
|
Date: Tue, 11 Jul 2023 10:33:08 +0200
|
|
Subject: GtkApplicationImplDBus: Cancel DBus method calls on shutdown
|
|
|
|
We do that for method calls where a non-NULL GAsyncReadyCallback
|
|
is passed.
|
|
|
|
Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/5775
|
|
Bug: https://gitlab.com/inkscape/inkscape/-/issues/4177
|
|
Bug-Debian: https://bugs.debian.org/1051220
|
|
Forwarded: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6180
|
|
Origin: 3.24.39, commit:7ca33ff9941ad8565979eb0873c8bc14e31397d2
|
|
---
|
|
gtk/gtkapplication-dbus.c | 21 +++++++++++++++------
|
|
gtk/gtkapplicationprivate.h | 1 +
|
|
2 files changed, 16 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/gtk/gtkapplication-dbus.c b/gtk/gtkapplication-dbus.c
|
|
index 2c9a1a7..a663aed 100644
|
|
--- a/gtk/gtkapplication-dbus.c
|
|
+++ b/gtk/gtkapplication-dbus.c
|
|
@@ -248,8 +248,10 @@ ss_get_active_cb (GObject *source,
|
|
ret = g_dbus_proxy_call_finish (proxy, result, &error);
|
|
if (ret == NULL)
|
|
{
|
|
- g_warning ("Getting screensaver status failed: %s", error->message);
|
|
- g_error_free (error);
|
|
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
+ g_warning ("Getting screensaver status failed: %s",
|
|
+ error ? error->message : "");
|
|
+ g_clear_error (&error);
|
|
return;
|
|
}
|
|
|
|
@@ -270,8 +272,10 @@ create_monitor_cb (GObject *source,
|
|
ret = g_dbus_proxy_call_finish (proxy, result, &error);
|
|
if (ret == NULL)
|
|
{
|
|
- g_warning ("Creating a portal monitor failed: %s", error->message);
|
|
- g_error_free (error);
|
|
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
+ g_warning ("Creating a portal monitor failed: %s",
|
|
+ error ? error->message : "");
|
|
+ g_clear_error (&error);
|
|
return;
|
|
}
|
|
|
|
@@ -302,6 +306,8 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|
if (gtk_should_use_portal ())
|
|
goto out;
|
|
|
|
+ dbus->cancellable = g_cancellable_new ();
|
|
+
|
|
g_debug ("Connecting to session manager");
|
|
|
|
/* Try the GNOME session manager first */
|
|
@@ -368,7 +374,7 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|
NULL,
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
G_MAXINT,
|
|
- NULL,
|
|
+ dbus->cancellable,
|
|
ss_get_active_cb,
|
|
dbus);
|
|
}
|
|
@@ -515,7 +521,7 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
|
g_variant_new ("(sa{sv})", "", &opt_builder),
|
|
G_DBUS_CALL_FLAGS_NONE,
|
|
G_MAXINT,
|
|
- NULL,
|
|
+ dbus->cancellable,
|
|
create_monitor_cb, dbus);
|
|
g_free (token);
|
|
}
|
|
@@ -527,6 +533,8 @@ end:;
|
|
static void
|
|
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);
|
|
@@ -902,6 +910,7 @@ gtk_application_impl_dbus_finalize (GObject *object)
|
|
if (dbus->ss_proxy)
|
|
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->cancellable);
|
|
|
|
G_OBJECT_CLASS (gtk_application_impl_dbus_parent_class)->finalize (object);
|
|
}
|
|
diff --git a/gtk/gtkapplicationprivate.h b/gtk/gtkapplicationprivate.h
|
|
index 01b674a..c76b2e8 100644
|
|
--- a/gtk/gtkapplicationprivate.h
|
|
+++ b/gtk/gtkapplicationprivate.h
|
|
@@ -117,6 +117,7 @@ typedef struct
|
|
GtkApplicationImpl impl;
|
|
|
|
GDBusConnection *session;
|
|
+ GCancellable *cancellable;
|
|
|
|
const gchar *application_id;
|
|
const gchar *unique_name;
|