From 52d1488ad654b975b5c966433e111db90ccef716 Mon Sep 17 00:00:00 2001 From: Fred Kiefer Date: Fri, 13 Dec 2013 20:34:52 +0000 Subject: [PATCH] * Source/GSXibLoader.m: Handle changed keys for XIB 4.6 format. Based on patch by Marcian Lytwyn . * Source/GSXibLoader.m (-parser:...): Warn about unsupported XIB 5 format. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37463 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/GSXibLoader.m | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6beece843..79c5f65fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-12-13 Fred Kiefer + + * Source/GSXibLoader.m: Handle changed keys for XIB 4.6 format. + Based on patch by Marcian Lytwyn . + * Source/GSXibLoader.m (-parser:...): Warn about unsupported XIB 5 format. + 2013-12-13 Fred Kiefer * Source/NSTableView.m (-numberOfRows): Return the current number diff --git a/Source/GSXibLoader.m b/Source/GSXibLoader.m index 792649667..27aad6bc3 100644 --- a/Source/GSXibLoader.m +++ b/Source/GSXibLoader.m @@ -405,6 +405,13 @@ { connectionID = [coder decodeIntForKey: @"connectionID"]; } + else if ([coder containsValueForKey: @"id"]) + { + // 4.6+ XIBs.... + NSString *string = [coder decodeObjectForKey: @"id"]; + + connectionID = [string intValue]; + } } else { @@ -530,6 +537,13 @@ { objectID = [coder decodeIntForKey: @"objectID"]; } + else if ([coder containsValueForKey: @"id"]) + { + // 4.6+ XIBs.... + NSString *string = [coder decodeObjectForKey: @"id"]; + + objectID = [string intValue]; + } if ([coder containsValueForKey: @"object"]) { ASSIGN(object, [coder decodeObjectForKey: @"object"]); @@ -1122,14 +1136,24 @@ while ((key = [en nextObject]) != nil) { NSString *keyValue = [key stringByReplacingOccurrencesOfString:@".CustomClassName" withString:@""]; - NSString *className = [customClassDict objectForKey:key]; + NSString *className = [customClassDict objectForKey: key]; NSString *objectRecordXpath = nil; - objectRecordXpath = [NSString stringWithFormat:@"//object[@class=\"IBObjectRecord\"]/" + objectRecordXpath = [NSString stringWithFormat: @"//object[@class=\"IBObjectRecord\"]/" @"int[@key=\"objectID\"][text()=\"%@\"]/../reference", keyValue]; - objectRecords = [document nodesForXPath:objectRecordXpath error:NULL]; + objectRecords = [document nodesForXPath: objectRecordXpath error: NULL]; + + if (objectRecords == nil) + { + // If that didn't work then it could be a 4.6+ XIB... + objectRecordXpath = [NSString stringWithFormat: @"//object[@class=\"IBObjectRecord\"]/" + @"string[@key=\"id\"][text()=\"%@\"]/../reference", + keyValue]; + objectRecords = [document nodesForXPath: objectRecordXpath error: NULL]; + } + NSString *refId = nil; if ([objectRecords count] > 0) { @@ -1257,6 +1281,12 @@ didStartElement: (NSString*)elementName // FIXME: We should use proper memory management here AUTORELEASE(element); + if ([@"document" isEqualToString: elementName]) + { + [NSException raise: NSInvalidArgumentException + format: @"Cannot decode XIB 5 format."]; + } + if (key != nil) { [currentElement setElement: element forKey: key];