From e6a73c84897663c0f2590e11510c95e5465e69ff Mon Sep 17 00:00:00 2001 From: Guillaume Louel Date: Thu, 1 Nov 2018 23:25:16 +0100 Subject: [PATCH] Fix crash on coordinates where calculating dawn/dusk may not be possible (south pole for example !) --- .../Source/Models/Time/TimeManagement.swift | 35 +++++++--- Resources/Info.plist | 4 +- Resources/PreferencesWindow.xib | 65 ++++++++++--------- 3 files changed, 60 insertions(+), 44 deletions(-) diff --git a/Aerial/Source/Models/Time/TimeManagement.swift b/Aerial/Source/Models/Time/TimeManagement.swift index 388cdef3..8b0706cd 100644 --- a/Aerial/Source/Models/Time/TimeManagement.swift +++ b/Aerial/Source/Models/Time/TimeManagement.swift @@ -162,20 +162,35 @@ class TimeManagement: NSObject { switch preferences.solarMode { case Preferences.SolarMode.official.rawValue: - sunriseString = dateFormatter.string(from: (solar?.sunrise)!) - sunsetString = dateFormatter.string(from: (solar?.sunset)!) + guard let sunrise = solar?.sunrise, let sunset = solar?.sunset else { + return (false, "Can't process your coordinates, please verify") + } + sunriseString = dateFormatter.string(from: sunrise) + sunsetString = dateFormatter.string(from: sunset) case Preferences.SolarMode.strict.rawValue: - sunriseString = dateFormatter.string(from: (solar?.strictSunrise)!) - sunsetString = dateFormatter.string(from: (solar?.strictSunset)!) + guard let sunrise = solar?.strictSunrise, let sunset = solar?.strictSunset else { + return (false, "Can't process your coordinates, please verify") + } + sunriseString = dateFormatter.string(from: sunrise) + sunsetString = dateFormatter.string(from: sunset) case Preferences.SolarMode.civil.rawValue: - sunriseString = dateFormatter.string(from: (solar?.civilSunrise)!) - sunsetString = dateFormatter.string(from: (solar?.civilSunset)!) + guard let sunrise = solar?.civilSunrise, let sunset = solar?.civilSunset else { + return (false, "Can't process your coordinates, please verify") + } + sunriseString = dateFormatter.string(from: sunrise) + sunsetString = dateFormatter.string(from: sunset) case Preferences.SolarMode.nautical.rawValue: - sunriseString = dateFormatter.string(from: (solar?.nauticalSunrise)!) - sunsetString = dateFormatter.string(from: (solar?.nauticalSunset)!) + guard let sunrise = solar?.nauticalSunrise, let sunset = solar?.nauticalSunset else { + return (false, "Can't process your coordinates, please verify") + } + sunriseString = dateFormatter.string(from: sunrise) + sunsetString = dateFormatter.string(from: sunset) default: - sunriseString = dateFormatter.string(from: (solar?.astronomicalSunrise)!) - sunsetString = dateFormatter.string(from: (solar?.astronomicalSunset)!) + guard let sunrise = solar?.astronomicalSunrise, let sunset = solar?.astronomicalSunset else { + return (false, "Can't process your coordinates, please verify") + } + sunriseString = dateFormatter.string(from: sunrise) + sunsetString = dateFormatter.string(from: sunset) } if preferences.solarMode == Preferences.SolarMode.official.rawValue || diff --git a/Resources/Info.plist b/Resources/Info.plist index 9ae057af..610c7b8c 100644 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.4.5beta3 + 1.4.5beta4 CFBundleSignature ???? CFBundleVersion - 1.4.5beta3 + 1.4.5beta4 LSApplicationCategoryType LSMinimumSystemVersion diff --git a/Resources/PreferencesWindow.xib b/Resources/PreferencesWindow.xib index 0c4454a8..a54a0684 100644 --- a/Resources/PreferencesWindow.xib +++ b/Resources/PreferencesWindow.xib @@ -297,7 +297,7 @@ - + @@ -402,7 +402,7 @@ is disabled - + @@ -440,7 +440,7 @@ is disabled - + @@ -461,7 +461,7 @@ is disabled - - + @@ -493,7 +493,7 @@ is disabled - - - - + @@ -715,7 +715,7 @@ should appear - + @@ -736,7 +736,7 @@ should appear - + @@ -753,7 +753,7 @@ should appear - - - - + @@ -854,7 +854,7 @@ should appear - + @@ -904,7 +904,7 @@ should appear - + @@ -1035,7 +1035,7 @@ should appear - + @@ -1062,7 +1062,7 @@ should appear - + @@ -1097,7 +1097,7 @@ should appear - + @@ -1148,7 +1148,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - - - - - - -