From 4beecc0c17c73cfc1a449017cd7f106aa3f3b006 Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Sun, 23 Nov 2008 17:10:22 +0000 Subject: [PATCH] Make sure a decoded control always has a cell. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27122 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSControl.m | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 74f64639f..71681fa42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-23 Fred Kiefer + + * Source/NSControl.m (-initWithCoder:): For keyed decoding make + sure there always is a cell. + 2008-11-23 Wolfgang Lux * Source/NSTextView.m (-mouseDown:): Allow click into the current diff --git a/Source/NSControl.m b/Source/NSControl.m index 44987991f..974c86a0a 100644 --- a/Source/NSControl.m +++ b/Source/NSControl.m @@ -971,7 +971,11 @@ static NSNotificationCenter *nc; - (id) initWithCoder: (NSCoder*)aDecoder { - [super initWithCoder: aDecoder]; + self = [super initWithCoder: aDecoder]; + if (self == nil) + { + return nil; + } if ([aDecoder allowsKeyedCoding]) { @@ -981,6 +985,15 @@ static NSNotificationCenter *nc; { [self setCell: cell]; } + else + { + // This is needed for subclasses without cells, like NSColorWeel + // as we store some properties only on the cell. + NSCell *cell = [[[self class] cellClass] new]; + + [self setCell: cell]; + RELEASE(cell); + } if ([aDecoder containsValueForKey: @"NSEnabled"]) { [self setEnabled: [aDecoder decodeBoolForKey: @"NSEnabled"]];