Added code to conditionally call desig. init. if it is defined on current class (only not parents).

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@17572 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2003-08-30 05:01:47 +00:00
parent d323f62b6c
commit ea85bcccb7
2 changed files with 55 additions and 37 deletions

View file

@ -1,3 +1,10 @@
2003-08-30 Gregory John Casamento <greg_casamento@yahoo.com>
* GSNibTemplates.m: Added code to templates to conditionally
call the designated initializer if and only if it is defined
on the class which is being unarchived, not the parent classes.
This is consistent with behaviour under OpenStep.
2003-08-29 Adam Fedor <fedor@gnu.org> 2003-08-29 Adam Fedor <fedor@gnu.org>
* Source/GNUmakefile.preamble (ADDITIONAL_OBJCFLAGS): Include * Source/GNUmakefile.preamble (ADDITIONAL_OBJCFLAGS): Include

View file

@ -56,6 +56,7 @@
#include <AppKit/NSNibLoading.h> #include <AppKit/NSNibLoading.h>
#include <AppKit/NSNibConnector.h> #include <AppKit/NSNibConnector.h>
#include <AppKit/NSApplication.h> #include <AppKit/NSApplication.h>
#include <GNUstepBase/GSObjCRuntime.h>
#include <GNUstepGUI/GSNibTemplates.h> #include <GNUstepGUI/GSNibTemplates.h>
static const int currentVersion = 1; // GSNibItem version number... static const int currentVersion = 1; // GSNibItem version number...
@ -415,14 +416,6 @@ static const int currentVersion = 1; // GSNibItem version number...
return _className; return _className;
} }
/*
- (void) dealloc
{
RELEASE(_className);
[super dealloc];
}
*/
- (id) initWithCoder: (NSCoder *)coder - (id) initWithCoder: (NSCoder *)coder
{ {
id obj = nil; id obj = nil;
@ -510,6 +503,8 @@ static const int currentVersion = 1; // GSNibItem version number...
[coder decodeValueOfObjCType: @encode(BOOL) at: &_deferFlag]; [coder decodeValueOfObjCType: @encode(BOOL) at: &_deferFlag];
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{
if(GSGetInstanceMethodNotInherited([obj class], @selector(initWithContentRect:styleMask:backing:defer:)) != NULL)
{ {
// if we are not in interface builder, call // if we are not in interface builder, call
// designated initializer per spec... // designated initializer per spec...
@ -522,6 +517,7 @@ static const int currentVersion = 1; // GSNibItem version number...
// set the content view back // set the content view back
[obj setContentView: contentView]; [obj setContentView: contentView];
} }
}
RELEASE(self); RELEASE(self);
} }
return obj; return obj;
@ -549,10 +545,13 @@ static const int currentVersion = 1; // GSNibItem version number...
if(obj != nil) if(obj != nil)
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{
if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithFrame:)) != NULL)
{ {
NSRect theFrame = [obj frame]; NSRect theFrame = [obj frame];
obj = [obj initWithFrame: theFrame]; obj = [obj initWithFrame: theFrame];
} }
}
RELEASE(self); RELEASE(self);
} }
return obj; return obj;
@ -575,10 +574,13 @@ static const int currentVersion = 1; // GSNibItem version number...
if(obj != nil) if(obj != nil)
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{
if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithFrame:)) != NULL)
{ {
NSRect theFrame = [obj frame]; NSRect theFrame = [obj frame];
obj = [obj initWithFrame: theFrame]; obj = [obj initWithFrame: theFrame];
} }
}
RELEASE(self); RELEASE(self);
} }
return obj; return obj;
@ -601,12 +603,15 @@ static const int currentVersion = 1; // GSNibItem version number...
if(obj != nil) if(obj != nil)
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{
if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithFrame:textContainer:)) != NULL)
{ {
NSRect theFrame = [obj frame]; NSRect theFrame = [obj frame];
id textContainer = [obj textContainer]; id textContainer = [obj textContainer];
obj = [obj initWithFrame: theFrame obj = [obj initWithFrame: theFrame
textContainer: textContainer]; textContainer: textContainer];
} }
}
RELEASE(self); RELEASE(self);
} }
return obj; return obj;
@ -629,10 +634,13 @@ static const int currentVersion = 1; // GSNibItem version number...
if(obj != nil) if(obj != nil)
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{
if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithTitle:)) != NULL)
{ {
NSString *theTitle = [obj title]; NSString *theTitle = [obj title];
obj = [obj initWithTitle: theTitle]; obj = [obj initWithTitle: theTitle];
} }
}
RELEASE(self); RELEASE(self);
} }
return obj; return obj;
@ -657,11 +665,11 @@ static const int currentVersion = 1; // GSNibItem version number...
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{ {
//if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithFrame:)) != NULL)
//{ {
// NSRect theFrame = [obj frame]; NSRect theFrame = [obj frame];
// obj = [obj initWithFrame: theFrame]; obj = [obj initWithFrame: theFrame];
//} }
} }
RELEASE(self); RELEASE(self);
} }
@ -683,10 +691,13 @@ static const int currentVersion = 1; // GSNibItem version number...
id obj = [super initWithCoder: coder]; id obj = [super initWithCoder: coder];
if(obj != nil) if(obj != nil)
{ {
//if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
//{ {
// obj = [self init]; if(GSGetInstanceMethodNotInherited([obj class],@selector(init)) != NULL)
//} {
obj = [self init];
}
}
RELEASE(self); RELEASE(self);
} }
return obj; return obj;