Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -607,21 +607,21 @@ objc_autoreleasePoolPop(pool); } - (void)performSelector: (SEL)selector - withObject: (id)object - withObject: (id)otherObject + withObject: (id)object1 + withObject: (id)object2 afterDelay: (double)delay { void *pool = objc_autoreleasePoolPush(); [OFTimer scheduledTimerWithTimeInterval: delay target: self selector: selector - object: object - object: object + object: object1 + object: object2 repeats: NO]; objc_autoreleasePoolPop(pool); } @@ -655,21 +655,21 @@ objc_autoreleasePoolPop(pool); } - (void)performSelector: (SEL)selector onThread: (OFThread*)thread - withObject: (id)object - withObject: (id)otherObject + withObject: (id)object1 + withObject: (id)object2 afterDelay: (double)delay { void *pool = objc_autoreleasePoolPush(); [[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay target: self selector: selector - object: object - object: object + object: object1 + object: object2 repeats: NO]]; objc_autoreleasePoolPop(pool); } Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -320,11 +320,12 @@ [timersQueue removeListObject: listObject]; } else timer = nil; } - [timer fire]; + if ([timer isValid]) + [timer fire]; @synchronized (timersQueue) { nextTimer = [[timersQueue firstObject] fireDate]; } Index: src/OFTimer.h ================================================================== --- src/OFTimer.h +++ src/OFTimer.h @@ -34,10 +34,11 @@ uint8_t arguments; BOOL repeats; #ifdef OF_HAVE_BLOCKS of_timer_block_t block; #endif + BOOL isValid; } /** * \brief Creates and schedules a new timer with the specified time interval. * @@ -260,6 +261,27 @@ * \brief Returns the next date at which the timer will fire. * * \return The next date at which the timer will fire */ - (OFDate*)fireDate; + +/** + * \brief Invalidates the timer, preventing it from firing. + */ +- (void)invalidate; + +/** + * \brief Returns whether the timer is valid. + * + * \return Whether the timer is valid + */ +- (BOOL)isValid; + +/** + * \brief Returns the time interval in which the timer will repeat, if it is a + * repeating timer. + * + * \return The time interval in which the timer will repeat, if it is a + * repeating timer + */ +- (double)timeInterval; @end Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -216,10 +216,11 @@ selector = selector_; object1 = [object1_ retain]; object2 = [object2_ retain]; arguments = arguments_; repeats = repeats_; + isValid = YES; } @catch (id e) { [self release]; @throw e; } @@ -358,13 +359,29 @@ fireDate = [[OFDate alloc] initWithTimeIntervalSinceNow: interval]; [old release]; [[OFRunLoop currentRunLoop] addTimer: self]; - } + } else + isValid = NO; } - (OFDate*)fireDate { return [[fireDate retain] autorelease]; } + +- (double)timeInterval +{ + return interval; +} + +- (void)invalidate +{ + isValid = NO; +} + +- (BOOL)isValid +{ + return isValid; +} @end