Retain/rele4ase fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13899 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-06-17 06:30:32 +00:00
parent e299ba5d37
commit 246913a1db
2 changed files with 27 additions and 4 deletions

View file

@ -1,3 +1,10 @@
2002-06-17 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <aeruder@yahoo.com>
2002-06-16 Richard Frith-Macdonald <rfm@gnu.org> 2002-06-16 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSFTPURLHandle.m: simple implementation added * Source/GSFTPURLHandle.m: simple implementation added

View file

@ -63,9 +63,9 @@ static Class NSDate_class;
_interval = ti; _interval = ti;
_date = [[NSDate_class allocWithZone: [self zone]] _date = [[NSDate_class allocWithZone: [self zone]]
initWithTimeIntervalSinceNow: ti]; initWithTimeIntervalSinceNow: ti];
_target = object; _target = RETAIN(object);
_selector = selector; _selector = selector;
_info = info; _info = RETAIN(info);
_repeats = f; _repeats = f;
return self; return self;
} }
@ -122,6 +122,10 @@ static Class NSDate_class;
- (void) dealloc - (void) dealloc
{ {
if (_invalidated == NO)
{
[self invalidate];
}
RELEASE(_date); RELEASE(_date);
[super dealloc]; [super dealloc];
} }
@ -166,6 +170,14 @@ static Class NSDate_class;
- (void) invalidate - (void) invalidate
{ {
if (_target != nil)
{
DESTROY(_target);
}
if (_info != nil)
{
DESTROY(_info);
}
/* OPENSTEP allows this method to be called multiple times. */ /* OPENSTEP allows this method to be called multiple times. */
//NSAssert(_invalidated == NO, NSInternalInconsistencyException); //NSAssert(_invalidated == NO, NSInternalInconsistencyException);
_invalidated = YES; _invalidated = YES;
@ -174,9 +186,13 @@ static Class NSDate_class;
- (BOOL) isValid - (BOOL) isValid
{ {
if (_invalidated == NO) if (_invalidated == NO)
{
return YES; return YES;
}
else else
{
return NO; return NO;
}
} }
- (NSDate*) fireDate - (NSDate*) fireDate