mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 19:21:41 +00:00
Prefer later versions in import of previous settings
This commit is contained in:
parent
c5ef51d688
commit
53dedb2c99
@ -663,6 +663,21 @@ bool SETTINGS_MANAGER::GetPreviousVersionPaths( std::vector<wxString>* aPaths )
|
||||
}
|
||||
}
|
||||
|
||||
std::sort( aPaths->begin(), aPaths->end(),
|
||||
[&]( const wxString& a, const wxString& b ) -> bool
|
||||
{
|
||||
wxString verA = wxFileName::DirName( a ).GetDirs().back();
|
||||
wxString verB = wxFileName::DirName( b ).GetDirs().back();
|
||||
|
||||
if( !extractVersion( verA.ToStdString() )
|
||||
|| !extractVersion( verB.ToStdString() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return compareVersions( verA.ToStdString(), verB.ToStdString() ) >= 0;
|
||||
} );
|
||||
|
||||
return aPaths->size() > 0;
|
||||
}
|
||||
|
||||
@ -793,8 +808,14 @@ bool SETTINGS_MANAGER::extractVersion( const std::string& aVersionString, int* a
|
||||
{
|
||||
try
|
||||
{
|
||||
*aMajor = std::stoi( match[1].str() );
|
||||
*aMinor = std::stoi( match[2].str() );
|
||||
int major = std::stoi( match[1].str() );
|
||||
int minor = std::stoi( match[2].str() );
|
||||
|
||||
if( aMajor )
|
||||
*aMajor = major;
|
||||
|
||||
if( aMinor )
|
||||
*aMinor = minor;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
|
@ -385,7 +385,8 @@ private:
|
||||
* @param aMinor will store the second part
|
||||
* @return true if extraction succeeded
|
||||
*/
|
||||
static bool extractVersion( const std::string& aVersionString, int* aMajor, int* aMinor );
|
||||
static bool extractVersion( const std::string& aVersionString, int* aMajor = nullptr,
|
||||
int* aMinor = nullptr );
|
||||
|
||||
/**
|
||||
* Attempts to load a color theme by name (the color theme directory and .json ext are assumed)
|
||||
|
Loading…
Reference in New Issue
Block a user