Author: mkestner
Date: 2007-10-11 16:34:24 -0400 (Thu, 11 Oct 2007)
New Revision: 87356

Modified:
   branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog
   branches/gtk-sharp-2-468-branch/gtk-sharp/gconf/GConf/Value.cs
Log:

2007-10-11  Mike Kestner  <[EMAIL PROTECTED]>

        * gconf/GConf/Value.cs: Deal with zero length arrays gracefully.
        Thanks to Sebastian Dr?\195?\182ge <[EMAIL PROTECTED]> for a
        patch this one was derived from.  [Fixes #325516]


Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog 2007-10-11 19:52:20 UTC 
(rev 87355)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog 2007-10-11 20:34:24 UTC 
(rev 87356)
@@ -1,5 +1,11 @@
 2007-10-11  Mike Kestner  <[EMAIL PROTECTED]>
 
+       * gconf/GConf/Value.cs: Deal with zero length arrays gracefully.
+       Thanks to Sebastian Dröge <[EMAIL PROTECTED]> for a
+       patch this one was derived from.  [Fixes #325516]
+
+2007-10-11  Mike Kestner  <[EMAIL PROTECTED]>
+
        * glib/Object.cs: finalization and toggle ref rework.  Queue handles
        and ToggleRefs for disposal in finalizer instead of Object references.
        Not even sure how that worked.

Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gconf/GConf/Value.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gconf/GConf/Value.cs      
2007-10-11 19:52:20 UTC (rev 87355)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gconf/GConf/Value.cs      
2007-10-11 20:34:24 UTC (rev 87356)
@@ -58,17 +58,19 @@
                [DllImport("gconf-2")]
                static extern void gconf_value_set_bool (IntPtr value, bool 
data);
 
-               ValueType LookupType (object data)
+               ValueType LookupType (System.Type t)
                {
-                       if (data is string) {
+                       if (t.IsArray) {
+                               return ValueType.List;
+                       } else if (t == typeof (string)) {
                                return ValueType.String;
-                       } else if (data is int) {
+                       } else if (t == typeof (int)) {
                                return ValueType.Int;
-                       } else if (data is double) {
+                       } else if (t == typeof (double)) {
                                return ValueType.Float;
-                       } else if (data is bool) {
+                       } else if (t == typeof (bool)) {
                                return ValueType.Bool;
-                       } else if (data is ICollection) {
+                       } else if (t == typeof (ICollection)) {
                                return ValueType.List;
                        } else {
                                return ValueType.Invalid;
@@ -80,7 +82,7 @@
                        if (data == null)
                                throw new NullReferenceException ();
                        
-                       ValueType type = LookupType (data);
+                       ValueType type = LookupType (data.GetType ());
                        Set (data, type);
                }
 
@@ -129,8 +131,16 @@
                        GLib.SList list = new GLib.SList (IntPtr.Zero);
                        GC.SuppressFinalize (list);
 
+                       if (arr.Length == 0) {
+                               if (data is Array)
+                                       listType = LookupType (data.GetType 
().GetElementType ());
+                               else
+                                       throw new InvalidValueTypeException ();
+                               return list;
+                       }
+
                        foreach (object o in arr) {
-                               ValueType type = LookupType (o);
+                               ValueType type = LookupType (o.GetType ());
                                if (listType == ValueType.Invalid)
                                        listType = type;
 
@@ -254,7 +264,7 @@
 */
                public Value (object val)
                {
-                       Initialize (val, LookupType (val));
+                       Initialize (val, LookupType (val.GetType ()));
                }
                public bool Managed
                {

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

Reply via email to