]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Fix crash when checking for update, fixes #575.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 13 Aug 2014 03:28:19 +0000 (11:28 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 13 Aug 2014 03:28:19 +0000 (11:28 +0800)
atom/browser/auto_updater_mac.mm

index 36dcec281b974a7e4986d0194a44b5f1b7321b69..0c6d4b6545074906a4d706c3d0f18b3acd7581fb 100644 (file)
@@ -48,11 +48,13 @@ void AutoUpdater::SetFeedURL(const std::string& feed) {
     [[g_updater rac_valuesForKeyPath:@"state" observer:g_updater]
       subscribeNext:^(NSNumber *stateNumber) {
         int state = [stateNumber integerValue];
-        if (state == SQRLUpdaterStateCheckingForUpdate) {
-          delegate->OnCheckingForUpdate();
-        } else if (state == SQRLUpdaterStateDownloadingUpdate) {
-          delegate->OnUpdateAvailable();
-        }
+        // Dispatching the event on main thread.
+        dispatch_async(dispatch_get_main_queue(), ^{
+          if (state == SQRLUpdaterStateCheckingForUpdate)
+            delegate->OnCheckingForUpdate();
+          else if (state == SQRLUpdaterStateDownloadingUpdate)
+            delegate->OnUpdateAvailable();
+        });
     }];
   }
 }
@@ -89,4 +91,5 @@ void AutoUpdater::CheckForUpdates() {
         delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription));
       }];
 }
+
 }  // namespace auto_updater