filterlistmodel: Make constructor transfer full

This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
This commit is contained in:
Matthias Clasen 2020-07-26 15:55:44 -04:00
parent b6d9f3facb
commit 706d464ae6
18 changed files with 23 additions and 42 deletions

View File

@ -179,14 +179,10 @@ constraint_view_init (ConstraintView *self)
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter);
g_object_unref (filter);
g_object_unref (all_constraints);
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
g_object_unref (filter);
g_object_unref (all_children);
list = g_list_store_new (G_TYPE_LIST_MODEL);
g_list_store_append (list, children);

View File

@ -246,12 +246,8 @@ transform_settings_to_keys (GBinding *binding,
g_object_unref (store);
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
g_object_unref (sort_model);
g_set_object (&current_filter, filter);
g_object_unref (filter);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
selection_model = gtk_no_selection_new (G_LIST_MODEL (filter_model));
g_object_unref (filter_model);

View File

@ -1145,6 +1145,7 @@ activate (GApplication *app)
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
filter = gtk_custom_filter_new ((GtkCustomFilterFunc)demo_filter_by_name, filter_model, NULL);
gtk_filter_list_model_set_filter (filter_model, filter);
g_object_unref (filter);
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);

View File

@ -325,8 +325,6 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
filter = gtk_custom_filter_new (match_func, NULL, NULL);
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
g_object_unref (full_list);
g_object_unref (filter);
dialog->custom_paper_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
gtk_print_load_custom_papers (dialog->custom_paper_list);

View File

@ -666,7 +666,7 @@ gtk_drop_down_set_model (GtkDropDown *self,
GListModel *filter_model;
GListModel *selection;
filter_model = G_LIST_MODEL (gtk_filter_list_model_new (model, NULL));
filter_model = G_LIST_MODEL (gtk_filter_list_model_new (g_object_ref (model), NULL));
g_set_object (&self->filter_model, filter_model);
g_object_unref (filter_model);

View File

@ -614,8 +614,8 @@ gtk_filter_list_model_init (GtkFilterListModel *self)
/**
* gtk_filter_list_model_new:
* @model: (allow-none): the model to sort
* @filter: (allow-none): filter or %NULL to not filter items
* @model: (allow-none) (transfer full): the model to sort, or %NULL
* @filter: (allow-none) (transfer full): filter or %NULL to not filter items
*
* Creates a new #GtkFilterListModel that will filter @model using the given
* @filter.
@ -636,6 +636,10 @@ gtk_filter_list_model_new (GListModel *model,
"filter", filter,
NULL);
/* consume the references */
g_clear_object (&model);
g_clear_object (&filter);
return result;
}

View File

@ -324,8 +324,6 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
filter = gtk_custom_filter_new (match_func, NULL, NULL);
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
g_object_unref (full_list);
g_object_unref (filter);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_printer_item), dialog);

View File

@ -830,7 +830,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
filtered = G_LIST_MODEL (gtk_filter_list_model_new (sorted, filter));
g_object_unref (filter);
selection = G_LIST_MODEL (gtk_single_selection_new (filtered));
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (selection), FALSE);

View File

@ -1151,8 +1151,7 @@ create_root_model (GdkDisplay *display)
g_object_unref (special);
filter = gtk_filter_list_model_new (NULL, NULL);
custom_filter = gtk_custom_filter_new (toplevel_filter_func,
display, NULL);
custom_filter = gtk_custom_filter_new (toplevel_filter_func, display, NULL);
gtk_filter_list_model_set_filter (filter, custom_filter);
gtk_filter_list_model_set_model (filter, gtk_window_get_toplevels ());
g_list_store_append (list, filter);

View File

@ -622,7 +622,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
if (GTK_IS_WIDGET (object))
g_signal_connect_object (object, "destroy", G_CALLBACK (cleanup_object), pl, G_CONNECT_SWAPPED);
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), pl->priv->filter));
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), g_object_ref (pl->priv->filter)));
sorted = gtk_sort_list_model_new (filtered, NULL);
list = G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (sorted)));
@ -635,7 +635,6 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
g_object_unref (list);
g_object_unref (sorted);
g_object_unref (filtered);
g_object_unref (store);
return TRUE;
}

View File

