Fix startup crash in debug build
Do not throw error when trying to get mutex lock.
This commit is contained in:
parent
dab9a3f57e
commit
17b9e7c107
@ -29,9 +29,13 @@
|
|||||||
|
|
||||||
MyMutex::MyMutex() : locked(false) {}
|
MyMutex::MyMutex() : locked(false) {}
|
||||||
|
|
||||||
void MyMutex::checkLock ()
|
bool MyMutex::checkLock (bool noError)
|
||||||
{
|
{
|
||||||
if (locked) {
|
if (locked) {
|
||||||
|
if (noError) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::cerr << "MyMutex already locked!" << std::endl;
|
std::cerr << "MyMutex already locked!" << std::endl;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -42,6 +46,7 @@ void MyMutex::checkLock ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
locked = true;
|
locked = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyMutex::checkUnlock ()
|
void MyMutex::checkUnlock ()
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool locked;
|
bool locked;
|
||||||
void checkLock ();
|
bool checkLock (bool noError=false);
|
||||||
void checkUnlock ();
|
void checkUnlock ();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -172,10 +172,10 @@ inline bool MyMutex::trylock ()
|
|||||||
{
|
{
|
||||||
if (MyMutexBase::try_lock ()) {
|
if (MyMutexBase::try_lock ()) {
|
||||||
#if STRICT_MUTEX && !NDEBUG
|
#if STRICT_MUTEX && !NDEBUG
|
||||||
checkLock ();
|
return checkLock(true);
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user