diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index e38f80677..6b1777093 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -58,6 +58,7 @@ @implementation SUUpdateAlert void(^_completionBlock)(SPUUserUpdateChoice, NSRect, BOOL); BOOL _allowsAutomaticUpdates; + BOOL _windowLoadedAndShowsReleaseNotes; } - (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateState *)state host:(SUHost *)aHost versionDisplayer:(id)versionDisplayer completionBlock:(void (^)(SPUUserUpdateChoice, NSRect, BOOL))completionBlock didBecomeKeyBlock:(void (^)(void))didBecomeKeyBlock @@ -184,8 +185,13 @@ - (void)displayReleaseNotesSpinner SPU_OBJC_DIRECT - (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData { - if (![self showsReleaseNotes]) { - if ([_host.bundle isEqual:NSBundle.mainBundle]) { + if (!_windowLoadedAndShowsReleaseNotes) { + if (self.window == nil) { + // Window was not properly loaded. + // This can happen if the app moves and the update alert nib fails to load + // This puts Sparkle in an unsupported state but we will try to avoid crashing + SULog(SULogLevelError, @"Error: SUUpdateAlert window is nil and failed to load, which may mean the app was moved. Sparkle is running in an unsupported state."); + } else if ([_host.bundle isEqual:NSBundle.mainBundle]) { SULog(SULogLevelError, @"Warning: '%@' is configured to not show release notes but release notes for version %@ were downloaded. Consider either removing release notes from your appcast or implementing -[SPUUpdaterDelegate updater:shouldDownloadReleaseNotesForUpdate:]", _host.name, _updateItem.displayVersionString); } return; @@ -344,6 +350,7 @@ - (void)windowDidLoad // Update alert should not be resizable when no release notes are available window.styleMask &= ~NSWindowStyleMaskResizable; } + _windowLoadedAndShowsReleaseNotes = showReleaseNotes; if (_updateItem.informationOnlyUpdate) { [_installButton setTitle:SULocalizedStringFromTableInBundle(@"Learn Moreā€¦", SPARKLE_TABLE, SUSparkleBundle(), @"Alternate title for 'Install Update' button when there's no download in RSS feed.")];