From a6d6e31b2cb6cfff061bc2457b8bc7cfc8b4a6f2 Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 22 Feb 2016 23:21:27 -0500 Subject: [PATCH] Remove asking user updater driver if it's showing alerts modally non-void/synchronous calls over XPC don't work properly, and these methods don't seem very proper architecture wise anyway. A proper solution will be needed for notifying the delegate of modal alerts --- Sparkle/SUUIBasedUpdateDriver.m | 17 ++++++++++++----- Sparkle/SUUserUpdaterDriver.h | 3 --- .../SUUpdateSettingsWindowController.m | 10 ---------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 91ea23e4..24e46ef6 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -53,7 +53,7 @@ [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater]; if (!self.automaticallyInstallUpdates) { - [self showNoticeModally:[self.updater.userUpdaterDriver showsUpdateNotFoundModally] noticeHandler:^{ + [self showNotice:^{ [self.updater.userUpdaterDriver showUpdateNotFound]; }]; @@ -152,22 +152,29 @@ - (void)abortUpdateWithError:(NSError *)error { - [self showNoticeModally:[self.updater.userUpdaterDriver showsUpdateErrorModally] noticeHandler:^{ + [self showNotice:^{ [self.updater.userUpdaterDriver showUpdaterError:error]; }]; [super abortUpdateWithError:error]; } -- (void)showNoticeModally:(BOOL)modally noticeHandler:(void (^)(void))noticeHandler +#warning think of a proper solution.. +// These delegate methods to show a modal alert are troublesome +// The user driver may not actually show a modal alert (although our default provided one does) +// We also don't want the user driver to have a reference to the delegate because the user driver +// can live in a separate process, so that's no good either. The user driver methods all need to be +// async and have void return types for XPC, so asking the user driver if it will show an alert modally can get complex +// Furthermore it's possible the user driver can bring up a modal alert in other scenarios out of our control +- (void)showNotice:(void (^)(void))noticeHandler { - if (modally && [[self.updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) { + if ([[self.updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) { [[self.updater delegate] updaterWillShowModalAlert:self.updater]; } noticeHandler(); - if (modally && [[self.updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)]) { + if ([[self.updater delegate] respondsToSelector:@selector(updaterDidShowModalAlert:)]) { [[self.updater delegate] updaterDidShowModalAlert:self.updater]; } } diff --git a/Sparkle/SUUserUpdaterDriver.h b/Sparkle/SUUserUpdaterDriver.h index 24c356b8..5c1a1e58 100644 --- a/Sparkle/SUUserUpdaterDriver.h +++ b/Sparkle/SUUserUpdaterDriver.h @@ -28,10 +28,7 @@ - (void)showAutomaticUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem reply:(void (^)(SUAutomaticInstallationChoice))reply; - (void)showUpdateNotFound; -- (BOOL)showsUpdateNotFoundModally; - - (void)showUpdaterError:(NSError *)error; -- (BOOL)showsUpdateErrorModally; - (void)showDownloadInitiatedWithCancelCallback:(void (^)(void))cancelDownload; - (void)showDownloadDidReceiveResponse:(NSURLResponse *)response; diff --git a/TestApplication/SUUpdateSettingsWindowController.m b/TestApplication/SUUpdateSettingsWindowController.m index 625d2b3e..2561f2aa 100644 --- a/TestApplication/SUUpdateSettingsWindowController.m +++ b/TestApplication/SUUpdateSettingsWindowController.m @@ -54,21 +54,11 @@ NSLog(@":( there was no new update"); } -- (BOOL)showsUpdateNotFoundModally -{ - return NO; -} - - (void)showUpdaterError:(NSError *)error { NSLog(@"Update error: %@", error); } -- (BOOL)showsUpdateErrorModally -{ - return NO; -} - - (void)showDownloadInitiatedWithCancelCallback:(void (^)(void))__unused cancelDownload { NSLog(@"Downloading update...");