Author: jackson
Date: 2007-11-09 10:15:45 -0500 (Fri, 09 Nov 2007)
New Revision: 89320

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

        * xaml.cpp: Rework to allow unparented properties.
        * createFromXaml
        ("<Canvas.Background><SolidColorBrush></Canvas.Background") will
        basically ignore the property and will return the
SolidColorBrush
        as the top element. This fixes 335865.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-11-09 15:14:03 UTC (rev 89319)
+++ trunk/moon/src/ChangeLog    2007-11-09 15:15:45 UTC (rev 89320)
@@ -1,3 +1,10 @@
+2007-11-09  Jackson Harper  <[EMAIL PROTECTED]>
+
+       * xaml.cpp: Rework to allow unparented properties.  createFromXaml
+       ("<Canvas.Background><SolidColorBrush></Canvas.Background") will
+       basically ignore the property and will return the SolidColorBrush
+       as the top element. This fixes 335865.
+
 2007-11-08  Chris Toshok  <[EMAIL PROTECTED]>
 
        [ may go a long way toward fixing #337714, if it doesn't fix it

Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp     2007-11-09 15:14:03 UTC (rev 89319)
+++ trunk/moon/src/xaml.cpp     2007-11-09 15:15:45 UTC (rev 89320)
@@ -789,8 +789,6 @@
                return;
 
        if (elem) {
-               bool set_top = false;
-
                inst = elem->create_element (p, elem);
 
                if (!inst)
@@ -807,10 +805,7 @@
                        return;
 
                if (!p->top_element) {
-                       set_top = true;
-
                        p->top_element = inst;
-                       p->current_element = inst;
                        NameScope::SetNameScope (inst->item, p->namescope);
                } else {
                        DependencyObject *parent = get_parent 
(p->current_element);
@@ -825,17 +820,9 @@
                if (!inst->item)
                        return;
 
-               if (set_top)
-                       return;
+               if (p->current_element && p->current_element->info)
+                       p->current_element->info->add_child (p, 
p->current_element, inst);
 
-               if (p->current_element) {
-
-                       if (p->current_element->info)
-                               p->current_element->info->add_child (p, 
p->current_element, inst);
-                       else
-                               g_warning ("attempt to set property of 
unimplemented type: %s\n", p->current_element->element_name);
-               }
-
        } else {
                bool property = false;
                for (int i = 0; el [i]; i++) {
@@ -847,7 +834,11 @@
 
                if (property) {
                        inst = new XamlElementInstance (NULL);
-                       inst->info = p->current_element->info; // We copy this 
from our parent
+
+                       if (p->current_element)
+                               inst->info = p->current_element->info;
+                       else
+                               inst->info = NULL;
                        inst->element_name = g_strdup (el);
                        inst->element_type = XamlElementInstance::PROPERTY;
                } else {
@@ -857,7 +848,10 @@
        }
 
        inst->parent = p->current_element;
-       p->current_element->children->Append (inst);
+
+       if (p->current_element) {
+               p->current_element->children->Append (inst);
+       }
        p->current_element = inst;      
 }
 
@@ -865,14 +859,15 @@
 flush_char_data (XamlParserInfo *p, bool start)
 {
        DependencyProperty *content;
-       const char *prop_name;
+       const char *prop_name = NULL;
        Type::Kind prop_type;
        
        if (!p->has_cdata || !p->current_element)
                return;
+
+       if (p->current_element->info)
+               prop_name = p->current_element->info->content_property;
        
-       prop_name = p->current_element->info->content_property;
-       
        if (!prop_name && p->cdata) {
                char *err = g_strdup_printf ("%s does not support text 
content.", p->current_element->element_name);
                parser_error (p, NULL, NULL, 2011, err);
@@ -985,7 +980,8 @@
                List::Node *walk = info->current_element->children->First ();
                while (walk) {
                        XamlElementInstance *child = (XamlElementInstance *) 
walk;
-                       info->current_element->parent->info->set_property 
(info, info->current_element->parent, info->current_element, child);
+                       if (info->current_element->parent)
+                               
info->current_element->parent->info->set_property (info, 
info->current_element->parent, info->current_element, child);
                        walk = walk->next;
                }
                break;

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

Reply via email to