[gnome-software: 7/9] application: Cancel and destroy shell in shutdown




commit 3d3105fb88e64b2326f9e7316e674ec493fac6bb
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Aug 18 15:49:09 2022 -0300

    application: Cancel and destroy shell in shutdown
    
    GsApplication currently is never disposed becase GsShell holds a
    reference to it, as all GtkApplicationWindows indirectly do.
    
    Fix that by destroying the GsShell instance in the 'shutdown' vfunc
    of GApplication. This allows GsApplication to be disposed.

 src/gs-application.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 6e919d341..0e5a1a49c 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -179,6 +179,19 @@ gs_application_dbus_unregister (GApplication    *application,
                gs_shell_search_provider_unregister (app->search_provider);
 }
 
+static void
+gs_application_shutdown (GApplication *application)
+{
+       GsApplication *app = GS_APPLICATION (application);
+
+       g_cancellable_cancel (app->cancellable);
+       g_clear_object (&app->cancellable);
+
+       g_clear_object (&app->shell);
+
+       G_APPLICATION_CLASS (gs_application_parent_class)->shutdown (application);
+}
+
 static void
 gs_application_shell_loaded_cb (GsShell *shell, GsApplication *app)
 {
@@ -1166,12 +1179,8 @@ gs_application_dispose (GObject *object)
 {
        GsApplication *app = GS_APPLICATION (object);
 
-       g_cancellable_cancel (app->cancellable);
-       g_clear_object (&app->cancellable);
-
        g_clear_object (&app->search_provider);
        g_clear_object (&app->plugin_loader);
-       g_clear_object (&app->shell);
        g_clear_object (&app->update_monitor);
 #ifdef HAVE_PACKAGEKIT
        g_clear_object (&app->dbus_helper);
@@ -1344,6 +1353,7 @@ gs_application_class_init (GsApplicationClass *klass)
        application_class->open = gs_application_open;
        application_class->dbus_register = gs_application_dbus_register;
        application_class->dbus_unregister = gs_application_dbus_unregister;
+       application_class->shutdown = gs_application_shutdown;
 
        /**
         * GsApplication:debug: (nullable)


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