Make GetSettingsVersion handle extra version appends better
Fixes #4015
This commit is contained in:
parent
4dfe630b28
commit
1e61668cee
|
@ -567,13 +567,35 @@ std::string SETTINGS_MANAGER::calculateUserSettingsPath( bool aIncludeVer, bool
|
|||
|
||||
std::string SETTINGS_MANAGER::GetSettingsVersion()
|
||||
{
|
||||
wxString version = GetBuildVersion().BeforeLast( '.' );
|
||||
|
||||
// A full build version looks like (x.y.z-nnn-g1234567) or x.y.z-xxx
|
||||
// The string after the major.minor.patch can contain all sorts of other information
|
||||
// We want to extract the x.y portion here
|
||||
wxString version = GetBuildVersion();
|
||||
|
||||
if( version.StartsWith( '(' ) )
|
||||
version = version.Mid( 1 );
|
||||
|
||||
// Trim everything starting from the second '.'
|
||||
|
||||
size_t mid = 0;
|
||||
int found = 0;
|
||||
|
||||
while( found < 2 && mid < version.size() )
|
||||
{
|
||||
if( version[mid] == '.' )
|
||||
found++;
|
||||
|
||||
if( found == 2 )
|
||||
{
|
||||
version = version.SubString( 0, mid - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
mid++;
|
||||
}
|
||||
|
||||
wxASSERT( version.Find( '.' ) != wxNOT_FOUND );
|
||||
|
||||
return version.ToStdString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue