summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-07-26 17:16:15 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-07-26 18:04:40 -0400
commitccb9dcc86bbc6809e78a5b773324c9d0ffdf0803 (patch)
tree155ad1eb32c07a02765eb9a7f0a583b333804140
parent68d6671413587716b75f29d3c18940d560d76f25 (diff)
downloadgtk+-ccb9dcc86bbc6809e78a5b773324c9d0ffdf0803.tar.gz
singleselection: 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.
-rw-r--r--demos/gtk-demo/listview_settings.c1
-rw-r--r--gtk/gtkcustompaperunixdialog.c2
-rw-r--r--gtk/gtkdropdown.c3
-rw-r--r--gtk/gtklistbase.c2
-rw-r--r--gtk/gtkprintunixdialog.c1
-rw-r--r--gtk/gtksingleselection.c11
-rw-r--r--gtk/inspector/object-tree.c2
-rw-r--r--gtk/inspector/recorder.c2
-rw-r--r--gtk/inspector/resource-list.c1
-rw-r--r--testsuite/gtk/singleselection.c2
10 files changed, 15 insertions, 12 deletions
diff --git a/demos/gtk-demo/listview_settings.c b/demos/gtk-demo/listview_settings.c
index 0ddd61889b..03ed9642e4 100644
--- a/demos/gtk-demo/listview_settings.c
+++ b/demos/gtk-demo/listview_settings.c
@@ -409,7 +409,6 @@ do_listview_settings (GtkWidget *do_widget)
columnview, NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
g_object_unref (selection);
- g_object_unref (treemodel);
name_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "name_column"));
sorter = gtk_string_sorter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
diff --git a/gtk/gtkcustompaperunixdialog.c b/gtk/gtkcustompaperunixdialog.c
index d16ae2e5ca..138f4e4ef1 100644
--- a/gtk/gtkcustompaperunixdialog.c
+++ b/gtk/gtkcustompaperunixdialog.c
@@ -896,7 +896,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog)
listview = gtk_list_view_new ();
gtk_widget_set_size_request (listview, 140, -1);
- model = G_LIST_MODEL (gtk_single_selection_new (G_LIST_MODEL (dialog->custom_paper_list)));
+ model = G_LIST_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (dialog->custom_paper_list))));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), model);
g_signal_connect (model, "notify::selected", G_CALLBACK (selected_custom_paper_changed), dialog);
g_object_unref (model);
diff --git a/gtk/gtkdropdown.c b/gtk/gtkdropdown.c
index e28369850e..32daf0a7b2 100644
--- a/gtk/gtkdropdown.c
+++ b/gtk/gtkdropdown.c
@@ -668,7 +668,6 @@ gtk_drop_down_set_model (GtkDropDown *self,
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);
update_filter (self);
@@ -677,7 +676,7 @@ gtk_drop_down_set_model (GtkDropDown *self,
gtk_list_view_set_model (GTK_LIST_VIEW (self->popup_list), selection);
g_object_unref (selection);
- selection = G_LIST_MODEL (gtk_single_selection_new (model));
+ selection = G_LIST_MODEL (gtk_single_selection_new (g_object_ref (model)));
g_set_object (&self->selection, selection);
g_object_unref (selection);
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c
index 5a1a38e40a..d6e1a129d0 100644
--- a/gtk/gtklistbase.c
+++ b/gtk/gtklistbase.c
@@ -2130,7 +2130,7 @@ gtk_list_base_set_model (GtkListBase *self,
if (GTK_IS_SELECTION_MODEL (model))
selection_model = GTK_SELECTION_MODEL (g_object_ref (model));
else
- selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
+ selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (model)));
gtk_list_item_manager_set_model (priv->item_manager, selection_model);
gtk_list_base_set_anchor (self, 0, 0.0, GTK_PACK_START, 0.0, GTK_PACK_START);
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 2305d3d4ed..23e43d9877 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -837,7 +837,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
g_signal_connect (selection, "items-changed", G_CALLBACK (printer_added_cb), dialog);
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
g_object_unref (selection);
- g_object_unref (filtered);
gtk_print_load_custom_papers (dialog->custom_paper_list);
diff --git a/gtk/gtksingleselection.c b/gtk/gtksingleselection.c
index 209f6524e8..8c23d3c303 100644
--- a/gtk/gtksingleselection.c
+++ b/gtk/gtksingleselection.c
@@ -453,7 +453,7 @@ gtk_single_selection_init (GtkSingleSelection *self)
/**
* gtk_single_selection_new:
- * @model: (transfer none): the #GListModel to manage
+ * @model: (allow-none) (transfer full): the #GListModel to manage, or %NULL
*
* Creates a new selection to handle @model.
*
@@ -462,11 +462,18 @@ gtk_single_selection_init (GtkSingleSelection *self)
GtkSingleSelection *
gtk_single_selection_new (GListModel *model)
{
+ GtkSingleSelection *self;
+
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
- return g_object_new (GTK_TYPE_SINGLE_SELECTION,
+ self = g_object_new (GTK_TYPE_SINGLE_SELECTION,
"model", model,
NULL);
+
+ /* consume the reference */
+ g_clear_object (&model);
+
+ return self;
}
/**
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index 5b65f03b91..32124431af 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -1304,7 +1304,7 @@ gtk_inspector_object_tree_set_display (GtkInspectorObjectTree *wt,
create_model_for_object,
NULL,
NULL);
- wt->priv->selection = gtk_single_selection_new (G_LIST_MODEL (wt->priv->tree_model));
+ wt->priv->selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (wt->priv->tree_model)));
gtk_column_view_set_model (GTK_COLUMN_VIEW (wt->priv->list),
G_LIST_MODEL (wt->priv->selection));
}
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index c76fb2971c..0fefa1609d 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -1239,7 +1239,7 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
TRUE,
create_list_model_for_render_node_paintable,
NULL, NULL);
- recorder->render_node_selection = gtk_single_selection_new (G_LIST_MODEL (recorder->render_node_model));
+ recorder->render_node_selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (recorder->render_node_model)));
g_signal_connect (recorder->render_node_selection, "notify::selected-item", G_CALLBACK (render_node_list_selection_changed), recorder);
factory = gtk_signal_list_item_factory_new ();
diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c
index 2abce1df7f..997e327742 100644
--- a/gtk/inspector/resource-list.c
+++ b/gtk/inspector/resource-list.c
@@ -712,7 +712,6 @@ constructed (GObject *object)
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
sort_model = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (rl->tree_model)), sorter));
rl->selection = gtk_single_selection_new (sort_model);
- g_object_unref (sort_model);
gtk_column_view_set_model (GTK_COLUMN_VIEW (rl->list), G_LIST_MODEL (rl->selection));
diff --git a/testsuite/gtk/singleselection.c b/testsuite/gtk/singleselection.c
index 256506cb4e..b94b38091f 100644
--- a/testsuite/gtk/singleselection.c
+++ b/testsuite/gtk/singleselection.c
@@ -249,7 +249,7 @@ new_model (GListStore *store, gboolean autoselect, gboolean can_unselect)
GtkSelectionModel *result;
GString *changes;
- result = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (store)));
+ result = GTK_SELECTION_MODEL (gtk_single_selection_new (g_object_ref (G_LIST_MODEL (store))));
/* We want to return an empty selection unless autoselect is true,
* so undo the initial selection due to autoselect defaulting to TRUE.