Author: lluis
Date: 2008-01-23 18:54:02 -0500 (Wed, 23 Jan 2008)
New Revision: 93742

Modified:
   trunk/gtk-sharp/ChangeLog
   trunk/gtk-sharp/glade/XML.custom
Log:
2008-01-24  Lluis Sanchez Gual  <[EMAIL PROTECTED]>
 
        * glade/XML.custom: due to a recent Mono fix (bug #322762),
          Type.GetFields does not return private fields from base classes
          anymore, so the BindFields now has to go through the class
          hierarchy to get all fields.



Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog   2008-01-23 23:51:27 UTC (rev 93741)
+++ trunk/gtk-sharp/ChangeLog   2008-01-23 23:54:02 UTC (rev 93742)
@@ -1,3 +1,10 @@
+2008-01-24  Lluis Sanchez Gual  <[EMAIL PROTECTED]>
+ 
+       * glade/XML.custom: due to a recent Mono fix (bug #322762),
+         Type.GetFields does not return private fields from base classes
+         anymore, so the BindFields now has to go through the class
+         hierarchy to get all fields.
+
 2008-01-23  Mike Kestner  <[EMAIL PROTECTED]>
 
        * bootstrap-2.12: update version and tag 2.11.91.

Modified: trunk/gtk-sharp/glade/XML.custom
===================================================================
--- trunk/gtk-sharp/glade/XML.custom    2008-01-23 23:51:27 UTC (rev 93741)
+++ trunk/gtk-sharp/glade/XML.custom    2008-01-23 23:54:02 UTC (rev 93742)
@@ -352,38 +352,42 @@
 
                private void BindFields (object target, Type type)
                {
-                       System.Reflection.BindingFlags flags = 
System.Reflection.BindingFlags.Public | 
System.Reflection.BindingFlags.NonPublic;
+                       System.Reflection.BindingFlags flags = 
System.Reflection.BindingFlags.Public | 
System.Reflection.BindingFlags.NonPublic | 
System.Reflection.BindingFlags.DeclaredOnly;
                        if (target != null)
                                flags |= 
System.Reflection.BindingFlags.Instance;
                        else
                                flags |= System.Reflection.BindingFlags.Static;
                        
-                       System.Reflection.FieldInfo[] fields = type.GetFields 
(flags);
-                       if (fields == null)
-                               return;
-                       
-                       foreach (System.Reflection.FieldInfo field in fields)
-                       {
-                               object[] attrs = field.GetCustomAttributes 
(typeof (WidgetAttribute), false);
-                               if (attrs == null || attrs.Length == 0)
-                                       continue;
-                               // The widget to field binding must be 1:1, so 
only check
-                               // the first attribute.
-                               WidgetAttribute attr = (WidgetAttribute) 
attrs[0];
-                               Gtk.Widget widget;
-                               if (attr.Specified) 
-                                       widget = GetWidget (attr.Name);
-                               else 
-                                       widget = GetWidget (field.Name);
+                       do {
+                               System.Reflection.FieldInfo[] fields = 
type.GetFields (flags);
+                               if (fields == null)
+                                       return;
+                               
+                               foreach (System.Reflection.FieldInfo field in 
fields)
+                               {
+                                       object[] attrs = 
field.GetCustomAttributes (typeof (WidgetAttribute), false);
+                                       if (attrs == null || attrs.Length == 0)
+                                               continue;
+                                       // The widget to field binding must be 
1:1, so only check
+                                       // the first attribute.
+                                       WidgetAttribute attr = 
(WidgetAttribute) attrs[0];
+                                       Gtk.Widget widget;
+                                       if (attr.Specified) 
+                                               widget = GetWidget (attr.Name);
+                                       else 
+                                               widget = GetWidget (field.Name);
 
-                               if (widget != null)
-                                       try {
-                                               field.SetValue (target, widget, 
flags, null, null);
-                                       } catch (Exception e) {
-                                               Console.WriteLine ("Unable to 
set value for field " + field.Name);
-                                               throw e;
-                                       }
+                                       if (widget != null)
+                                               try {
+                                                       field.SetValue (target, 
widget, flags, null, null);
+                                               } catch (Exception e) {
+                                                       Console.WriteLine 
("Unable to set value for field " + field.Name);
+                                                       throw e;
+                                               }
+                               }
+                               type = type.BaseType;
                        }
+                       while (type != typeof(object) && type != null);
                }
                
                public void BindFields (object target)

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

Reply via email to