mirror of
https://github.com/glest/glest-source.git
synced 2025-08-12 11:24:00 +02:00
added mutex protection in custom game menu to protect access to member variables to avoid crashes when background thread and user changes both occur
This commit is contained in:
@@ -69,17 +69,23 @@ public:
|
||||
|
||||
MutexSafeWrapper(Mutex *mutex) {
|
||||
this->mutex = mutex;
|
||||
if(this->mutex != NULL) {
|
||||
this->mutex->p();
|
||||
}
|
||||
Lock();
|
||||
}
|
||||
~MutexSafeWrapper() {
|
||||
ReleaseLock();
|
||||
}
|
||||
void ReleaseLock() {
|
||||
|
||||
void Lock() {
|
||||
if(this->mutex != NULL) {
|
||||
this->mutex->p();
|
||||
}
|
||||
}
|
||||
void ReleaseLock(bool keepMutex=false) {
|
||||
if(this->mutex != NULL) {
|
||||
this->mutex->v();
|
||||
this->mutex = NULL;
|
||||
if(keepMutex == false) {
|
||||
this->mutex = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user