mac: Fix crash when checking for update, fixes #575.

This commit is contained in:
Cheng Zhao 2014-08-13 11:28:19 +08:00
parent a8ca0329b4
commit e7647ba183

View file

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