mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Prevent call to designated init when className and superClass are equivalent.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21180 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
68d9e52620
commit
2c274d8449
2 changed files with 19 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
2005-05-02 23:45 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/GSNibTemplates.m: added condition to all of the templates
|
||||
so that the designated init is not called when the className and
|
||||
the superClass are equivalent.
|
||||
|
||||
2005-05-01 17:09 Adrian Robert <arobert@cogsci.ucsd.edu>
|
||||
|
||||
* Source/GSNibTemplates.m: [GSWindowTemplate initWithCoder:]
|
||||
|
|
|
@ -656,7 +656,7 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
|||
if([self shouldSwapClass])
|
||||
{
|
||||
Class aClass = NSClassFromString(_className);
|
||||
if(aClass == 0)
|
||||
if(aClass == nil)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to find class '%@', it is not linked into the application.", _className];
|
||||
|
@ -737,7 +737,10 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
|||
|
||||
if([self shouldSwapClass])
|
||||
{
|
||||
if(GSGetMethod([obj class], @selector(initWithContentRect:styleMask:backing:defer:), YES, NO) != NULL)
|
||||
// We should call the designated initializer when it is a custom subclass only. If the
|
||||
// class name and the encoded class are the same, it's usually not a custom class.
|
||||
if(GSGetMethod([obj class], @selector(initWithContentRect:styleMask:backing:defer:), YES, NO) != NULL
|
||||
&& ![_className isEqualToString: NSStringFromClass(_superClass)])
|
||||
{
|
||||
// if we are not in interface builder, call
|
||||
// designated initializer per spec...
|
||||
|
@ -779,7 +782,8 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
|||
{
|
||||
if([self shouldSwapClass])
|
||||
{
|
||||
if(GSGetMethod([obj class],@selector(initWithFrame:), YES, NO) != NULL)
|
||||
if(GSGetMethod([obj class],@selector(initWithFrame:), YES, NO) != NULL
|
||||
&& ![_className isEqualToString: NSStringFromClass(_superClass)])
|
||||
{
|
||||
NSRect theFrame = [obj frame];
|
||||
obj = [obj initWithFrame: theFrame];
|
||||
|
@ -808,7 +812,8 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
|||
{
|
||||
if([self shouldSwapClass])
|
||||
{
|
||||
if(GSGetMethod([obj class],@selector(initWithFrame:), YES, NO) != NULL)
|
||||
if(GSGetMethod([obj class],@selector(initWithFrame:), YES, NO) != NULL
|
||||
&& ![_className isEqualToString: NSStringFromClass(_superClass)])
|
||||
{
|
||||
NSRect theFrame = [obj frame];
|
||||
obj = [obj initWithFrame: theFrame];
|
||||
|
@ -837,7 +842,8 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
|||
{
|
||||
if([self shouldSwapClass])
|
||||
{
|
||||
if(GSGetMethod([obj class],@selector(initWithFrame:textContainer:), YES, NO) != NULL)
|
||||
if(GSGetMethod([obj class],@selector(initWithFrame:textContainer:), YES, NO) != NULL
|
||||
&& ![_className isEqualToString: NSStringFromClass(_superClass)])
|
||||
{
|
||||
NSRect theFrame = [obj frame];
|
||||
id textContainer = [obj textContainer];
|
||||
|
@ -928,7 +934,8 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
|||
{
|
||||
if([self shouldSwapClass])
|
||||
{
|
||||
if(GSGetMethod([obj class],@selector(init), YES, NO) != NULL)
|
||||
if(GSGetMethod([obj class],@selector(init), YES, NO) != NULL
|
||||
&& ![_className isEqualToString: NSStringFromClass(_superClass)])
|
||||
{
|
||||
obj = [self init];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue