[glade3] * gladeui/glade-widget.c: Check if object is actually in the parent when rebuilding (for setting



commit 2d5ae42887c4640e36c64c02b4c0dc6d2d537dd8
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Thu Dec 23 12:26:50 2010 +0900

    	* gladeui/glade-widget.c: Check if object is actually in the parent when rebuilding
    	  (for setting construct properties during a load process).

 gladeui/glade-widget.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 1a82e47..a34b3dc 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -2320,7 +2320,7 @@ glade_widget_rebuild (GladeWidget *gwidget)
 	GObject            *new_object, *old_object;
 	GladeWidgetAdaptor *adaptor;
 	GList              *children;
-	gboolean            reselect = FALSE, inproject;
+	gboolean            reselect = FALSE, inproject, inparent;
 	GList              *restore_properties = NULL;
 	GList              *save_properties, *l;
 	
@@ -2393,8 +2393,15 @@ glade_widget_rebuild (GladeWidget *gwidget)
 	glade_widget_adaptor_post_create (adaptor, new_object, GLADE_CREATE_REBUILD);
 
 	/* Replace old object with new object in parent
+	 * (this can happen during construction before the object is actually
+	 * added to the parent but the parent pointer is set).
 	 */
-	if (gwidget->parent)
+
+	inparent = (gwidget->parent &&
+		    glade_widget_adaptor_has_child (gwidget->parent->adaptor, 
+						    gwidget->parent->object, 
+						    old_object));
+	if (inparent)
 		glade_widget_replace (gwidget->parent,
 				      old_object, new_object);
 
@@ -2438,7 +2445,7 @@ glade_widget_rebuild (GladeWidget *gwidget)
 
 	/* Sync packing.
 	 */
-	if (gwidget->parent)
+	if (inparent)
 		glade_widget_sync_packing_props (gwidget);
 
 	/* If the widget was in a project (and maybe the selection), then



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