aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/updates/macosx/macosx-updates.mm13
-rw-r--r--common/updates.cpp10
-rw-r--r--common/updates.h9
-rw-r--r--gui/options.cpp4
4 files changed, 22 insertions, 14 deletions
diff --git a/backends/updates/macosx/macosx-updates.mm b/backends/updates/macosx/macosx-updates.mm
index 6c7ed03b52..fc967f8fec 100644
--- a/backends/updates/macosx/macosx-updates.mm
+++ b/backends/updates/macosx/macosx-updates.mm
@@ -80,7 +80,7 @@ MacOSXUpdateManager::MacOSXUpdateManager() {
setAutomaticallyChecksForUpdates(kUpdateStateDisabled);
} else {
setAutomaticallyChecksForUpdates(kUpdateStateEnabled);
- setUpdateCheckInterval(ConfMan.getInt("updates_check"));
+ setUpdateCheckInterval(normalizeInterval(ConfMan.getInt("updates_check")));
}
}
@@ -110,16 +110,7 @@ void MacOSXUpdateManager::setUpdateCheckInterval(int interval) {
if (interval == kUpdateIntervalNotSupported)
return;
- const int *vals = getUpdateIntervals();
-
- while (*vals != -1) {
- if (interval == *vals)
- break;
- vals++;
- }
-
- if (*vals == -1)
- interval = kUpdateIntervalOneDay;
+ interval = normalizeInterval(interval);
[sparkleUpdater setUpdateCheckInterval:(NSTimeInterval)interval];
}
diff --git a/common/updates.cpp b/common/updates.cpp
index 0318864881..552324ef5a 100644
--- a/common/updates.cpp
+++ b/common/updates.cpp
@@ -38,6 +38,16 @@ const int *UpdateManager::getUpdateIntervals() {
return updateIntervals;
}
+int UpdateManager::normalizeInterval(int interval) {
+ const int *val = updateIntervals;
+
+ while (*val != -1)
+ if (*val > interval)
+ return *val;
+
+ return val[-1]; // Return maximal acceptable value
+}
+
const char *UpdateManager::updateIntervalToString(int interval) {
switch (interval) {
case kUpdateIntervalNotSupported:
diff --git a/common/updates.h b/common/updates.h
index fa6f79fb91..65eb5ac095 100644
--- a/common/updates.h
+++ b/common/updates.h
@@ -105,9 +105,18 @@ public:
/**
* Returns string representation of a given interval.
*
+ * @param interval The interval.
* @return pointer to localized string of given interval.
*/
static const char *updateIntervalToString(int interval);
+
+ /**
+ * Rounds up the given interval to acceptable value.
+ *
+ * @param interval The interval.
+ * @return rounded up interval
+ */
+ static int normalizeInterval(int interval);
};
} // End of namespace Common
diff --git a/gui/options.cpp b/gui/options.cpp
index 9e8036b68f..c6bbde7abf 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -1243,7 +1243,7 @@ GlobalOptionsDialog::GlobalOptionsDialog()
}
if (ConfMan.hasKey("updates_check"))
- _updatesPopUp->setSelectedTag(ConfMan.getInt("updates_check"));
+ _updatesPopUp->setSelectedTag(Common::UpdateManager::normalizeInterval(ConfMan.getInt("updates_check")));
else
_updatesPopUp->setSelectedTag(Common::UpdateManager::kUpdateIntervalNotSupported);
@@ -1397,8 +1397,6 @@ void GlobalOptionsDialog::close() {
} else {
g_system->getUpdateManager()->setAutomaticallyChecksForUpdates(Common::UpdateManager::kUpdateStateEnabled);
g_system->getUpdateManager()->setUpdateCheckInterval(_updatesPopUp->getSelectedTag());
-
- ConfMan.setInt("updates_check", g_system->getUpdateManager()->getUpdateCheckInterval());
}
}
#endif