541de345.diff 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. diff --git a/gtk/gtktreelistmodel.c b/gtk/gtktreelistmodel.c
  2. index 1e55323c0a4e548bcde5389e72928eee1438c0c9..a4f0fa1d4b9ffe870e0bc9e7420945da946bc253 100644
  3. --- a/gtk/gtktreelistmodel.c
  4. +++ b/gtk/gtktreelistmodel.c
  5. @@ -101,8 +101,15 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
  6. static GtkTreeListModel *
  7. tree_node_get_tree_list_model (TreeNode *node)
  8. {
  9. - for (; !node->is_root; node = node->parent)
  10. - { }
  11. + if (node->is_root)
  12. + return node->list;
  13. +
  14. + for (node = node->parent; !node->is_root; node = node->parent)
  15. + {
  16. + /* This can happen during collapsing of a parent node */
  17. + if (node->children == NULL)
  18. + return NULL;
  19. + }
  20. return node->list;
  21. }
  22. @@ -316,6 +323,9 @@ gtk_tree_list_model_items_changed_cb (GListModel *model,
  23. guint i, tree_position, tree_removed, tree_added, n_local;
  24. self = tree_node_get_tree_list_model (node);
  25. + if (self == NULL)
  26. + return;
  27. +
  28. n_local = g_list_model_get_n_items (model) - added + removed;
  29. if (position < n_local)
  30. @@ -405,10 +415,16 @@ gtk_tree_list_model_clear_node (gpointer data)
  31. TreeNode *node = data;
  32. if (node->row)
  33. - gtk_tree_list_row_destroy (node->row);
  34. + {
  35. + g_object_freeze_notify (G_OBJECT (node->row));
  36. + gtk_tree_list_row_destroy (node->row);
  37. + }
  38. gtk_tree_list_model_clear_node_children (node);
  39. + if (node->row)
  40. + g_object_thaw_notify (G_OBJECT (node->row));
  41. +
  42. g_clear_object (&node->item);
  43. }
  44. @@ -945,16 +961,12 @@ G_DEFINE_TYPE (GtkTreeListRow, gtk_tree_list_row, G_TYPE_OBJECT)
  45. static void
  46. gtk_tree_list_row_destroy (GtkTreeListRow *self)
  47. {
  48. - g_object_freeze_notify (G_OBJECT (self));
  49. -
  50. self->node = NULL;
  51. /* FIXME: We could check some properties to avoid excess notifies */
  52. g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_DEPTH]);
  53. g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_EXPANDABLE]);
  54. g_object_notify_by_pspec (G_OBJECT (self), row_properties[ROW_PROP_EXPANDED]);
  55. -
  56. - g_object_thaw_notify (G_OBJECT (self));
  57. }
  58. static void
  59. @@ -1180,6 +1192,8 @@ gtk_tree_list_row_set_expanded (GtkTreeListRow *self,
  60. return;
  61. list = tree_node_get_tree_list_model (self->node);
  62. + if (list == NULL)
  63. + return;
  64. if (expanded)
  65. {
  66. @@ -1255,6 +1269,9 @@ gtk_tree_list_row_is_expandable (GtkTreeListRow *self)
  67. return TRUE;
  68. list = tree_node_get_tree_list_model (self->node);
  69. + if (list == NULL)
  70. + return FALSE;
  71. +
  72. model = tree_node_create_model (list, self->node);
  73. if (model)
  74. {