Explicit timer invalidation

This commit is contained in:
Allan Odgaard
2012-09-22 13:22:34 +02:00
parent 56b96e7f07
commit 0cea361b00
3 changed files with 10 additions and 4 deletions

View File

@@ -326,9 +326,9 @@ OAK_DEBUG_VAR(Find_FolderSearch);
if(self.scannerProbeTimer)
{
OakTimer* probeTimer = [[self.scannerProbeTimer retain] autorelease];
[self.scannerProbeTimer invalidate];
self.scannerProbeTimer = nil;
[probeTimer fire];
[self updateMatches:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:FFDocumentSearchDidFinishNotification object:self];
}
}

View File

@@ -7,5 +7,5 @@ PUBLIC @interface OakTimer : NSObject
+ (id)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector repeats:(BOOL)repeats;
+ (id)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)repeats;
@property (nonatomic, retain) id userInfo;
- (void)fire;
- (void)invalidate;
@end

View File

@@ -57,7 +57,13 @@ OAK_DEBUG_VAR(OakTimer);
- (void)dealloc
{
D(DBF_OakTimer, bug("\n"););
[self invalidate];
}
- (void)invalidate
{
[self.timer invalidate];
self.timer = nil;
}
- (void)fire
@@ -73,6 +79,6 @@ OAK_DEBUG_VAR(OakTimer);
D(DBF_OakTimer, bug("target: %p, action: %s\n", self.target, sel_getName(selector)););
if(self.target)
[self fire];
else [self.timer invalidate];
else [self invalidate];
}
@end