[gnome-todo] grid-item: Avoid crash by disconnecting signal handlers



commit c553e45a332322ceed6065c7a3bbf1656cefe6a6
Author: Victor Toso <me victortoso com>
Date:   Tue Nov 8 00:22:41 2016 +0100

    grid-item: Avoid crash by disconnecting signal handlers
    
    As GtdListSelectorGridItem might be terminated already when GtdTaskList emits
    some signal as backtrace bellow shows
    
    Thread 1 "gnome-todo" received signal SIGSEGV, Segmentation fault.
     in g_type_check_instance_cast (type_instance=0x117c4f0, iface_type=16593856)
     at (...)/glib/gobject/gtype.c:4056
    4056              node = lookup_type_node_I (type_instance->g_class->g_type);
    (gdb) bt
     #0 g_type_check_instance_cast (type_instance=0x117c4f0, iface_type=16593856)
        at (...)/glib/gobject/gtype.c:4056
     #1 GTD_LIST_SELECTOR_GRID_ITEM (ptr=0x117c4f0) at
        views/gtd-list-selector-grid-item.h:30
     #2 gtd_list_selector_grid_item__task_changed (list=0x11d08d0, task=0x13eb340,
        user_data=0x117c4f0) at views/gtd-list-selector-grid-item.c:316
     #3 g_cclosure_marshal_VOID__OBJECT (closure=0x11d3ef0, return_value=0x0,
        n_param_values=2, param_values=0x7fffffff8af0,
        invocation_hint=0x7fffffff8a30, marshal_data=0x0) at
        (...)/glib/gobject/gmarshal.c:2062
     #4 g_closure_invoke (closure=0x11d3ef0, return_value=0x0, n_param_values=2,
        param_values=0x7fffffff8af0, invocation_hint=0x7fffffff8a30) at
        (...)/glib/gobject/gclosure.c:804
     #5 signal_emit_unlocked_R (node=0xd71380, detail=0, instance=0x11d08d0,
        emission_return=0x0, instance_and_params=0x7fffffff8af0) at
        (...)/glib/gobject/gsignal.c:3635
     #6 g_signal_emit_valist (instance=0x11d08d0, signal_id=403, detail=0,
        var_args=0x7fffffff8db8) at (...)/glib/gobject/gsignal.c:3391
     #7 g_signal_emit (instance=0x11d08d0, signal_id=403, detail=0) at
        (...)/glib/gobject/gsignal.c:3447
     #8 task_changed_cb (task=0x13eb340, pspec=0x911490, self=0x11d08d0) at
        gtd-task-list.c:168
    
    Signed-off-by: Victor Toso <victortoso redhat com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774082

 src/views/gtd-list-selector-grid-item.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/views/gtd-list-selector-grid-item.c b/src/views/gtd-list-selector-grid-item.c
index a8debea..00acb26 100644
--- a/src/views/gtd-list-selector-grid-item.c
+++ b/src/views/gtd-list-selector-grid-item.c
@@ -428,6 +428,29 @@ gtd_list_selector_grid_item_finalize (GObject *object)
 }
 
 static void
+gtd_list_selector_grid_item_dispose (GObject *object)
+{
+  GtdListSelectorGridItem *self = GTD_LIST_SELECTOR_GRID_ITEM (object);
+
+  if (self->list)
+    {
+      g_signal_handlers_disconnect_by_func (self->list,
+                                            gtd_list_selector_grid_item__notify_ready,
+                                            self);
+      g_signal_handlers_disconnect_by_func (self->list,
+                                            color_changed,
+                                            self);
+      g_signal_handlers_disconnect_by_func (self->list,
+                                            gtd_list_selector_grid_item__task_changed,
+                                            self);
+      g_clear_object (&self->list);
+    }
+
+
+  G_OBJECT_CLASS (gtd_list_selector_grid_item_parent_class)->dispose (object);
+}
+
+static void
 gtd_list_selector_grid_item_get_property (GObject    *object,
                                  guint       prop_id,
                                  GValue     *value,
@@ -537,6 +560,7 @@ gtd_list_selector_grid_item_class_init (GtdListSelectorGridItemClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   object_class->finalize = gtd_list_selector_grid_item_finalize;
+  object_class->dispose = gtd_list_selector_grid_item_dispose;
   object_class->get_property = gtd_list_selector_grid_item_get_property;
   object_class->set_property = gtd_list_selector_grid_item_set_property;
 


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