From 373fb56fb79d9b8a500284684c54320bc0f8c0e9 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 18 Aug 2023 22:46:16 -0400 Subject: [PATCH] Fix legacy lib table loading logic Also enforce locking of the mutex --- common/lib_table_base.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/lib_table_base.cpp b/common/lib_table_base.cpp index 6f302c1610..9455334b9b 100644 --- a/common/lib_table_base.cpp +++ b/common/lib_table_base.cpp @@ -198,15 +198,18 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl do { - std::shared_lock lock( cur->m_mutex, std::try_to_lock ); + std::shared_lock 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.