Commit ea050b26 authored by Michael Natterer's avatar Michael Natterer 😴

app: don't leak all cached GtkTreeIters in container views

This is evil: the hash table of "insert_data" is created on demand
when GimpContainerView API is used, using a value_free_func that is
set in the interface_init functions of its implementors. Therefore, no
GimpContainerView API must be called from any init() function, because
the interface_init() function of a subclass that sets the right
value_free_func might not have been called yet, leaving the
insert_data hash table without memory management.

Call GimpContainerView API from GObject::constructed() instead, which
runs after everything is set up correctly.
parent a60463cd
......@@ -43,6 +43,8 @@
static void gimp_container_box_view_iface_init (GimpContainerViewInterface *iface);
static void gimp_container_box_docked_iface_init (GimpDockedInterface *iface);
static void gimp_container_box_constructed (GObject *object);
static GtkWidget * gimp_container_box_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
......@@ -65,6 +67,7 @@ gimp_container_box_class_init (GimpContainerBoxClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = gimp_container_box_constructed;
object_class->set_property = gimp_container_view_set_property;
object_class->get_property = gimp_container_view_get_property;
......@@ -74,8 +77,7 @@ gimp_container_box_class_init (GimpContainerBoxClass *klass)
static void
gimp_container_box_init (GimpContainerBox *box)
GimpContainerView *view = GIMP_CONTAINER_VIEW (box);
GtkWidget *sb;
GtkWidget *sb;
box->scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_box_pack_start (GTK_BOX (box), box->scrolled_win, TRUE, TRUE, 0);
......@@ -84,8 +86,6 @@ gimp_container_box_init (GimpContainerBox *box)
sb = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (box->scrolled_win));
gtk_widget_set_can_focus (sb, FALSE);
gimp_container_view_set_dnd_widget (view, box->scrolled_win);
static void
......@@ -100,6 +100,18 @@ gimp_container_box_docked_iface_init (GimpDockedInterface *iface)
iface->set_context = gimp_container_box_set_context;
static void
gimp_container_box_constructed (GObject *object)
GimpContainerBox *box = GIMP_CONTAINER_BOX (object);
gimp_container_view_set_dnd_widget (GIMP_CONTAINER_VIEW (box),
if (G_OBJECT_CLASS (parent_class)->constructed)
G_OBJECT_CLASS (parent_class)->constructed (object);
gimp_container_box_set_size_request (GimpContainerBox *box,
gint width,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment