summaryrefslogtreecommitdiff
path: root/ui/checkVersion.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 16:59:28 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 16:59:28 +0200
commite303a7bcdb5ce6c7afb368d329fbbba8088328f6 (patch)
treed74d651b8d0c17f5195ac22d1751ce29c35e082a /ui/checkVersion.cpp
parent2.0 (diff)
downloadFreeFileSync-e303a7bcdb5ce6c7afb368d329fbbba8088328f6.tar.gz
FreeFileSync-e303a7bcdb5ce6c7afb368d329fbbba8088328f6.tar.bz2
FreeFileSync-e303a7bcdb5ce6c7afb368d329fbbba8088328f6.zip
2.1
Diffstat (limited to 'ui/checkVersion.cpp')
-rw-r--r--ui/checkVersion.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/ui/checkVersion.cpp b/ui/checkVersion.cpp
index 914e5e09..16d37036 100644
--- a/ui/checkVersion.cpp
+++ b/ui/checkVersion.cpp
@@ -64,16 +64,34 @@ bool getOnlineVersion(wxString& version)
bool newerVersionExists(const wxString& onlineVersion)
{
- const wxString currentMajor = FreeFileSync::currentVersion.BeforeLast(wxT('.'));
- const wxString onlineMajor = onlineVersion.BeforeLast(wxT('.'));
+ wxString currentVersionCpy = FreeFileSync::currentVersion;
+ wxString onlineVersionCpy = onlineVersion;
- if (currentMajor != onlineMajor)
- return globalFunctions::wxStringToInt(currentMajor) < globalFunctions::wxStringToInt(onlineMajor);
+ const wxChar VERSION_SEP = wxT('.');
- const wxString currentMinor = FreeFileSync::currentVersion.AfterLast(wxT('.'));
- const wxString onlineMinor = onlineVersion.AfterLast(wxT('.'));
+ while ( currentVersionCpy.Find(VERSION_SEP) != wxNOT_FOUND &&
+ onlineVersionCpy.Find(VERSION_SEP) != wxNOT_FOUND)
+ {
+ const wxString currentMajor = currentVersionCpy.BeforeFirst(VERSION_SEP);
+ const wxString onlineMajor = onlineVersionCpy.BeforeFirst(VERSION_SEP);
+
+ if (currentMajor != onlineMajor)
+ return globalFunctions::wxStringToInt(currentMajor) < globalFunctions::wxStringToInt(onlineMajor);
+
+ currentVersionCpy = currentVersionCpy.AfterFirst(VERSION_SEP);
+ onlineVersionCpy = onlineVersionCpy.AfterFirst(VERSION_SEP);
+ }
+
+ const wxString currentMinor = currentVersionCpy.BeforeFirst(VERSION_SEP); //Returns the whole string if VERSION_SEP is not found.
+ const wxString onlineMinor = onlineVersionCpy.BeforeFirst(VERSION_SEP); //Returns the whole string if VERSION_SEP is not found.
+
+ if (currentMinor != onlineMinor)
+ return globalFunctions::wxStringToInt(currentMinor) < globalFunctions::wxStringToInt(onlineMinor);
+
+ currentVersionCpy = currentVersionCpy.AfterFirst(VERSION_SEP); //Returns the empty string if VERSION_SEP is not found.
+ onlineVersionCpy = onlineVersionCpy.AfterFirst(VERSION_SEP); //Returns the empty string if VERSION_SEP is not found.
- return globalFunctions::wxStringToInt(currentMinor) < globalFunctions::wxStringToInt(onlineMinor);
+ return globalFunctions::wxStringToInt(currentVersionCpy) < globalFunctions::wxStringToInt(onlineVersionCpy);
}
bgstack15