diff --git a/3d-viewer/3d_cache/3d_cache.cpp b/3d-viewer/3d_cache/3d_cache.cpp index e5058cc96b..1935b390b5 100644 --- a/3d-viewer/3d_cache/3d_cache.cpp +++ b/3d-viewer/3d_cache/3d_cache.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -60,8 +61,8 @@ #define MASK_3D_CACHE "3D_CACHE" -static wxCriticalSection lock3D_cache; -static wxCriticalSection lock3D_cacheManager; +static std::mutex mutex3D_cache; +static std::mutex mutex3D_cacheManager; static bool isSHA1Same( const unsigned char* shaA, const unsigned char* shaB ) @@ -225,7 +226,8 @@ SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCach } // check cache if file is already loaded - wxCriticalSectionLocker lock( lock3D_cache ); + std::lock_guard lock( mutex3D_cache ); + std::map< wxString, S3D_CACHE_ENTRY*, rsort_wxString >::iterator mi; mi = m_CacheMap.find( full3Dpath ); @@ -780,7 +782,7 @@ wxString S3D_CACHE::GetModelHash( const wxString& aModelFileName ) S3D_CACHE* PROJECT::Get3DCacheManager( bool aUpdateProjDir ) { - wxCriticalSectionLocker lock( lock3D_cacheManager ); + std::lock_guard lock( mutex3D_cacheManager ); // Get the existing cache from the project S3D_CACHE* cache = dynamic_cast( GetElem( ELEM_3DCACHE ) ); diff --git a/common/filename_resolver.cpp b/common/filename_resolver.cpp index cf4f8ddacd..f6299f3367 100644 --- a/common/filename_resolver.cpp +++ b/common/filename_resolver.cpp @@ -21,9 +21,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include +#include #include + #include #include #include @@ -44,7 +45,7 @@ #define MASK_3D_RESOLVER "3D_RESOLVER" -static wxCriticalSection lock_resolver; +static std::mutex mutex_resolver; static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult ); @@ -250,7 +251,7 @@ bool FILENAME_RESOLVER::UpdatePathList( std::vector< SEARCH_PATH >& aPathList ) wxString FILENAME_RESOLVER::ResolvePath( const wxString& aFileName ) { - wxCriticalSectionLocker lock( lock_resolver ); + std::lock_guard lock( mutex_resolver ); if( aFileName.empty() ) return wxEmptyString; @@ -439,7 +440,7 @@ bool FILENAME_RESOLVER::addPath( const SEARCH_PATH& aPath ) if( aPath.m_alias.empty() || aPath.m_pathvar.empty() ) return false; - wxCriticalSectionLocker lock( lock_resolver ); + std::lock_guard lock( mutex_resolver ); SEARCH_PATH tpath = aPath; @@ -759,7 +760,8 @@ wxString FILENAME_RESOLVER::ShortenPath( const wxString& aFullPathName ) if( m_Paths.empty() ) createPathList(); - wxCriticalSectionLocker lock( lock_resolver ); + std::lock_guard lock( mutex_resolver ); + std::list< SEARCH_PATH >::const_iterator sL = m_Paths.begin(); size_t idx; diff --git a/utils/kicad2step/pcb/3d_resolver.cpp b/utils/kicad2step/pcb/3d_resolver.cpp index 4dfeb32ba9..fb9c9ccff9 100644 --- a/utils/kicad2step/pcb/3d_resolver.cpp +++ b/utils/kicad2step/pcb/3d_resolver.cpp @@ -21,12 +21,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include #include #include #include +#include +#include #include + #include #include #include @@ -48,7 +49,7 @@ #define MASK_3D_RESOLVER "3D_RESOLVER" -static wxCriticalSection lock3D_resolver; +static std::mutex mutex3D_resolver; static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult ); @@ -326,7 +327,7 @@ bool S3D_RESOLVER::UpdatePathList( std::vector< SEARCH_PATH >& aPathList ) wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName ) { - wxCriticalSectionLocker lock( lock3D_resolver ); + std::lock_guard lock( mutex3D_resolver ); if( aFileName.empty() ) return wxEmptyString; @@ -524,7 +525,7 @@ bool S3D_RESOLVER::addPath( const SEARCH_PATH& aPath ) if( aPath.m_alias.empty() || aPath.m_pathvar.empty() ) return false; - wxCriticalSectionLocker lock( lock3D_resolver ); + std::lock_guard lock( mutex3D_resolver ); SEARCH_PATH tpath = aPath; @@ -895,7 +896,8 @@ wxString S3D_RESOLVER::ShortenPath( const wxString& aFullPathName ) if( m_Paths.empty() ) createPathList(); - wxCriticalSectionLocker lock( lock3D_resolver ); + std::lock_guard lock( mutex3D_resolver ); + std::list< SEARCH_PATH >::const_iterator sL = m_Paths.begin(); std::list< SEARCH_PATH >::const_iterator eL = m_Paths.end(); size_t idx;