[gnome-software/gnome-3-18] shell details: Disconnect old signal handlers before setting new app



commit e06f23cc9241e5319000c3e3766519a656b70609
Author: Rafal Luzynski <digitalfreak lingonborough com>
Date:   Mon Sep 28 11:52:38 2015 +0200

    shell details: Disconnect old signal handlers before setting new app
    
    While at this, also make sure to connect to notify::progress not only
    when installing from repos, but when installing local rpms as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755664

 src/gs-shell-details.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 477a949..57c79b0 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -911,8 +911,12 @@ gs_shell_details_filename_to_app_cb (GObject *source,
        g_autoptr(GError) error = NULL;
        g_autofree gchar *tmp = NULL;
 
-       if (self->app != NULL)
+       /* save app */
+       if (self->app != NULL) {
+               g_signal_handlers_disconnect_by_func (self->app, gs_shell_details_notify_state_changed_cb, 
self);
+               g_signal_handlers_disconnect_by_func (self->app, gs_shell_details_progress_changed_cb, self);
                g_object_unref (self->app);
+       }
        self->app = gs_plugin_loader_filename_to_app_finish(plugin_loader,
                                                            res,
                                                            &error);
@@ -938,7 +942,6 @@ gs_shell_details_filename_to_app_cb (GObject *source,
                return;
        }
 
-       /* save app */
        g_signal_connect_object (self->app, "notify::state",
                                 G_CALLBACK (gs_shell_details_notify_state_changed_cb),
                                 self, 0);
@@ -948,6 +951,9 @@ gs_shell_details_filename_to_app_cb (GObject *source,
        g_signal_connect_object (self->app, "notify::licence",
                                 G_CALLBACK (gs_shell_details_notify_state_changed_cb),
                                 self, 0);
+       g_signal_connect_object (self->app, "notify::progress",
+                                G_CALLBACK (gs_shell_details_progress_changed_cb),
+                                self, 0);
 
        /* print what we've got */
        tmp = gs_app_to_string (self->app);
@@ -1019,8 +1025,11 @@ gs_shell_details_set_app (GsShellDetails *self, GsApp *app)
        gs_shell_details_set_state (self, GS_SHELL_DETAILS_STATE_LOADING);
 
        /* save app */
-       if (self->app != NULL)
+       if (self->app != NULL) {
+               g_signal_handlers_disconnect_by_func (self->app, gs_shell_details_notify_state_changed_cb, 
self);
+               g_signal_handlers_disconnect_by_func (self->app, gs_shell_details_progress_changed_cb, self);
                g_object_unref (self->app);
+       }
        self->app = g_object_ref (app);
        g_signal_connect_object (self->app, "notify::state",
                                 G_CALLBACK (gs_shell_details_notify_state_changed_cb),
@@ -1271,10 +1280,14 @@ gs_shell_details_dispose (GObject *object)
 {
        GsShellDetails *self = GS_SHELL_DETAILS (object);
 
+       if (self->app != NULL) {
+               g_signal_handlers_disconnect_by_func (self->app, gs_shell_details_notify_state_changed_cb, 
self);
+               g_signal_handlers_disconnect_by_func (self->app, gs_shell_details_progress_changed_cb, self);
+               g_clear_object (&self->app);
+       }
        g_clear_object (&self->builder);
        g_clear_object (&self->plugin_loader);
        g_clear_object (&self->cancellable);
-       g_clear_object (&self->app);
        g_clear_object (&self->session);
 
        G_OBJECT_CLASS (gs_shell_details_parent_class)->dispose (object);


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