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
This commit is contained in:
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user