@@ -675,10 +675,64 @@ object: object1 object: object2 repeats: NO]; [[thread runLoop] addTimer: timer]; + if (waitUntilDone) + [timer waitUntilDone]; + + objc_autoreleasePoolPop(pool); +} + +- (void)performSelectorOnMainThread: (SEL)selector + waitUntilDone: (BOOL)waitUntilDone +{ + void *pool = objc_autoreleasePoolPush(); + OFTimer *timer = [OFTimer timerWithTimeInterval: 0 + target: self + selector: selector + repeats: NO]; + [[OFRunLoop mainRunLoop] addTimer: timer]; + + if (waitUntilDone) + [timer waitUntilDone]; + + objc_autoreleasePoolPop(pool); +} + +- (void)performSelectorOnMainThread: (SEL)selector + withObject: (id)object + waitUntilDone: (BOOL)waitUntilDone +{ + void *pool = objc_autoreleasePoolPush(); + OFTimer *timer = [OFTimer timerWithTimeInterval: 0 + target: self + selector: selector + object: object + repeats: NO]; + [[OFRunLoop mainRunLoop] addTimer: timer]; + + if (waitUntilDone) + [timer waitUntilDone]; + + objc_autoreleasePoolPop(pool); +} + +- (void)performSelectorOnMainThread: (SEL)selector + withObject: (id)object1 + withObject: (id)object2 + waitUntilDone: (BOOL)waitUntilDone +{ + void *pool = objc_autoreleasePoolPush(); + OFTimer *timer = [OFTimer timerWithTimeInterval: 0 + target: self + selector: selector + object: object1 + object: object2 + repeats: NO]; + [[OFRunLoop mainRunLoop] addTimer: timer]; + if (waitUntilDone) [timer waitUntilDone]; objc_autoreleasePoolPop(pool); }