diff --git a/common/lib_table_base.cpp b/common/lib_table_base.cpp index c2bd8d650f..e0c8cddcc0 100644 --- a/common/lib_table_base.cpp +++ b/common/lib_table_base.cpp @@ -193,6 +193,8 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl { cur->ensureIndex(); + std::shared_lock lock( m_nickIndexMutex ); + for( const std::pair& entry : cur->m_nickIndex ) { if( entry.first == aNickName ) @@ -303,7 +305,7 @@ bool LIB_TABLE::InsertRow( LIB_TABLE_ROW* aRow, bool doReplace ) { ensureIndex(); - std::lock_guard lock( m_nickIndexMutex ); + std::lock_guard lock( m_nickIndexMutex ); INDEX_CITER it = m_nickIndex.find( aRow->GetNickName() ); diff --git a/include/lib_table_base.h b/include/lib_table_base.h index 04769543ea..f93e5f9f84 100644 --- a/include/lib_table_base.h +++ b/include/lib_table_base.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -329,7 +329,7 @@ public: /// Delete all rows. void Clear() { - std::lock_guard lock( m_nickIndexMutex ); + std::lock_guard lock( m_nickIndexMutex ); m_rows.clear(); m_nickIndex.clear(); @@ -541,7 +541,7 @@ protected: void reindex() { - std::lock_guard lock( m_nickIndexMutex ); + std::lock_guard lock( m_nickIndexMutex ); m_nickIndex.clear(); @@ -580,7 +580,7 @@ protected: mutable int m_version; /// Mutex to protect access to the nickIndex variable - mutable std::mutex m_nickIndexMutex; + mutable std::shared_mutex m_nickIndexMutex; }; #endif // _LIB_TABLE_BASE_H_