[glade/glade-3-16] glade_project_remove_object() check if object has a GladeWidget first since its cheaper and issue a



commit 0119bf2dead490d2f763794fb169682a21195fa4
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Wed Sep 11 16:12:59 2013 -0300

    glade_project_remove_object() check if object has a GladeWidget first since its cheaper
    and issue a warning if we have an object in the project without a GladeWidget.

 gladeui/glade-project.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 5d8d9ef..1f427ef 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -3731,15 +3731,25 @@ glade_project_remove_object (GladeProject *project, GObject *object)
   g_return_if_fail (GLADE_IS_PROJECT (project));
   g_return_if_fail (G_IS_OBJECT (object));
 
-  if (!glade_project_has_object (project, object))
-    return;
-
   if (GLADE_IS_PLACEHOLDER (object))
     return;
 
   if ((gwidget = glade_widget_get_from_gobject (object)) == NULL)
-    return;
+    {
+      if (g_list_find (project->priv->objects, object))
+        {
+          project->priv->tree = g_list_remove_all (project->priv->tree, object);
+          project->priv->objects = g_list_remove_all (project->priv->objects, object);
+          project->priv->selection = g_list_remove_all (project->priv->selection, object);
+          g_warning ("Internal data model error, removing object %p %s without a GladeWidget wrapper",
+                     object, G_OBJECT_TYPE_NAME (object));
+        }
+      return;
+    }
 
+  if (!glade_project_has_object (project, object))
+    return;
+  
   /* Recurse and remove deepest children first */
   if ((children = glade_widget_get_children (gwidget)) != NULL)
     {


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