[gtk+/gtkbuilder-gbinding: 99/101] Check for conflicting <binding>/<property> elements



commit 3dd2c6f4e314e0e8835007c0f9365aaf9b1f21b4
Author: Denis Washington <denisw online de>
Date:   Wed Feb 15 22:36:01 2012 +0100

    Check for conflicting <binding>/<property> elements

 gtk/gtkbuilderparser.c |   59 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index d966c7b..02826bb 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -1052,6 +1052,49 @@ end_element (GMarkupParseContext *context,
     {
       ObjectInfo *object_info = state_pop_info (data, ObjectInfo);
       ChildInfo* child_info = state_peek_info (data, ChildInfo);
+      GSList *l;
+
+      /* Check for conflicting property binding definitions and
+       * conflicts between property binding and value definitions.
+       */
+      for (l = object_info->bindings; l; l = l->next)
+        {
+          BindingInfo *b = (BindingInfo*)l->data;
+          GSList *l2;
+
+          for (l2 = object_info->bindings; l2; l2 = l2->next)
+            {
+              BindingInfo *b2 = (BindingInfo*)l2->data;
+              if (b != b2 && !strcmp (b->to, b2->to))
+                {
+                  g_set_error (error,
+                               GTK_BUILDER_ERROR,
+                               GTK_BUILDER_ERROR_INVALID_VALUE,
+                               "Duplicate binding for property: `%s'",
+                               b->to);
+                  break;
+                }
+            }
+
+          /* If we broke out of the last loop, we already found an error */
+          if (l2)
+            break;
+
+          for (l2 = object_info->properties; l2; l2 = l2->next)
+            {
+              PropertyInfo *p = (PropertyInfo*)l2->data;
+              if (!strcmp (b->to, p->name))
+                {
+                  g_set_error (error,
+                               GTK_BUILDER_ERROR,
+                               GTK_BUILDER_ERROR_INVALID_VALUE,
+                               "Value supplied for property defined as "
+                               "bound: `%s'",
+                               b->to);
+                  break;
+                }
+            }
+        }
 
       if (data->requested_objects && data->inside_requested_object &&
           (data->cur_object_level == data->requested_object_level))
@@ -1132,21 +1175,7 @@ end_element (GMarkupParseContext *context,
     {
       BindingInfo *binding_info = state_pop_info (data, BindingInfo);
       ObjectInfo *object_info = (ObjectInfo*)state_peek_info (data, CommonInfo);
-      GSList *l;
-      
-      for (l = object_info->bindings; l; l = l->next)
-        {
-          BindingInfo *b = (BindingInfo*)l->data;
-          if (!strcmp (b->to, binding_info->to))
-            {
-              g_set_error (error,
-                           GTK_BUILDER_ERROR,
-                           GTK_BUILDER_ERROR_INVALID_VALUE,
-                           "Duplicate binding for property: `%s'",
-                           b->to);
-            }
-        }
-      
+
       binding_info->object_name = g_strdup (object_info->id);
       object_info->bindings =
         g_slist_prepend (object_info->bindings, binding_info);



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