[gtk+/popovers: 31/33] gtk-demo: Fix crash after running popovers demo
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/popovers: 31/33] gtk-demo: Fix crash after running popovers demo
- Date: Fri, 10 Jan 2014 15:17:34 +0000 (UTC)
commit 619fc2d4248566169421616d300d7bccab7018bd
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]