diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2015-08-17 13:32:35 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2015-08-17 13:32:35 +0100 |
commit | 3de1bd383afddd3b530b612f8539d1866388b88d (patch) | |
tree | a3df46881545b7c1f6c148883ef8aa10d1c59e6b /gtk/gtkflowbox.c | |
parent | e8063bcb210d729297cd4667c6a5c23ac0b477fc (diff) | |
download | gtk+-3de1bd383afddd3b530b612f8539d1866388b88d.tar.gz |
flowbox: Sink the floating reference of model-based children
We don't want to leak references if the widget created to represent the
item in the model does not have a floating reference — which is usually
what happens in bindings, as they automatically sink references when
creating new instances.
See commit 6e03e7e8 for the similar change in GtkListBox.
Diffstat (limited to 'gtk/gtkflowbox.c')
-rw-r--r-- | gtk/gtkflowbox.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index 40d60a240a..e84b3597a9 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -4036,9 +4036,22 @@ gtk_flow_box_bound_model_changed (GListModel *list, item = g_list_model_get_item (list, position + i); widget = priv->create_widget_func (item, priv->create_widget_func_data); + + /* We need to sink the floating reference here, so that we can accept + * both instances created with a floating reference (e.g. C functions + * that just return the result of g_object_new()) and without (e.g. + * from language bindings which will automatically sink the floating + * reference). + * + * See the similar code in gtklistbox.c:gtk_list_box_bound_model_changed. + */ + if (g_object_is_floating (widget)) + g_object_ref_sink (widget); + gtk_widget_show (widget); gtk_flow_box_insert (box, widget, position + i); + g_object_unref (widget); g_object_unref (item); } } |