From 246913a1dbb15c48c52d5b7af6035fcdf71eb385 Mon Sep 17 00:00:00 2001 From: CaS Date: Mon, 17 Jun 2002 06:30:32 +0000 Subject: [PATCH] Retain/rele4ase fixes git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13899 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/NSTimer.m | 24 ++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68c7acee3..0c97ed168 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-06-17 Richard Frith-Macdonald + + * Source/NSTimer.m: Retain target and user info on initialisation + Release them on invalidation. Ensure timer is invalidated on + deallocation. + Changes based on bug report by Andy Ruder + 2002-06-16 Richard Frith-Macdonald * Source/GSFTPURLHandle.m: simple implementation added diff --git a/Source/NSTimer.m b/Source/NSTimer.m index b75dd6e5a..fe64f17c4 100644 --- a/Source/NSTimer.m +++ b/Source/NSTimer.m @@ -63,9 +63,9 @@ static Class NSDate_class; _interval = ti; _date = [[NSDate_class allocWithZone: [self zone]] initWithTimeIntervalSinceNow: ti]; - _target = object; + _target = RETAIN(object); _selector = selector; - _info = info; + _info = RETAIN(info); _repeats = f; return self; } @@ -122,6 +122,10 @@ static Class NSDate_class; - (void) dealloc { + if (_invalidated == NO) + { + [self invalidate]; + } RELEASE(_date); [super dealloc]; } @@ -166,6 +170,14 @@ static Class NSDate_class; - (void) invalidate { + if (_target != nil) + { + DESTROY(_target); + } + if (_info != nil) + { + DESTROY(_info); + } /* OPENSTEP allows this method to be called multiple times. */ //NSAssert(_invalidated == NO, NSInternalInconsistencyException); _invalidated = YES; @@ -174,9 +186,13 @@ static Class NSDate_class; - (BOOL) isValid { if (_invalidated == NO) - return YES; + { + return YES; + } else - return NO; + { + return NO; + } } - (NSDate*) fireDate