[evolution] ECalShellView: Disconnect "prepare-for-quit" handler on dispose().



commit 54384b72172d92bb69d136b564a6096978f50695
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Jun 10 16:37:03 2013 -0400

    ECalShellView: Disconnect "prepare-for-quit" handler on dispose().
    
    This is another source of crashes after creating and destroying a second
    shell window.  The signal handler was left connected with the destroyed
    shell window as the closure.

 modules/calendar/e-cal-shell-view-private.c |    8 ++++++++
 modules/calendar/e-cal-shell-view-private.h |    3 +++
 modules/calendar/e-cal-shell-view.c         |    6 +++++-
 3 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 99de61c..8f5ce93 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -734,6 +734,13 @@ e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view)
        if (priv->cal_shell_content != NULL)
                e_cal_shell_content_save_state (priv->cal_shell_content);
 
+       if (priv->prepare_for_quit_handler_id > 0) {
+               g_signal_handler_disconnect (
+                       priv->shell,
+                       priv->prepare_for_quit_handler_id);
+               priv->prepare_for_quit_handler_id = 0;
+       }
+
        if (priv->backend_error_handler_id > 0) {
                g_signal_handler_disconnect (
                        priv->client_cache,
@@ -745,6 +752,7 @@ e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view)
        g_clear_object (&priv->cal_shell_content);
        g_clear_object (&priv->cal_shell_sidebar);
 
+       g_clear_object (&priv->shell);
        g_clear_object (&priv->client_cache);
 
        if (priv->calendar_activity != NULL) {
diff --git a/modules/calendar/e-cal-shell-view-private.h b/modules/calendar/e-cal-shell-view-private.h
index 7931eb3..30962d8 100644
--- a/modules/calendar/e-cal-shell-view-private.h
+++ b/modules/calendar/e-cal-shell-view-private.h
@@ -93,6 +93,9 @@ struct _ECalShellViewPrivate {
        ECalShellContent *cal_shell_content;
        ECalShellSidebar *cal_shell_sidebar;
 
+       EShell *shell;
+       gulong prepare_for_quit_handler_id;
+
        EClientCache *client_cache;
        gulong backend_error_handler_id;
 
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index a6e3475..39f1472 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -101,6 +101,7 @@ cal_shell_view_constructed (GObject *object)
        ECalShellContent *cal_shell_content;
        GtkWidget *container;
        GtkWidget *widget;
+       gulong handler_id;
 
        /* Chain up to parent's constructed() method. */
        G_OBJECT_CLASS (parent_class)->constructed (object);
@@ -126,10 +127,13 @@ cal_shell_view_constructed (GObject *object)
        gtk_container_add (GTK_CONTAINER (container), widget);
        gtk_widget_show (widget);
 
-       g_signal_connect (
+       handler_id = g_signal_connect (
                shell, "prepare-for-quit",
                G_CALLBACK (cal_shell_view_prepare_for_quit_cb),
                cal_shell_view);
+
+       cal_shell_view->priv->shell = g_object_ref (shell);
+       cal_shell_view->priv->prepare_for_quit_handler_id = handler_id;
 }
 
 static void


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