[gtk+/wip/baedert/drawing: 155/371] gizmo: Unparent all child widgets in finalize



commit 30794a35cf08d9278f32c47531621e9db5ff267b
Author: Timm Bäder <mail baedert org>
Date:   Thu May 11 21:52:18 2017 +0200

    gizmo: Unparent all child widgets in finalize

 gtk/gtkgizmo.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkgizmo.c b/gtk/gtkgizmo.c
index 38cd3d5..f80fabe 100644
--- a/gtk/gtkgizmo.c
+++ b/gtk/gtkgizmo.c
@@ -51,10 +51,32 @@ gtk_gizmo_snapshot (GtkWidget   *widget,
 }
 
 static void
+gtk_gizmo_finalize (GObject *object)
+{
+  GtkGizmo *self = GTK_GIZMO (object);
+  GtkWidget *widget;
+
+  widget = _gtk_widget_get_first_child (GTK_WIDGET (self));
+  while (widget != NULL)
+    {
+      GtkWidget *next = _gtk_widget_get_next_sibling (widget);
+
+      gtk_widget_unparent (widget);
+
+      widget = next;
+    }
+
+  G_OBJECT_CLASS (gtk_gizmo_parent_class)->finalize (object);
+}
+
+static void
 gtk_gizmo_class_init (GtkGizmoClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->finalize = gtk_gizmo_finalize;
+
   widget_class->measure = gtk_gizmo_measure;
   widget_class->size_allocate = gtk_gizmo_size_allocate;
   widget_class->snapshot = gtk_gizmo_snapshot;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]