summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/constraint-editor/constraint-view.c13
-rw-r--r--gtk/gtkcustompaperunixdialog.c1
-rw-r--r--gtk/gtkflattenlistmodel.c5
-rw-r--r--gtk/gtkfontchooserwidget.c2
-rw-r--r--gtk/gtkpagesetupunixdialog.c1
-rw-r--r--gtk/gtkprintunixdialog.c8
-rw-r--r--gtk/gtkshortcutmanager.c9
-rw-r--r--gtk/inspector/controllers.c1
-rw-r--r--gtk/inspector/object-tree.c61
-rw-r--r--testsuite/gtk/filterlistmodel-exhaustive.c2
-rw-r--r--testsuite/gtk/flattenlistmodel.c2
-rw-r--r--testsuite/gtk/sortlistmodel-exhaustive.c1
12 files changed, 30 insertions, 76 deletions
diff --git a/demos/constraint-editor/constraint-view.c b/demos/constraint-editor/constraint-view.c
index c9d08acab8..a3fbd447bf 100644
--- a/demos/constraint-editor/constraint-view.c
+++ b/demos/constraint-editor/constraint-view.c
@@ -174,28 +174,29 @@ constraint_view_init (ConstraintView *self)
manager = gtk_constraint_layout_new ();
gtk_widget_set_layout_manager (GTK_WIDGET (self), manager);
- all_children = gtk_widget_observe_children (GTK_WIDGET (self));
- all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager));
+
+ 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);
g_list_store_append (list, guides);
g_list_store_append (list, constraints);
- self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
g_object_unref (children);
g_object_unref (guides);
g_object_unref (constraints);
- g_object_unref (all_children);
- g_object_unref (all_constraints);
- g_object_unref (list);
+ self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
controller = (GtkEventController *)gtk_gesture_drag_new ();
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
diff --git a/gtk/gtkcustompaperunixdialog.c b/gtk/gtkcustompaperunixdialog.c
index 6940fdf12a..501331c99b 100644
--- a/gtk/gtkcustompaperunixdialog.c
+++ b/gtk/gtkcustompaperunixdialog.c
@@ -322,7 +322,6 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
g_object_unref (printer_list);
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (printer_list_list)));
- g_object_unref (printer_list_list);
filter = gtk_custom_filter_new (match_func, NULL, NULL);
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
diff --git a/gtk/gtkflattenlistmodel.c b/gtk/gtkflattenlistmodel.c
index f4398d853c..cea983f8da 100644
--- a/gtk/gtkflattenlistmodel.c
+++ b/gtk/gtkflattenlistmodel.c
@@ -425,7 +425,7 @@ gtk_flatten_list_model_init (GtkFlattenListModel *self)
/**
* gtk_flatten_list_model_new:
- * @model: (nullable) (transfer none): the model to be flattened
+ * @model: (nullable) (transfer full): the model to be flattened
*
* Creates a new #GtkFlattenListModel that flattens @list.
*
@@ -442,6 +442,9 @@ gtk_flatten_list_model_new (GListModel *model)
"model", model,
NULL);
+ /* we consume the reference */
+ g_clear_object (&model);
+
return result;
}
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index e56b13ad42..7558fa1bce 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -784,7 +784,7 @@ update_fontlist (GtkFontChooserWidget *self)
if ((self->level & GTK_FONT_CHOOSER_LEVEL_STYLE) == 0)
model = g_object_ref (G_LIST_MODEL (fontmap));
else
- model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (fontmap)));
+ model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (g_object_ref (fontmap))));
gtk_filter_list_model_set_model (self->filter_model, model);
g_object_unref (model);
}
diff --git a/gtk/gtkpagesetupunixdialog.c b/gtk/gtkpagesetupunixdialog.c
index c0743deaee..3964a1aa60 100644
--- a/gtk/gtkpagesetupunixdialog.c
+++ b/gtk/gtkpagesetupunixdialog.c
@@ -308,7 +308,6 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
g_list_store_append (store, dialog->manage_papers_list);
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
- g_object_unref (store);
g_object_unref (paper_size_list);
/* Do this in code, we want the translatable strings without the markup */
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 26a25a6cfc..3c88f4cc25 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -807,7 +807,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
g_list_store_append (store, dialog->manage_papers_list);
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
- g_object_unref (store);
g_object_unref (paper_size_list);
/* Load backends */
@@ -1037,7 +1036,6 @@ load_print_backends (GtkPrintUnixDialog *dialog)
{
GList *node;
GListStore *lists;
- GListModel *model;
lists = g_list_store_new (G_TYPE_LIST_MODEL);
@@ -1053,11 +1051,7 @@ load_print_backends (GtkPrintUnixDialog *dialog)
g_list_store_append (lists, gtk_print_backend_get_printers (backend));
}
- model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
-
- g_object_unref (lists);
-
- return model;
+ return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
}
static void
diff --git a/gtk/gtkshortcutmanager.c b/gtk/gtkshortcutmanager.c
index a6f2559b1d..0351490df2 100644
--- a/gtk/gtkshortcutmanager.c
+++ b/gtk/gtkshortcutmanager.c
@@ -44,21 +44,16 @@ G_DEFINE_INTERFACE (GtkShortcutManager, gtk_shortcut_manager, G_TYPE_OBJECT)
void
gtk_shortcut_manager_create_controllers (GtkWidget *widget)
{
- GListStore *store;
GtkFlattenListModel *model;
GtkEventController *controller;
- store = g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER);
- model = gtk_flatten_list_model_new (G_LIST_MODEL (store));
- g_object_unref (store);
+ model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-bubble", model, g_object_unref);
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-bubble");
gtk_widget_add_controller (widget, controller);
- store = g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER);
- model = gtk_flatten_list_model_new (G_LIST_MODEL (store));
- g_object_unref (store);
+ model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-capture", model, g_object_unref);
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-capture");
diff --git a/gtk/inspector/controllers.c b/gtk/inspector/controllers.c
index a8fa4340ed..5c4bab15b5 100644
--- a/gtk/inspector/controllers.c
+++ b/gtk/inspector/controllers.c
@@ -260,7 +260,6 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
g_object_unref (sort_model);
g_object_unref (flatten_model);
- g_object_unref (map_model);
}
static void
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index 3c41bfd432..bd2585b06b 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -116,7 +116,6 @@ static GListModel *
object_tree_widget_get_children (GObject *object)
{
GtkWidget *widget = GTK_WIDGET (object);
- GtkFlattenListModel *flatten;
GListStore *list;
GListModel *sublist;
@@ -130,10 +129,7 @@ object_tree_widget_get_children (GObject *object)
g_list_store_append (list, sublist);
g_object_unref (sublist);
- flatten = gtk_flatten_list_model_new (G_LIST_MODEL (list));
- g_object_unref (list);
-
- return G_LIST_MODEL (flatten);
+ return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
}
static GListModel *
@@ -211,7 +207,6 @@ list_model_for_properties (GObject *object,
const char **props)
{
GListStore *concat;
- GListModel *result;
guint i;
if (props[1] == NULL)
@@ -225,9 +220,7 @@ list_model_for_properties (GObject *object,
g_object_unref (tmp);
}
- result = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (concat)));
- g_object_unref (concat);
- return result;
+ return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (concat)));
}
static GListModel *
@@ -310,7 +303,6 @@ object_tree_tree_view_get_children (GObject *object)
GtkTreeView *treeview = GTK_TREE_VIEW (object);
GListStore *columns, *selection, *result_list;
GListModel *props;
- GtkFlattenListModel *result;
guint i;
props = list_model_for_properties (object, (const char *[2]) { "model", NULL });
@@ -330,10 +322,8 @@ object_tree_tree_view_get_children (GObject *object)
g_object_unref (selection);
g_list_store_append (result_list, columns);
g_object_unref (columns);
- result = gtk_flatten_list_model_new (G_LIST_MODEL (result_list));
- g_object_unref (result_list);
- return G_LIST_MODEL (result);
+ return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
}
static GListModel *
@@ -341,7 +331,6 @@ object_tree_column_view_get_children (GObject *object)
{
GtkColumnView *view = GTK_COLUMN_VIEW (object);
GListStore *result_list;
- GtkFlattenListModel *result;
GListModel *columns, *sublist;
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
@@ -353,10 +342,7 @@ object_tree_column_view_get_children (GObject *object)
g_list_store_append (result_list, sublist);
g_object_unref (sublist);
- result = gtk_flatten_list_model_new (G_LIST_MODEL (result_list));
- g_object_unref (result_list);
-
- return G_LIST_MODEL (result);
+ return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
}
static GListModel *
@@ -602,12 +588,11 @@ static GListModel *
object_get_children (GObject *object)
{
GType object_type;
- GListModel *result, *children;
+ GListModel *children;
GListStore *result_list;
guint i;
object_type = G_OBJECT_TYPE (object);
- result = NULL;
result_list = NULL;
for (i = 0; i < G_N_ELEMENTS (object_tree_class_funcs); i++)
@@ -619,32 +604,17 @@ object_get_children (GObject *object)
if (children == NULL)
continue;
- if (result_list)
- {
- g_list_store_append (result_list, children);
- g_object_unref (children);
- }
- else if (result == NULL)
- {
- result = children;
- }
- else
- {
- result_list = g_list_store_new (G_TYPE_LIST_MODEL);
- g_list_store_append (result_list, result);
- g_object_unref (result);
- g_list_store_append (result_list, children);
- g_object_unref (children);
- }
- }
+ if (!result_list)
+ result_list = g_list_store_new (G_TYPE_LIST_MODEL);
- if (result_list)
- {
- result = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
- g_object_unref (result_list);
+ g_list_store_append (result_list, children);
+ g_object_unref (children);
}
- return result;
+ if (result_list)
+ return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
+ else
+ return NULL;
}
static const char *
@@ -1167,7 +1137,6 @@ create_root_model (GdkDisplay *display)
{
GtkFilter *custom_filter;
GtkFilterListModel *filter;
- GtkFlattenListModel *flatten;
GListStore *list, *special;
gpointer item;
@@ -1189,9 +1158,7 @@ create_root_model (GdkDisplay *display)
g_list_store_append (list, filter);
g_object_unref (filter);
- flatten = gtk_flatten_list_model_new (G_LIST_MODEL (list));
- g_object_unref (list);
- return G_LIST_MODEL (flatten);
+ return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
}
static void
diff --git a/testsuite/gtk/filterlistmodel-exhaustive.c b/testsuite/gtk/filterlistmodel-exhaustive.c
index 19bec198a3..12b9bedb55 100644
--- a/testsuite/gtk/filterlistmodel-exhaustive.c
+++ b/testsuite/gtk/filterlistmodel-exhaustive.c
@@ -443,8 +443,6 @@ test_model_changes (gconstpointer model_id)
g_object_unref (model2);
g_object_unref (flatten2);
g_object_unref (flatten1);
- g_object_unref (store2);
- g_object_unref (store1);
g_object_unref (multi);
}
diff --git a/testsuite/gtk/flattenlistmodel.c b/testsuite/gtk/flattenlistmodel.c
index 12fc279d18..6c551ecefe 100644
--- a/testsuite/gtk/flattenlistmodel.c
+++ b/testsuite/gtk/flattenlistmodel.c
@@ -210,7 +210,7 @@ new_model (GListStore *store)
GtkFlattenListModel *result;
GString *changes;
- result = gtk_flatten_list_model_new (G_LIST_MODEL (store));
+ result = gtk_flatten_list_model_new (g_object_ref (G_LIST_MODEL (store)));
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);
diff --git a/testsuite/gtk/sortlistmodel-exhaustive.c b/testsuite/gtk/sortlistmodel-exhaustive.c
index 519df756ad..049df6b295 100644
--- a/testsuite/gtk/sortlistmodel-exhaustive.c
+++ b/testsuite/gtk/sortlistmodel-exhaustive.c
@@ -433,7 +433,6 @@ test_stability (gconstpointer model_id)
g_object_unref (sort2);
g_object_unref (sort1);
g_object_unref (flatten);
- g_object_unref (store);
}
static void