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.
This commit is contained in:
Carlos Garnacho 2014-01-10 14:07:44 +01:00
parent 31042fe95f
commit 7e30b82aee
2 changed files with 7 additions and 4 deletions

View File

@ -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);

View File

@ -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">