Make GetSettingsVersion handle extra version appends better

Fixes #4015
This commit is contained in:
Jon Evans 2020-03-07 09:33:35 -05:00
parent 4dfe630b28
commit 1e61668cee
1 changed files with 24 additions and 2 deletions

View File

@ -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();
}