Skip to content

Commit

Permalink
Avoid invalid use of main thread
Browse files Browse the repository at this point in the history
Fixes #1189
  • Loading branch information
kornelski committed Mar 18, 2018
1 parent 2a0514c commit 57731f4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sparkle/SUUIBasedUpdateDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit 57731f4

Please sign in to comment.