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



commit b4238268166639234e36a06879e9f5909cf1bf78
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]