Merge pull request #6842 from Lawrence37/popupcommon-lock-debug-crash

Fix mutex try lock for debug builds
This commit is contained in:
Floessie
2023-09-11 11:00:13 +02:00
committed by GitHub
2 changed files with 10 additions and 5 deletions

View File

@@ -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 ()

View File

@@ -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;