[gtk+] treemodelsort: destroy the root only if we are removing the latest row of the level
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] treemodelsort: destroy the root only if we are removing the latest row of the level
- Date: Fri, 3 May 2013 11:06:26 +0000 (UTC)
commit c15a7877e9725d104f1d22a9a264048aa044e282
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu Apr 25 16:30:12 2013 +0200
treemodelsort: destroy the root only if we are removing the latest row of the level
GtkIconView doesn't ref the rows of the model so we have to make sure that a
level is actually empty before destroying it.
https://bugzilla.gnome.org/show_bug.cgi?id=698846
gtk/gtktreemodelsort.c | 2 +-
gtk/tests/sortmodel.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtktreemodelsort.c b/gtk/gtktreemodelsort.c
index b2046c2..a3545e9 100644
--- a/gtk/gtktreemodelsort.c
+++ b/gtk/gtktreemodelsort.c
@@ -1061,7 +1061,7 @@ gtk_tree_model_sort_row_deleted (GtkTreeModel *s_model,
gtk_tree_model_sort_free_level (tree_model_sort,
elt->children, FALSE);
- if (level->ref_count == 0)
+ if (level->ref_count == 0 && g_sequence_get_length (level->seq) == 1)
{
gtk_tree_model_sort_increment_stamp (tree_model_sort);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path);
diff --git a/gtk/tests/sortmodel.c b/gtk/tests/sortmodel.c
index 147db53..a24f8a3 100644
--- a/gtk/tests/sortmodel.c
+++ b/gtk/tests/sortmodel.c
@@ -1171,6 +1171,37 @@ specific_bug_674587 (void)
g_object_unref (m);
}
+static void
+row_deleted_cb (GtkTreeModel *tree_model,
+ GtkTreePath *path,
+ guint *count)
+{
+ *count = *count + 1;
+}
+
+static void
+specific_bug_698846 (void)
+{
+ GtkListStore *store;
+ GtkTreeModel *sorted;
+ GtkTreeIter iter;
+ guint count = 0;
+
+ g_test_bug ("698846");
+
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+ sorted = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
+
+ gtk_list_store_insert_with_values (store, &iter, 0, 0, "a", -1);
+ gtk_list_store_insert_with_values (store, &iter, 1, 0, "b", -1);
+
+ g_signal_connect (sorted, "row-deleted", G_CALLBACK (row_deleted_cb), &count);
+
+ gtk_list_store_clear (store);
+
+ g_assert_cmpuint (count, ==, 2);
+}
+
/* main */
void
@@ -1206,5 +1237,7 @@ register_sort_model_tests (void)
specific_bug_364946);
g_test_add_func ("/TreeModelSort/specific/bug-674587",
specific_bug_674587);
+ g_test_add_func ("/TreeModelSort/specific/bug-698846",
+ specific_bug_698846);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]