Author: fredkiefer
Date: Sun Dec  7 17:38:40 2014
New Revision: 38236

URL: http://svn.gna.org/viewcvs/gnustep?rev=38236&view=rev
Log:
        * Headers/Additions/GNUstepGUI/GSXibLoading.h,
        * Source/GSXibLoader.m: Fix object ID parsing in XIB loading due
        to Apple moving to string ID represenatation.
        Patch by Marcian Lytwyn <[email protected]>.

Modified:
    libs/gui/trunk/ChangeLog
    libs/gui/trunk/Headers/Additions/GNUstepGUI/GSXibLoading.h
    libs/gui/trunk/Source/GSXibLoader.m

Modified: libs/gui/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=38236&r1=38235&r2=38236&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog    (original)
+++ libs/gui/trunk/ChangeLog    Sun Dec  7 17:38:40 2014
@@ -1,3 +1,10 @@
+2014-12-07  Fred Kiefer <[email protected]>
+
+       * Headers/Additions/GNUstepGUI/GSXibLoading.h,
+       * Source/GSXibLoader.m: Fix object ID parsing in XIB loading due
+       to Apple moving to string ID represenatation.
+       Patch by Marcian Lytwyn <[email protected]>.
+
 2014-12-02  Fred Kiefer <[email protected]>
 
        * Source/NSToolbarItem.m: Fix tool bar item tool tips.

Modified: libs/gui/trunk/Headers/Additions/GNUstepGUI/GSXibLoading.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Headers/Additions/GNUstepGUI/GSXibLoading.h?rev=38236&r1=38235&r2=38236&view=diff
==============================================================================
--- libs/gui/trunk/Headers/Additions/GNUstepGUI/GSXibLoading.h  (original)
+++ libs/gui/trunk/Headers/Additions/GNUstepGUI/GSXibLoading.h  Sun Dec  7 
17:38:40 2014
@@ -122,14 +122,14 @@
 
 @interface IBObjectRecord: NSObject
 {
-  int objectID;
+  id objectID;
   id object;
   id children;
   id parent;
 }
 - (id) object;
 - (id) parent;
-- (NSInteger) objectID;
+- (id) objectID;
 @end
 
 @interface IBMutableOrderedSet: NSObject
@@ -137,7 +137,7 @@
   NSArray *orderedObjects;
 }
 - (NSArray *)orderedObjects;
-- (id) objectWithObjectID: (NSInteger)objID;
+- (id) objectWithObjectID: (id)objID;
 @end
 
 @interface IBObjectContainer: NSObject <NSCoding>

Modified: libs/gui/trunk/Source/GSXibLoader.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/GSXibLoader.m?rev=38236&r1=38235&r2=38236&view=diff
==============================================================================
--- libs/gui/trunk/Source/GSXibLoader.m (original)
+++ libs/gui/trunk/Source/GSXibLoader.m Sun Dec  7 17:38:40 2014
@@ -404,8 +404,19 @@
         {
           ASSIGN(connection, [coder decodeObjectForKey: @"connection"]);
         }
+      else
+        {
+          NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ 
without a connection ID",
+                              __PRETTY_FUNCTION__,
+                              NSStringFromClass([self class])];
+          [NSException raise: NSInvalidArgumentException
+                      format: format];
+        }
+      
+      // Load the connection ID....
       if ([coder containsValueForKey: @"connectionID"])
         {
+          // PRE-4.6 XIBs....
           connectionID = [coder decodeIntForKey: @"connectionID"];
         }
       else if ([coder containsValueForKey: @"id"])
@@ -413,7 +424,25 @@
           // 4.6+ XIBs....
           NSString *string = [coder decodeObjectForKey: @"id"];
 
-          connectionID = [string intValue];
+          if (string && [string isKindOfClass:[NSString class]] && [string 
length])
+            {
+              connectionID = [string intValue];
+            }
+          else
+            {
+              NSString *format = [NSString stringWithFormat:@"%s:class: %@ - 
connection ID is missing or zero!",
+                                  __PRETTY_FUNCTION__, NSStringFromClass([self 
class])];
+              [NSException raise: NSInvalidArgumentException
+                          format: format];
+            }
+        }
+      else
+        {
+          NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ 
without a connection ID",
+                              __PRETTY_FUNCTION__,
+                              NSStringFromClass([self class])];
+          [NSException raise: NSInvalidArgumentException
+                      format: format];
         }
     }
   else
@@ -538,15 +567,24 @@
     {
       if ([coder containsValueForKey: @"objectID"])
         {
-          objectID = [coder decodeIntForKey: @"objectID"];
+          // PRE-4.6 XIBs....
+          objectID = [coder decodeObjectForKey: @"objectID"];
         }
       else if ([coder containsValueForKey: @"id"])
         {
           // 4.6+ XIBs....
-          NSString *string = [coder decodeObjectForKey: @"id"];
-
-          objectID = [string intValue];
-        }
+          objectID = [coder decodeObjectForKey: @"id"];
+        }
+      else
+        {
+          // Cannot process without object ID...
+          NSString *format = [NSString stringWithFormat:@"%s:Can't decode %@ 
without an object ID",
+                              __PRETTY_FUNCTION__,
+                              NSStringFromClass([self class])];
+          [NSException raise: NSInvalidArgumentException
+                      format: format];
+        }
+      
       if ([coder containsValueForKey: @"object"])
         {
           ASSIGN(object, [coder decodeObjectForKey: @"object"]);
@@ -587,7 +625,7 @@
   return parent;
 }
 
-- (NSInteger) objectID
+- (id) objectID
 {
   return objectID;
 }
@@ -633,7 +671,7 @@
   return orderedObjects;
 }
 
-- (id) objectWithObjectID: (NSInteger)objID
+- (id) objectWithObjectID: (id)objID
 {
   NSEnumerator *en;
   IBObjectRecord *obj;
@@ -641,7 +679,7 @@
   en = [orderedObjects objectEnumerator];
   while ((obj = [en nextObject]) != nil)
     {
-      if ([obj objectID] == objID)
+      if ([[obj objectID] isEqual:objID])
         {
           return [obj object];
         }
@@ -715,7 +753,7 @@
   return [[objectRecords orderedObjects] objectEnumerator];
 }
 
-- (NSDictionary*) propertiesForObjectID: (int)objectID
+- (NSDictionary*) propertiesForObjectID: (id)objectID
 {
   NSEnumerator *en;
   NSString *idString;
@@ -723,7 +761,7 @@
   NSMutableDictionary *properties;
   int idLength;
 
-  idString = [NSString stringWithFormat: @"%d.", objectID];
+  idString = [NSString stringWithFormat: @"%@.", objectID];
   idLength = [idString length];
   properties = [[NSMutableDictionary alloc] init];
   en = [flattenedProperties keyEnumerator];


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to