From 17b9e7c1076efa0670d62cd69d3e9420804234d1 Mon Sep 17 00:00:00 2001 From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com> Date: Sat, 9 Sep 2023 15:22:04 -0700 Subject: [PATCH] Fix startup crash in debug build Do not throw error when trying to get mutex lock. --- rtgui/threadutils.cc | 7 ++++++- rtgui/threadutils.h | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/rtgui/threadutils.cc b/rtgui/threadutils.cc index fd3aeda47..070cd2e3c 100644 --- a/rtgui/threadutils.cc +++ b/rtgui/threadutils.cc @@ -29,9 +29,13 @@ MyMutex::MyMutex() : locked(false) {} -void MyMutex::checkLock () +bool MyMutex::checkLock (bool noError) { if (locked) { + if (noError) { + return false; + } + std::cerr << "MyMutex already locked!" << std::endl; #ifdef _WIN32 @@ -42,6 +46,7 @@ void MyMutex::checkLock () } locked = true; + return true; } void MyMutex::checkUnlock () diff --git a/rtgui/threadutils.h b/rtgui/threadutils.h index 401660b93..b4b12ac19 100644 --- a/rtgui/threadutils.h +++ b/rtgui/threadutils.h @@ -59,7 +59,7 @@ public: private: bool locked; - void checkLock (); + bool checkLock (bool noError=false); void checkUnlock (); #endif }; @@ -172,10 +172,10 @@ inline bool MyMutex::trylock () { if (MyMutexBase::try_lock ()) { #if STRICT_MUTEX && !NDEBUG - checkLock (); -#endif - + return checkLock(true); +#else return true; +#endif } return false;