[gtk+: 31/54] gtk-demo: Fix crash after running popovers demo



commit 7e30b82aee60c431e4fd55f06b56a4f48ed9774d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jan 10 14:07:44 2014 +0100

    gtk-demo: Fix crash after running popovers demo
    
    The GtkBuilder window containing the complex popover UI was left
    dangling, and with a dangling pointer to its former child, causing
    crashes on gtk_grab_notify() after the popover was destroyed.

 demos/gtk-demo/popover.c  |    9 ++++++---
 demos/gtk-demo/popover.ui |    2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/demos/gtk-demo/popover.c b/demos/gtk-demo/popover.c
index 809fcef..4247f57 100644
--- a/demos/gtk-demo/popover.c
+++ b/demos/gtk-demo/popover.c
@@ -35,14 +35,17 @@ static GtkWidget *
 create_complex_popover (GtkWidget       *parent,
                         GtkPositionType  pos)
 {
-  GtkWidget *popover, *content;
+  GtkWidget *popover, *window, *content;
   GtkBuilder *builder;
 
   builder = gtk_builder_new ();
   gtk_builder_add_from_resource (builder, "/popover/popover.ui", NULL);
-  content = GTK_WIDGET (gtk_builder_get_object (builder, "box"));
+  window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
+  content = gtk_bin_get_child (GTK_BIN (window));
   g_object_ref (content);
-  gtk_widget_unparent (content);
+  gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (content)),
+                        content);
+  gtk_widget_destroy (window);
   g_object_unref (builder);
 
   popover = create_popover (parent, content, GTK_POS_BOTTOM);
diff --git a/demos/gtk-demo/popover.ui b/demos/gtk-demo/popover.ui
index 33fabe6..0a70b47 100644
--- a/demos/gtk-demo/popover.ui
+++ b/demos/gtk-demo/popover.ui
@@ -40,7 +40,7 @@
       </row>
     </data>
   </object>
-  <object class="GtkWindow" id="window1">
+  <object class="GtkWindow" id="window">
     <property name="can_focus">False</property>
     <child>
       <object class="GtkBox" id="box">


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