[gnome-shell/gnome-40] shell/app: Keep cancellable after cancelled proxy request



commit 87a7a4c25c5dc9eb161e4472963ad730fd92fd96
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Dec 13 18:57:44 2020 +0100

    shell/app: Keep cancellable after cancelled proxy request
    
    When a GTK app is started, we create a corresponding GtkApplication
    proxy to monitor the app's busy state. If the app is stopped before
    the proxy request finishes, we cancel the cancellable before clearing
    the running state.
    
    Usually we clear the cancellable once it is no longer needed, namely
    when we got the proxy. However when the request was cancelled, the
    cancellable has already been cleared, and if there's a cancellable,
    it belongs to another request (because the window was added again,
    for example when moving between monitors).
    
    Leave that cancellable alone in that case, so we can cancel the
    second request as well if necessary to avoid a crash when trying
    to set the proxy on a cleared running state.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1962
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1885>
    (cherry picked from commit 3f2db31d7e74f11ed57e9e106971a591521640a1)

 src/shell-app.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 62ba2ec73a..1dfd82d8e4 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -1046,10 +1046,11 @@ get_application_proxy (GObject      *source,
 {
   ShellApp *app = user_data;
   ShellOrgGtkApplication *proxy;
+  g_autoptr (GError) error = NULL;
 
   g_assert (SHELL_IS_APP (app));
 
-  proxy = shell_org_gtk_application_proxy_new_finish (result, NULL);
+  proxy = shell_org_gtk_application_proxy_new_finish (result, &error);
   if (proxy != NULL)
     {
       app->running_state->application_proxy = proxy;
@@ -1061,7 +1062,8 @@ get_application_proxy (GObject      *source,
         g_object_notify (G_OBJECT (app), "busy");
     }
 
-  if (app->running_state != NULL)
+  if (app->running_state != NULL &&
+      !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
     g_clear_object (&app->running_state->cancellable);
 
   g_object_unref (app);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]