Fix legacy lib table loading logic

Also enforce locking of the mutex
This commit is contained in:
Jon Evans 2023-08-18 22:46:16 -04:00
parent 4b6116cb30
commit 373fb56fb7
1 changed files with 10 additions and 7 deletions

View File

@ -198,15 +198,18 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl
do
{
std::shared_lock<std::shared_mutex> lock( cur->m_mutex, std::try_to_lock );
std::shared_lock<std::shared_mutex> lock( cur->m_mutex );
if( !cur->m_rowsMap.count( aNickName ) )
continue;
if( cur->m_rowsMap.count( aNickName ) )
row = &*cur->m_rowsMap.at( aNickName );
row = &*cur->m_rowsMap.at( aNickName );
if( !aCheckIfEnabled || row->GetIsEnabled() )
return row;
if( row )
{
if( !aCheckIfEnabled || row->GetIsEnabled() )
return row;
else
return nullptr; // We found it, but it's disabled
}
// Repeat, this time looking for names that were "fixed" by legacy versions because
// the old eeschema file format didn't support spaces in tokens.