[evolution] Bug #703153 - Forgotten signal callbacks for freed objects



commit 7a05cf2cf74ceb5c5bb950f42475ab4ff3acba74
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jul 19 17:43:08 2013 +0200

    Bug #703153 - Forgotten signal callbacks for freed objects

 calendar/gui/e-day-view.c              |   81 ++++----------------------------
 calendar/gui/e-week-view.c             |    5 ++
 calendar/gui/gnome-cal.c               |    5 +--
 modules/calendar/e-cal-shell-sidebar.c |    3 +
 4 files changed, 19 insertions(+), 75 deletions(-)
---
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 6ad72a5..3c0b462 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -97,13 +97,6 @@
 
 struct _EDayViewPrivate {
        ECalModel *model;
-       gulong notify_work_day_monday_handler_id;
-       gulong notify_work_day_tuesday_handler_id;
-       gulong notify_work_day_wednesday_handler_id;
-       gulong notify_work_day_thursday_handler_id;
-       gulong notify_work_day_friday_handler_id;
-       gulong notify_work_day_saturday_handler_id;
-       gulong notify_work_day_sunday_handler_id;
 
        /* Whether we are showing the work-week view. */
        gboolean work_week_view;
@@ -826,53 +819,9 @@ day_view_dispose (GObject *object)
                day_view->grabbed_pointer = NULL;
        }
 
-       if (day_view->priv->notify_work_day_monday_handler_id > 0) {
-               g_signal_handler_disconnect (
-                       day_view->priv->model,
-                       day_view->priv->notify_work_day_monday_handler_id);
-               day_view->priv->notify_work_day_monday_handler_id = 0;
-       }
-
-       if (day_view->priv->notify_work_day_tuesday_handler_id > 0) {
-               g_signal_handler_disconnect (
-                       day_view->priv->model,
-                       day_view->priv->notify_work_day_tuesday_handler_id);
-               day_view->priv->notify_work_day_tuesday_handler_id = 0;
-       }
-
-       if (day_view->priv->notify_work_day_wednesday_handler_id > 0) {
-               g_signal_handler_disconnect (
-                       day_view->priv->model,
-                       day_view->priv->notify_work_day_wednesday_handler_id);
-               day_view->priv->notify_work_day_wednesday_handler_id = 0;
-       }
-
-       if (day_view->priv->notify_work_day_thursday_handler_id > 0) {
-               g_signal_handler_disconnect (
-                       day_view->priv->model,
-                       day_view->priv->notify_work_day_thursday_handler_id);
-               day_view->priv->notify_work_day_thursday_handler_id = 0;
-       }
-
-       if (day_view->priv->notify_work_day_friday_handler_id > 0) {
-               g_signal_handler_disconnect (
-                       day_view->priv->model,
-                       day_view->priv->notify_work_day_friday_handler_id);
-               day_view->priv->notify_work_day_friday_handler_id = 0;
-       }
-
-       if (day_view->priv->notify_work_day_saturday_handler_id > 0) {
-               g_signal_handler_disconnect (
-                       day_view->priv->model,
-                       day_view->priv->notify_work_day_saturday_handler_id);
-               day_view->priv->notify_work_day_saturday_handler_id = 0;
-       }
-
-       if (day_view->priv->notify_work_day_sunday_handler_id > 0) {
-               g_signal_handler_disconnect (
-                       day_view->priv->model,
-                       day_view->priv->notify_work_day_sunday_handler_id);
-               day_view->priv->notify_work_day_sunday_handler_id = 0;
+       if (day_view->priv->model) {
+               g_signal_handlers_disconnect_by_data (day_view->priv->model, day_view);
+               g_signal_handlers_disconnect_by_data (day_view->priv->model, day_view->main_canvas);
        }
 
        g_clear_object (&day_view->priv->model);
@@ -886,7 +835,6 @@ day_view_constructed (GObject *object)
 {
        EDayView *day_view;
        ECalModel *model;
-       gulong handler_id;
 
        day_view = E_DAY_VIEW (object);
 
@@ -899,42 +847,33 @@ day_view_constructed (GObject *object)
         * disconnect signal handlers in dispose(). */
        day_view->priv->model = g_object_ref (model);
 
-       handler_id = g_signal_connect (
+       g_signal_connect (
                model, "notify::work-day-monday",
                G_CALLBACK (day_view_notify_work_day_cb), day_view);
-       day_view->priv->notify_work_day_monday_handler_id = handler_id;
 
-       handler_id = g_signal_connect (
+       g_signal_connect (
                model, "notify::work-day-tuesday",
                G_CALLBACK (day_view_notify_work_day_cb), day_view);
-       day_view->priv->notify_work_day_tuesday_handler_id = handler_id;
 
-       handler_id = g_signal_connect (
+       g_signal_connect (
                model, "notify::work-day-wednesday",
                G_CALLBACK (day_view_notify_work_day_cb), day_view);
-       day_view->priv->notify_work_day_wednesday_handler_id = handler_id;
 
-       handler_id = g_signal_connect (
+       g_signal_connect (
                model, "notify::work-day-thursday",
                G_CALLBACK (day_view_notify_work_day_cb), day_view);
-       day_view->priv->notify_work_day_thursday_handler_id = handler_id;
 
-       handler_id = g_signal_connect (
+       g_signal_connect (
                model, "notify::work-day-friday",
                G_CALLBACK (day_view_notify_work_day_cb), day_view);
-       day_view->priv->notify_work_day_friday_handler_id = handler_id;
 
-       handler_id = g_signal_connect (
+       g_signal_connect (
                model, "notify::work-day-saturday",
                G_CALLBACK (day_view_notify_work_day_cb), day_view);
-       day_view->priv->notify_work_day_saturday_handler_id = handler_id;
 
-       handler_id = g_signal_connect (
+       g_signal_connect (
                model, "notify::work-day-sunday",
                G_CALLBACK (day_view_notify_work_day_cb), day_view);
-       day_view->priv->notify_work_day_sunday_handler_id = handler_id;
-
-       /* FIXME Should be doing something similar for these handlers. */
 
        g_signal_connect_swapped (
                day_view, "notify::time-divisions",
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index b2bc509..b00a3af 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -718,11 +718,16 @@ static void
 week_view_dispose (GObject *object)
 {
        EWeekView *week_view;
+       ECalModel *model;
 
        week_view = E_WEEK_VIEW (object);
+       model = e_calendar_view_get_model (E_CALENDAR_VIEW (object));
 
        e_week_view_cancel_layout (week_view);
 
+       if (model)
+               g_signal_handlers_disconnect_by_data (model, object);
+
        if (week_view->events) {
                e_week_view_free_events (week_view);
                g_array_free (week_view->events, TRUE);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 684aa83..a686dc2 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1572,10 +1572,7 @@ gnome_calendar_do_dispose (GObject *object)
        }
 
        if (priv->model != NULL) {
-               g_signal_handlers_disconnect_by_func (
-                       priv->model, view_progress_cb, object);
-               g_signal_handlers_disconnect_by_func (
-                       priv->model, view_complete_cb, object);
+               g_signal_handlers_disconnect_by_data (priv->model, object);
                g_object_unref (priv->model);
                priv->model = NULL;
        }
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index bb779da..196e519 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -419,6 +419,9 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
 
        priv = E_CAL_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
 
+       g_signal_handlers_disconnect_by_func (shell_window,
+               cal_shell_sidebar_restore_state_cb, shell_sidebar);
+
        selector = E_SOURCE_SELECTOR (priv->selector);
        registry = e_source_selector_get_registry (selector);
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector));


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