From efa3cf18d0d484fb0c5f2d7a1d19a225aa73259d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Fri, 23 Apr 2010 21:38:56 +0000 Subject: - Ensure that Growl notifications are made from the main thread. This addresses http://spbug.com/643 , and should also fix race condition crashes caused by the timer firing on a closed thread. --- Source/SPGrowlController.m | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Source') diff --git a/Source/SPGrowlController.m b/Source/SPGrowlController.m index 91690546..a92dbdda 100644 --- a/Source/SPGrowlController.m +++ b/Source/SPGrowlController.m @@ -25,6 +25,7 @@ #import "SPGrowlController.h" #import "SPConstants.h" +#import "SPMainThreadTrampoline.h" #include @@ -88,6 +89,13 @@ static SPGrowlController *sharedGrowlController = nil; */ - (void)notifyWithTitle:(NSString *)title description:(NSString *)description window:(NSWindow *)window notificationName:(NSString *)name { + + // Ensure that the delayed notification call is made on the main thread + if (![NSThread isMainThread]) { + [[self onMainThread] notifyWithTitle:title description:description window:window notificationName:name]; + return; + } + NSMutableDictionary *notificationDictionary = [NSMutableDictionary dictionary]; [notificationDictionary setObject:title forKey:@"title"]; [notificationDictionary setObject:description forKey:@"description"]; -- cgit v1.2.3