Fix library sort order in library viewers

The lib table returns a properly sorted list of libraries already, which
we just iterate through. A std::set is a sorted collection, but uses a
different sorting function than the lib table, so appending to a
std::set breaks the initial sorting that was done already.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13530
This commit is contained in:
Ian McInerney 2023-01-27 23:38:10 +00:00
parent f6dc48ead7
commit 51c8f2c119
2 changed files with 8 additions and 8 deletions

View File

@ -642,8 +642,8 @@ bool SYMBOL_VIEWER_FRAME::ReCreateLibList()
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
std::vector<wxString> libs = libTable->GetLogicalLibs();
std::set<wxString> pinnedMatches;
std::set<wxString> otherMatches;
std::vector<wxString> pinnedMatches;
std::vector<wxString> otherMatches;
auto doAddLib =
[&]( const wxString& aLib )
@ -651,11 +651,11 @@ bool SYMBOL_VIEWER_FRAME::ReCreateLibList()
if( alg::contains( project.m_PinnedSymbolLibs, aLib )
|| alg::contains( cfg->m_Session.pinned_symbol_libs, aLib ) )
{
pinnedMatches.insert( aLib );
pinnedMatches.push_back( aLib );
}
else
{
otherMatches.insert( aLib );
otherMatches.push_back( aLib );
}
};

View File

@ -463,8 +463,8 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
std::set<wxString> pinnedMatches;
std::set<wxString> otherMatches;
std::vector<wxString> pinnedMatches;
std::vector<wxString> otherMatches;
auto process =
[&]( const wxString& aNickname )
@ -472,11 +472,11 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
|| alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
{
pinnedMatches.insert( aNickname );
pinnedMatches.push_back( aNickname );
}
else
{
otherMatches.insert( aNickname );
otherMatches.push_back( aNickname );
}
};