From 1c4bcda0122626211224e41b25c8c0c5a91aa232 Mon Sep 17 00:00:00 2001 From: Brian Bergstrand Date: Fri, 25 May 2018 13:54:21 -0500 Subject: [PATCH] Fix potential hang with dispatch_sync to main thread --- Sparkle/SUUIBasedUpdateDriver.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 19370652..6b0092bc 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -241,11 +241,17 @@ - (void)extractUpdate { - dispatch_sync(dispatch_get_main_queue(), ^{ + dispatch_block_t updateUI = ^{ // Now we have to extract the downloaded archive. [self.statusController beginActionWithTitle:SULocalizedString(@"Extracting update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil]; [self.statusController setButtonEnabled:NO]; - }); + }; + + if (![NSThread mainThread]) { + dispatch_sync(dispatch_get_main_queue(), updateUI); + } else { + updateUI(); + } [super extractUpdate]; }