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;
@ -511,16 +504,19 @@ static const int currentVersion = 1; // GSNibItem version number...
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{ {
// if we are not in interface builder, call if(GSGetInstanceMethodNotInherited([obj class], @selector(initWithContentRect:styleMask:backing:defer:)) != NULL)
// designated initializer per spec... {
contentView = [obj contentView]; // if we are not in interface builder, call
obj = [obj initWithContentRect: [obj frame] // designated initializer per spec...
styleMask: [obj styleMask] contentView = [obj contentView];
backing: [obj backingType] obj = [obj initWithContentRect: [obj frame]
defer: _deferFlag]; styleMask: [obj styleMask]
backing: [obj backingType]
// set the content view back defer: _deferFlag];
[obj setContentView: contentView];
// set the content view back
[obj setContentView: contentView];
}
} }
RELEASE(self); RELEASE(self);
} }
@ -550,8 +546,11 @@ static const int currentVersion = 1; // GSNibItem version number...
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{ {
NSRect theFrame = [obj frame]; if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithFrame:)) != NULL)
obj = [obj initWithFrame: theFrame]; {
NSRect theFrame = [obj frame];
obj = [obj initWithFrame: theFrame];
}
} }
RELEASE(self); RELEASE(self);
} }
@ -576,8 +575,11 @@ static const int currentVersion = 1; // GSNibItem version number...
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{ {
NSRect theFrame = [obj frame]; if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithFrame:)) != NULL)
obj = [obj initWithFrame: theFrame]; {
NSRect theFrame = [obj frame];
obj = [obj initWithFrame: theFrame];
}
} }
RELEASE(self); RELEASE(self);
} }
@ -602,10 +604,13 @@ static const int currentVersion = 1; // GSNibItem version number...
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{ {
NSRect theFrame = [obj frame]; if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithFrame:textContainer:)) != NULL)
id textContainer = [obj textContainer]; {
obj = [obj initWithFrame: theFrame NSRect theFrame = [obj frame];
textContainer: textContainer]; id textContainer = [obj textContainer];
obj = [obj initWithFrame: theFrame
textContainer: textContainer];
}
} }
RELEASE(self); RELEASE(self);
} }
@ -630,8 +635,11 @@ static const int currentVersion = 1; // GSNibItem version number...
{ {
if(![self respondsToSelector: @selector(isInInterfaceBuilder)]) if(![self respondsToSelector: @selector(isInInterfaceBuilder)])
{ {
NSString *theTitle = [obj title]; if(GSGetInstanceMethodNotInherited([obj class],@selector(initWithTitle:)) != NULL)
obj = [obj initWithTitle: theTitle]; {
NSString *theTitle = [obj title];
obj = [obj initWithTitle: theTitle];
}
} }
RELEASE(self); RELEASE(self);
} }
@ -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;