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