static void gsslrtma_unref_node(GtkTreeModel *tree_model, GtkTreeIter *iter) { gtk_tree_model_unref_node(GTK_TREE_MODEL(GNC_SX_SLR_TREE_MODEL_ADAPTER(tree_model)->real), iter); }
static void ref_count_reorder_two (void) { GtkTreeIter iter1, iter2, iter3, iter4, iter5; GtkTreeIter citer1, citer2, citer3, citer4, citer5; GtkTreeIter siter1, siter2, siter3, siter4, siter5; GtkTreeIter sciter1, sciter2, sciter3, sciter4, sciter5; GtkTreeModel *model; GtkTreeModelRefCount *ref_model; GtkTreeModel *sort_model; GtkWidget *tree_view; GType column_types[] = { G_TYPE_INT }; model = gtk_tree_model_ref_count_new (); ref_model = GTK_TREE_MODEL_REF_COUNT (model); gtk_tree_store_set_column_types (GTK_TREE_STORE (model), 1, column_types); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &iter1, NULL, 0, 0, 30, -1); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &iter2, NULL, 1, 0, 40, -1); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &iter3, NULL, 2, 0, 10, -1); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &iter4, NULL, 3, 0, 20, -1); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &iter5, NULL, 4, 0, 60, -1); /* Child level */ gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &citer1, &iter1, 0, 0, 30, -1); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &citer2, &iter1, 1, 0, 40, -1); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &citer3, &iter1, 2, 0, 10, -1); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &citer4, &iter1, 3, 0, 20, -1); gtk_tree_store_insert_with_values (GTK_TREE_STORE (model), &citer5, &iter1, 4, 0, 60, -1); assert_root_level_unreferenced (ref_model); sort_model = gtk_tree_model_sort_new_with_model (model); tree_view = gtk_tree_view_new_with_model (sort_model); gtk_tree_view_expand_all (GTK_TREE_VIEW (tree_view)); assert_node_ref_count (ref_model, &iter1, 2); assert_node_ref_count (ref_model, &iter2, 1); assert_node_ref_count (ref_model, &iter3, 1); assert_node_ref_count (ref_model, &iter4, 1); assert_node_ref_count (ref_model, &iter5, 1); assert_level_referenced (ref_model, 1, &iter1); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter1, &iter1); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter2, &iter2); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter3, &iter3); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter4, &iter4); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter5, &iter5); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter1, &citer1); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter2, &citer2); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter3, &citer3); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter4, &citer4); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter5, &citer5); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &siter1); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &siter1); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &siter3); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &siter3); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &siter3); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &siter5); assert_node_ref_count (ref_model, &iter1, 4); assert_node_ref_count (ref_model, &iter2, 1); assert_node_ref_count (ref_model, &iter3, 4); assert_node_ref_count (ref_model, &iter4, 1); assert_node_ref_count (ref_model, &iter5, 2); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &sciter3); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &sciter3); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &sciter5); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &sciter5); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &sciter5); gtk_tree_model_ref_node (GTK_TREE_MODEL (sort_model), &sciter1); assert_node_ref_count (ref_model, &citer1, 2); assert_node_ref_count (ref_model, &citer2, 1); assert_node_ref_count (ref_model, &citer3, 3); assert_node_ref_count (ref_model, &citer4, 1); assert_node_ref_count (ref_model, &citer5, 4); /* Sort */ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model), 0, GTK_SORT_ASCENDING); assert_node_ref_count (ref_model, &iter1, 4); assert_node_ref_count (ref_model, &iter2, 1); assert_node_ref_count (ref_model, &iter3, 4); assert_node_ref_count (ref_model, &iter4, 1); assert_node_ref_count (ref_model, &iter5, 2); assert_node_ref_count (ref_model, &citer1, 2); assert_node_ref_count (ref_model, &citer2, 1); assert_node_ref_count (ref_model, &citer3, 3); assert_node_ref_count (ref_model, &citer4, 1); assert_node_ref_count (ref_model, &citer5, 4); /* Re-translate the iters after sorting */ gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter1, &iter1); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter2, &iter2); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter3, &iter3); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter4, &iter4); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &siter5, &iter5); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter1, &citer1); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter2, &citer2); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter3, &citer3); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter4, &citer4); gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &sciter5, &citer5); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &siter1); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &siter1); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &siter3); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &siter3); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &siter3); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &siter5); assert_node_ref_count (ref_model, &iter1, 2); assert_node_ref_count (ref_model, &iter2, 1); assert_node_ref_count (ref_model, &iter3, 1); assert_node_ref_count (ref_model, &iter4, 1); assert_node_ref_count (ref_model, &iter5, 1); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &sciter3); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &sciter3); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &sciter5); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &sciter5); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &sciter5); gtk_tree_model_unref_node (GTK_TREE_MODEL (sort_model), &sciter1); assert_level_referenced (ref_model, 1, &iter1); gtk_widget_destroy (tree_view); g_object_unref (sort_model); assert_entire_model_unreferenced (ref_model); g_object_unref (ref_model); }