[gnome-software] search provider: Don't keep the app running forever



commit feba7e5a79edacbd80dde3561b79fcd61cbd6509
Author: Kalev Lember <klember redhat com>
Date:   Sat Sep 5 16:32:21 2015 +0200

    search provider: Don't keep the app running forever
    
    Only hold the app alive while the actual search is going on and let it
    time out after that.
    
    This shouldn't make any difference in regular use since the background
    monitor is keeping the app alive as well. However, when the background
    monitor is disabled, this lets gnome-software exit after a timeout,
    making it easier to debug memleaks under valgrind.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750634

 src/gs-application.c           |    7 +++++--
 src/gs-shell-search-provider.c |   14 +++-----------
 2 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 86fd225..5e11faa 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -206,7 +206,10 @@ gs_application_dbus_unregister (GApplication    *application,
 {
        GsApplication *app = GS_APPLICATION (application);
 
-       gs_shell_search_provider_unregister (app->search_provider);
+       if (app->search_provider != NULL) {
+               gs_shell_search_provider_unregister (app->search_provider);
+               g_clear_object (&app->search_provider);
+       }
 }
 
 static void
@@ -604,7 +607,6 @@ gs_application_dispose (GObject *object)
        g_clear_object (&app->update_monitor);
        g_clear_object (&app->proxy_settings);
        g_clear_object (&app->profile);
-       g_clear_object (&app->search_provider);
        g_clear_object (&app->network_monitor);
        g_clear_object (&app->dbus_helper);
        g_clear_object (&app->settings);
@@ -738,6 +740,7 @@ gs_application_new (void)
        g_set_prgname("org.gnome.Software");
        return g_object_new (GS_APPLICATION_TYPE,
                             "application-id", "org.gnome.Software",
+                            "inactivity-timeout", 12000,
                             NULL);
 }
 
diff --git a/src/gs-shell-search-provider.c b/src/gs-shell-search-provider.c
index 21c503d..21976c7 100644
--- a/src/gs-shell-search-provider.c
+++ b/src/gs-shell-search-provider.c
@@ -87,6 +87,7 @@ search_done_cb (GObject *source,
        if (list == NULL) {
                g_dbus_method_invocation_return_value (search->invocation, g_variant_new ("(as)", NULL));
                pending_search_free (search);
+               g_application_release (g_application_get_default ());
                return; 
        }
 
@@ -104,6 +105,7 @@ search_done_cb (GObject *source,
 
        g_list_free_full (list, g_object_unref);
        pending_search_free (search);
+       g_application_release (g_application_get_default ());
 }
 
 static void
@@ -132,6 +134,7 @@ execute_search (GsShellSearchProvider  *self,
        pending_search->provider = self;
        pending_search->invocation = g_object_ref (invocation);
 
+       g_application_hold (g_application_get_default ());
        self->cancellable = g_cancellable_new ();
        gs_plugin_loader_search_async (self->plugin_loader,
                                       string, 0, self->cancellable,
@@ -302,14 +305,6 @@ search_provider_dispose (GObject *obj)
 }
 
 static void
-search_provider_finalize (GObject *obj)
-{
-       g_application_release (g_application_get_default ());
-
-       G_OBJECT_CLASS (gs_shell_search_provider_parent_class)->finalize (obj);
-}
-
-static void
 gs_shell_search_provider_init (GsShellSearchProvider *self)
 {
        self->metas_cache = g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -327,8 +322,6 @@ gs_shell_search_provider_init (GsShellSearchProvider *self)
                        G_CALLBACK (handle_activate_result), self);
        g_signal_connect (self->skeleton, "handle-launch-search",
                        G_CALLBACK (handle_launch_search), self);
-
-       g_application_hold (g_application_get_default ());
 }
 
 static void
@@ -337,7 +330,6 @@ gs_shell_search_provider_class_init (GsShellSearchProviderClass *klass)
        GObjectClass *oclass = G_OBJECT_CLASS (klass);
 
        oclass->dispose = search_provider_dispose;
-       oclass->finalize = search_provider_finalize;
 }
 
 GsShellSearchProvider *


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