From 45a96af9ac76c7b4e3f794346326c0307303b7ee Mon Sep 17 00:00:00 2001 From: RichardTea <31507749+RichardTea@users.noreply.github.com> Date: Tue, 3 Dec 2019 14:15:50 +0000 Subject: [PATCH] Fix typo in M3DWrapper.cpp Don't use std::mutex if not supported. Allow override to force it to be used if does in fact exist Thank you CI --- code/M3D/M3DWrapper.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/code/M3D/M3DWrapper.cpp b/code/M3D/M3DWrapper.cpp index 291c28d20..0060c894e 100644 --- a/code/M3D/M3DWrapper.cpp +++ b/code/M3D/M3DWrapper.cpp @@ -48,16 +48,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#if (__cplusplus >= 201103L) || (_MSC_VER >= 1915) || defined(AI_M3D_USE_STDMUTEX) // C++11 and MSVC that mostly supports it -#define AI_M3D_USE_STDMUTEX +#ifndef AI_M3D_USE_STDMUTEX +#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900) // C++11 and MSVC 2015 onwards +#define AI_M3D_USE_STDMUTEX 1 +#else +#define AI_M3D_USE_STDMUTEX 0 +#endif +#endif + +#if AI_M3D_USE_STDMUTEX #include +std::mutex file_mutex; #endif // workaround: the M3D SDK expects a C callback, but we want to use Assimp::IOSystem to implement that // This makes it non-rentrant so lock a mutex (requires C++11) -std::mutex file_mutex; - extern "C" { void *m3dimporter_pIOHandler; @@ -94,7 +100,7 @@ M3DWrapper::M3DWrapper() { } M3DWrapper::M3DWrapper(IOSystem *pIOHandler, const std::vector &buffer) { -#ifdef AI_M3D_USE_STDMUTEX +#if AI_M3D_USE_STDMUTEX // M3D is NOT thread-safe, so lock the global mutex const std::lock_guard lock(file_mutex); #endif