[gnome-todo] list-selector-grid-item don't update thumbnail on dispose



commit 63bffd17bab18bba4a00ecff67c6320b9b2a8d53
Author: Rohit Kaushik <kaushikrohit325 gmail com>
Date:   Wed Mar 22 23:13:08 2017 +0530

    list-selector-grid-item don't update thumbnail on dispose
    
    Rendering of list_selector_grid_item with NULL list reference causes
    segmentation fault errors. While updating thumbnail of grid_item,
    check is not imposed if list has been disposed.
    
    The problem is that grid_item_update_thumbnail is being called even if
    the list reference has been disposed.When provider is removed all the
    list that it stores gets deleted.after disposal of item->list, grid item
    widget flags changes which call the update_thumbnail which calls
    render_thumbnail. This should only be called if list has not been
    disposed as thumbnail will only be updated for non null list items in
    the grid.
    
    The fix is to check if the gtd-list-selector-item has a reference to valid
    list and if true call the gtd_list_selector_grid_item__update_thumbnail
    else do not call the update_thumbnail.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778839

 src/views/gtd-list-selector-grid-item.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/views/gtd-list-selector-grid-item.c b/src/views/gtd-list-selector-grid-item.c
index ab3752a..6147e09 100644
--- a/src/views/gtd-list-selector-grid-item.c
+++ b/src/views/gtd-list-selector-grid-item.c
@@ -368,10 +368,21 @@ static void
 gtd_list_selector_grid_item_state_flags_changed (GtkWidget     *item,
                                          GtkStateFlags  flags)
 {
+  GtdListSelectorGridItem *self;
+
+  self = GTD_LIST_SELECTOR_GRID_ITEM (item);
+
   if (GTK_WIDGET_CLASS (gtd_list_selector_grid_item_parent_class)->state_flags_changed)
     GTK_WIDGET_CLASS (gtd_list_selector_grid_item_parent_class)->state_flags_changed (item, flags);
 
-  gtd_list_selector_grid_item__update_thumbnail (GTD_LIST_SELECTOR_GRID_ITEM (item));
+  /*
+   * The list might be NULL when the provider has been removed, in which
+   * case :dispose() will be called before this function which will remove
+   * the list reference from GtdListSelectorGridItem.
+   */
+
+  if (self->list)
+    gtd_list_selector_grid_item__update_thumbnail (GTD_LIST_SELECTOR_GRID_ITEM (item));
 }
 
 static GtdTaskList*


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