Fix to prevent a problem in unarchiving from crashing the app.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21134 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-04-21 03:04:08 +00:00
parent d71b1e88b8
commit 564893d37a
3 changed files with 24 additions and 6 deletions

View file

@ -1,3 +1,10 @@
2005-04-20 23:00 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormObjectEditor.m: Added copyright information.
* GormLib/IBResourceManager.m: Added exception handling to prevent
a problem unarchiving an object from the pasteboard from crashing
the app.
2005-04-20 21:51 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormClassManager.m: Restrict instantiation of NSView and

View file

@ -1,7 +1,9 @@
/* GormObjectEditor.m
*
* Copyright (C) 1999 Free Software Foundation, Inc.
* Copyright (C) 1999,2002,2003,2004,2005 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 2002,2003,2004,2005
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
* Date: 1999
*

View file

@ -28,10 +28,11 @@
#include <Foundation/NSArchiver.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSEnumerator.h>
#include <Foundation/NSException.h>
#include <Foundation/NSMapTable.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSString.h>
#include <Foundation/NSNull.h>
#include <Foundation/NSString.h>
#include <AppKit/NSPasteboard.h>
NSString *IBResourceManagerRegistryDidChangeNotification = @"IBResourceManagerRegistryDidChangeNotification";
@ -152,12 +153,20 @@ static NSMapTable *_resourceManagers = NULL;
NSData *data = [pboard dataForType: type];
if(data != nil)
{
id obj = [NSUnarchiver unarchiveObjectWithData: data];
if(obj != nil)
NS_DURING
{
// the object is an array of objects of this type.
[self addResources: obj];
id obj = [NSUnarchiver unarchiveObjectWithData: data];
if(obj != nil)
{
// the object is an array of objects of this type.
[self addResources: obj];
}
}
NS_HANDLER
{
NSLog(@"Problem adding resource: %@",[localException reason]);
}
NS_ENDHANDLER;
}
}
}