From 57731f44d7b6834536af678fc88413a6e501c2c7 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sun, 18 Mar 2018 13:40:45 +0000 Subject: [PATCH] Avoid invalid use of main thread Fixes #1189 --- Sparkle/SUUIBasedUpdateDriver.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index cfcbf36aab..e65b845d24 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -304,7 +304,7 @@ - (void)terminateApp - (void)abortUpdateWithError:(NSError *)error { - dispatch_sync(dispatch_get_main_queue(), ^{ + void (^callback)() = ^{ if (self.showErrors) { NSAlert *alert = [[NSAlert alloc] init]; alert.messageText = SULocalizedString(@"Update Error!", nil); @@ -313,7 +313,12 @@ - (void)abortUpdateWithError:(NSError *)error [self showAlert:alert]; } [super abortUpdateWithError:error]; - }); + }; + if ([NSThread isMainThread]) { + callback(); + } else { + dispatch_sync(dispatch_get_main_queue(), callback); + } } - (void)abortUpdate