* 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 <gna@advcsi.com>.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38236 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2014-12-07 16:38:40 +00:00
parent e587e3624e
commit c21c690727
3 changed files with 58 additions and 13 deletions

View file

@ -1,3 +1,10 @@
2014-12-07 Fred Kiefer <FredKiefer@gmx.de>
* 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 <gna@advcsi.com>.
2014-12-02 Fred Kiefer <FredKiefer@gmx.de> 2014-12-02 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSToolbarItem.m: Fix tool bar item tool tips. * Source/NSToolbarItem.m: Fix tool bar item tool tips.

View file

@ -122,14 +122,14 @@
@interface IBObjectRecord: NSObject @interface IBObjectRecord: NSObject
{ {
int objectID; id objectID;
id object; id object;
id children; id children;
id parent; id parent;
} }
- (id) object; - (id) object;
- (id) parent; - (id) parent;
- (NSInteger) objectID; - (id) objectID;
@end @end
@interface IBMutableOrderedSet: NSObject @interface IBMutableOrderedSet: NSObject
@ -137,7 +137,7 @@
NSArray *orderedObjects; NSArray *orderedObjects;
} }
- (NSArray *)orderedObjects; - (NSArray *)orderedObjects;
- (id) objectWithObjectID: (NSInteger)objID; - (id) objectWithObjectID: (id)objID;
@end @end
@interface IBObjectContainer: NSObject <NSCoding> @interface IBObjectContainer: NSObject <NSCoding>

View file

@ -404,8 +404,19 @@
{ {
ASSIGN(connection, [coder decodeObjectForKey: @"connection"]); 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"]) if ([coder containsValueForKey: @"connectionID"])
{ {
// PRE-4.6 XIBs....
connectionID = [coder decodeIntForKey: @"connectionID"]; connectionID = [coder decodeIntForKey: @"connectionID"];
} }
else if ([coder containsValueForKey: @"id"]) else if ([coder containsValueForKey: @"id"])
@ -413,8 +424,26 @@
// 4.6+ XIBs.... // 4.6+ XIBs....
NSString *string = [coder decodeObjectForKey: @"id"]; NSString *string = [coder decodeObjectForKey: @"id"];
if (string && [string isKindOfClass:[NSString class]] && [string length])
{
connectionID = [string intValue]; 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 else
{ {
@ -538,15 +567,24 @@
{ {
if ([coder containsValueForKey: @"objectID"]) if ([coder containsValueForKey: @"objectID"])
{ {
objectID = [coder decodeIntForKey: @"objectID"]; // PRE-4.6 XIBs....
objectID = [coder decodeObjectForKey: @"objectID"];
} }
else if ([coder containsValueForKey: @"id"]) else if ([coder containsValueForKey: @"id"])
{ {
// 4.6+ XIBs.... // 4.6+ XIBs....
NSString *string = [coder decodeObjectForKey: @"id"]; objectID = [coder decodeObjectForKey: @"id"];
objectID = [string intValue];
} }
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"]) if ([coder containsValueForKey: @"object"])
{ {
ASSIGN(object, [coder decodeObjectForKey: @"object"]); ASSIGN(object, [coder decodeObjectForKey: @"object"]);
@ -587,7 +625,7 @@
return parent; return parent;
} }
- (NSInteger) objectID - (id) objectID
{ {
return objectID; return objectID;
} }
@ -633,7 +671,7 @@
return orderedObjects; return orderedObjects;
} }
- (id) objectWithObjectID: (NSInteger)objID - (id) objectWithObjectID: (id)objID
{ {
NSEnumerator *en; NSEnumerator *en;
IBObjectRecord *obj; IBObjectRecord *obj;
@ -641,7 +679,7 @@
en = [orderedObjects objectEnumerator]; en = [orderedObjects objectEnumerator];
while ((obj = [en nextObject]) != nil) while ((obj = [en nextObject]) != nil)
{ {
if ([obj objectID] == objID) if ([[obj objectID] isEqual:objID])
{ {
return [obj object]; return [obj object];
} }
@ -715,7 +753,7 @@
return [[objectRecords orderedObjects] objectEnumerator]; return [[objectRecords orderedObjects] objectEnumerator];
} }
- (NSDictionary*) propertiesForObjectID: (int)objectID - (NSDictionary*) propertiesForObjectID: (id)objectID
{ {
NSEnumerator *en; NSEnumerator *en;
NSString *idString; NSString *idString;
@ -723,7 +761,7 @@
NSMutableDictionary *properties; NSMutableDictionary *properties;
int idLength; int idLength;
idString = [NSString stringWithFormat: @"%d.", objectID]; idString = [NSString stringWithFormat: @"%@.", objectID];
idLength = [idString length]; idLength = [idString length];
properties = [[NSMutableDictionary alloc] init]; properties = [[NSMutableDictionary alloc] init];
en = [flattenedProperties keyEnumerator]; en = [flattenedProperties keyEnumerator];