Author: jackson
Date: 2007-10-10 11:13:32 -0400 (Wed, 10 Oct 2007)
New Revision: 87274

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/xaml.cpp
Log:

        * xaml.cpp: Don't allow the same property to be set twice.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-10-10 15:11:30 UTC (rev 87273)
+++ trunk/moon/src/ChangeLog    2007-10-10 15:13:32 UTC (rev 87274)
@@ -1,3 +1,7 @@
+2007-10-10  Jackson Harper  <[EMAIL PROTECTED]>
+
+       * xaml.cpp: Don't allow the same property to be set twice.
+
 2007-10-09  Jackson Harper  <[EMAIL PROTECTED]>
 
        * xaml.cpp: When we create custom elements we also need to set the

Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp     2007-10-10 15:11:30 UTC (rev 87273)
+++ trunk/moon/src/xaml.cpp     2007-10-10 15:13:32 UTC (rev 87274)
@@ -87,10 +87,11 @@
        int element_type;
        DependencyObject *item;
 
+       GHashTable *set_properties;
 
        XamlElementInstance (XamlElementInfo *info) : element_name (NULL), 
instance_name (NULL),
                                                      info (info), parent 
(NULL), element_type (UNKNOWN),
-                                                     item (NULL)
+                                                     item (NULL), 
set_properties (NULL)
        {
                children = new List ();
        }
@@ -99,11 +100,31 @@
        {
                children->Clear (true);
                delete children;
+
+               if (set_properties)
+                       g_hash_table_destroy (set_properties);
+
                // if (instance_name)
                //      delete instance_name;
                // if (element_name && element_type == PROPERTY)
                //      delete element_name;
        }
+
+       bool IsPropertySet (const char *name)
+       {
+               if (!set_properties)
+                       return false;
+
+               return g_hash_table_lookup (set_properties, name) != NULL;
+       }
+
+       void MarkPropertyAsSet (char *name, DependencyObject *value)
+       {
+               if (!set_properties)
+                       set_properties = g_hash_table_new (g_str_hash, 
g_str_equal);
+
+               g_hash_table_insert (set_properties, name, value);
+       }
 };
 
 void 
@@ -2277,8 +2298,15 @@
        if (prop) {
                if (is_instance_of (value, prop->value_type)) {
                        // an empty collection can be NULL and valid
-                       if (value->item)
-                               dep->SetValue (prop, Value ((DependencyObject 
*) value->item));
+                       if (value->item) {
+                               if (item->IsPropertySet (prop->name)) {
+                                       parser_error (p, item->element_name, 
NULL,
+                                               g_strdup_printf ("Attempting to 
set property '%s' twice\n", prop->name));
+                               } else {
+                                       dep->SetValue (prop, Value 
(value->item));
+                                       item->MarkPropertyAsSet (prop->name, 
value->item);
+                               }
+                       }
                } else {
                        // TODO: Do some error checking in here, this is a 
valid place to be
                        // if we are adding a non collection to a collection, 
so the non collection

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to