From 3be0c5db02b94e2e3dd6485abcd5d5c7abe8d429 Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 24 Sep 2002 01:32:42 +0000 Subject: [PATCH] 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 --- Source/NSTextStorage.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/NSTextStorage.m b/Source/NSTextStorage.m index d50e34a0a..6a8001d51 100644 --- a/Source/NSTextStorage.m +++ b/Source/NSTextStorage.m @@ -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;