@ -759,7 +759,6 @@ main (int argc, char *argv[])
custom_filter = gtk_custom_filter_new (match_file, g_object_ref (search_entry), g_object_unref);
filter = gtk_filter_list_model_new (G_LIST_MODEL (sort), custom_filter);
g_signal_connect (search_entry, "search-changed", G_CALLBACK (search_changed_cb), custom_filter);
g_object_unref (custom_filter);
gtk_column_view_set_model (GTK_COLUMN_VIEW (view), G_LIST_MODEL (filter));
@ -771,7 +770,6 @@ main (int argc, char *argv[])
gtk_box_append (GTK_BOX (vbox), statusbar);
g_object_unref (filter);
g_object_unref (sort);
g_object_unref (tree);
list = gtk_list_view_new_with_factory (

View File

@ -640,7 +640,6 @@ main (int argc, char *argv[])
custom_filter = gtk_custom_filter_new (match_file, search_entry, NULL);
filter = gtk_filter_list_model_new (G_LIST_MODEL (tree), custom_filter);
g_signal_connect (search_entry, "search-changed", G_CALLBACK (search_changed_cb), custom_filter);
g_object_unref (custom_filter);
selectionmodel = file_info_selection_new (G_LIST_MODEL (filter));
g_object_unref (filter);
@ -654,7 +653,6 @@ main (int argc, char *argv[])
update_statusbar (GTK_STATUSBAR (statusbar));
gtk_box_append (GTK_BOX (vbox), statusbar);
g_object_unref (tree);
g_object_unref (selectionmodel);
gtk_widget_show (win);

View File

@ -203,7 +203,7 @@ test_nested (void)
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "word");
list = G_LIST_MODEL (g_list_store_new (G_TYPE_OBJECT));
filtered = gtk_filter_list_model_new (list, filter);
filtered = gtk_filter_list_model_new (list, g_object_ref (filter));
list_expr = gtk_object_expression_new (G_OBJECT (filtered));
filter_expr = gtk_property_expression_new (GTK_TYPE_FILTER_LIST_MODEL, list_expr, "filter");
@ -262,8 +262,6 @@ test_nested (void)
g_assert_cmpint (counter, ==, 0);
g_object_unref (filtered);
g_object_unref (list);
g_object_unref (filter);
gtk_expression_unref (expr);
}
@ -292,7 +290,7 @@ test_nested_this_destroyed (void)
filter = gtk_string_filter_new (NULL);
gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "word");
list = G_LIST_MODEL (g_list_store_new (G_TYPE_OBJECT));
filtered = gtk_filter_list_model_new (list, filter);
filtered = gtk_filter_list_model_new (list, g_object_ref (filter));
list_expr = gtk_object_expression_new (G_OBJECT (filtered));
filter_expr = gtk_property_expression_new (GTK_TYPE_FILTER_LIST_MODEL, list_expr, "filter");
@ -333,7 +331,6 @@ test_nested_this_destroyed (void)
g_assert_cmpint (counter, ==, 0);
g_object_unref (filtered);
g_object_unref (list);
g_object_unref (filter);
gtk_expression_unref (expr);
}
@ -492,11 +489,8 @@ test_bind_child (void)
"filter");
filter = gtk_string_filter_new (NULL);
child = gtk_filter_list_model_new (NULL, NULL);
gtk_filter_list_model_set_filter (child, filter);
child = gtk_filter_list_model_new (NULL, filter);
target = gtk_filter_list_model_new (G_LIST_MODEL (child), NULL);
g_object_unref (child);
g_object_unref (filter);
gtk_expression_bind (expr, target, "filter", child);
g_assert_true (gtk_filter_list_model_get_filter (child) == gtk_filter_list_model_get_filter (target));
@ -528,7 +522,7 @@ test_nested_bind (void)
gtk_string_filter_set_search (GTK_STRING_FILTER (filter2), "sausage");
list = G_LIST_MODEL (g_list_store_new (G_TYPE_OBJECT));
filtered = gtk_filter_list_model_new (list, filter2);
filtered = gtk_filter_list_model_new (list, g_object_ref (filter2));
filter_expr = gtk_property_expression_new (GTK_TYPE_FILTER_LIST_MODEL,
gtk_object_expression_new (G_OBJECT (filtered)),
@ -566,7 +560,6 @@ test_nested_bind (void)
g_object_unref (filter2);
g_object_unref (filter3);
g_object_unref (filtered);
g_object_unref (list);
gtk_expression_unref (expr);
gtk_expression_unref (filter_expr);
@ -709,7 +702,6 @@ test_bind_object (void)
gtk_expression_unref (expr);
g_object_unref (model);
g_object_unref (store);
}
int

View File

@ -189,7 +189,7 @@ new_model (guint size,
{
GtkFilterListModel *result;
result = gtk_filter_list_model_new (G_LIST_MODEL (new_store (1, size, 1)), filter);
result = gtk_filter_list_model_new (g_object_ref (G_LIST_MODEL (new_store (1, size, 1))), g_object_ref (filter));
return result;
}

View File

@ -135,6 +135,10 @@ filter_list_model_new (GListModel *source,
GListStore *check;
guint i;
if (source)
g_object_ref (source);
if (filter)
g_object_ref (filter);
model = gtk_filter_list_model_new (source, filter);
check = g_list_store_new (G_TYPE_OBJECT);
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model)); i++)

View File

@ -167,8 +167,7 @@ new_model (guint size,
filter = gtk_custom_filter_new (filter_func, data, NULL);
else
filter = NULL;
result = gtk_filter_list_model_new (G_LIST_MODEL (new_store (1, size, 1)), filter);
g_clear_object (&filter);
result = gtk_filter_list_model_new (g_object_ref (G_LIST_MODEL (new_store (1, size, 1))), filter);
changes = g_string_new ("");
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);

View File

@ -627,7 +627,7 @@ test_set_model (void)
store = new_store (1, 5, 1);
m1 = G_LIST_MODEL (store);
m2 = G_LIST_MODEL (gtk_slice_list_model_new (m1, 0, 3));
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
selection = new_model (store);
assert_selection (selection, "");
assert_selection_changes (selection, "");

View File

@ -653,7 +653,7 @@ test_set_model (void)
store = new_store (1, 5, 1);
m1 = G_LIST_MODEL (store);
m2 = G_LIST_MODEL (gtk_slice_list_model_new (m1, 0, 3));
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
selection = new_model (store, TRUE, TRUE);
assert_selection (selection, "1");
assert_selection_changes (selection, "");