Remove the delegate from the notification center in -dealloc; cache the

default notification center


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14530 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2002-09-24 01:32:42 +00:00
parent 03c108664b
commit 33da6f7f1c

View file

@ -35,12 +35,15 @@
static Class abstract;
static Class concrete;
static NSNotificationCenter *nc = nil;
+ (void) initialize
{
if (self == [NSTextStorage class])
{
abstract = self;
concrete = [GSTextStorage class];
nc = [NSNotificationCenter defaultCenter];
}
}
@ -55,6 +58,11 @@ static Class concrete;
- (void) dealloc
{
RELEASE (_layoutManagers);
if (_delegate != nil)
{
[nc removeObserver: _delegate name: nil object: self];
_delegate = nil;
}
[super dealloc];
}
@ -178,8 +186,6 @@ static Class concrete;
int i;
unsigned length;
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
NSDebugLLog(@"NSText", @"processEditing called in NSTextStorage.");
/*
@ -260,8 +266,6 @@ static Class concrete;
*/
- (void) setDelegate: (id)anObject
{
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
if (_delegate)
[nc removeObserver: _delegate name: nil object: self];
_delegate = anObject;