Minor fix for loading nibs

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5795 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-01-17 07:18:42 +00:00
parent fff420f2ef
commit e52de6929e
2 changed files with 37 additions and 25 deletions

View file

@ -1,3 +1,8 @@
Mon Jan 17 6:32:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSBundleAdditions.m: Catch exceptions when loading nib so
we simply return YES or NO. Fix suggested by karl@nfox.com
Sun Jan 16 8:57:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Sun Jan 16 8:57:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSWindow.m: Don't log DnD stuff unless NSDragging logging * Source/NSWindow.m: Don't log DnD stuff unless NSDragging logging

View file

@ -201,42 +201,49 @@
externalNameTable: (NSDictionary *)context externalNameTable: (NSDictionary *)context
withZone: (NSZone *)zone withZone: (NSZone *)zone
{ {
NSData *data;
BOOL loaded = NO; BOOL loaded = NO;
NSUnarchiver *unarchiver = nil;
data = [NSData dataWithContentsOfFile: fileName]; NS_DURING
if (data != nil)
{ {
NSUnarchiver *unarchiver; NSData *data = [NSData dataWithContentsOfFile: fileName];
unarchiver = [[NSUnarchiver alloc] initForReadingWithData: data]; if (data != nil)
if (unarchiver != nil)
{ {
id obj; unarchiver = [[NSUnarchiver alloc] initForReadingWithData: data];
if (unarchiver != nil)
[unarchiver setObjectZone: zone];
obj = [unarchiver decodeObject];
if (obj != nil)
{ {
if ([obj isKindOfClass: [GSNibContainer class]]) id obj;
[unarchiver setObjectZone: zone];
obj = [unarchiver decodeObject];
if (obj != nil)
{ {
[obj awakeWithContext: context]; if ([obj isKindOfClass: [GSNibContainer class]])
/* {
* Ok - it's all done now - just retain the nib container [obj awakeWithContext: context];
* so tthat it will not be released when the unarchiver /*
* is released, and the nib contents will persist. *Ok - it's all done now - just retain the nib container
*/ *so that it will not be released when the unarchiver
RETAIN(obj); *is released, and the nib contents will persist.
loaded = YES; */
} RETAIN(obj);
else loaded = YES;
{ }
NSLog(@"Nib '%@' without container object!", fileName); else
{
NSLog(@"Nib '%@' without container object!", fileName);
}
} }
RELEASE(unarchiver);
} }
RELEASE(unarchiver);
} }
} }
NS_HANDLER
{
TEST_RELEASE(unarchiver);
}
NS_ENDHANDLER
return loaded; return loaded;
} }