mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 22:16:39 +02:00
add a mutex lock and unlock on Menu instance creation
This commit is contained in:
parent
7151d1679f
commit
ec909a6c13
1 changed files with 7 additions and 0 deletions
|
@ -36,11 +36,18 @@
|
||||||
Menu* Menu::_instance = NULL;
|
Menu* Menu::_instance = NULL;
|
||||||
|
|
||||||
Menu* Menu::getInstance() {
|
Menu* Menu::getInstance() {
|
||||||
|
static QMutex menuInstanceMutex;
|
||||||
|
|
||||||
|
// lock the menu instance mutex to make sure we don't race and create two menus and crash
|
||||||
|
menuInstanceMutex.lock();
|
||||||
|
|
||||||
if (!_instance) {
|
if (!_instance) {
|
||||||
qDebug("First call to Menu::getInstance() - initing menu.\n");
|
qDebug("First call to Menu::getInstance() - initing menu.\n");
|
||||||
|
|
||||||
_instance = new Menu();
|
_instance = new Menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menuInstanceMutex.unlock();
|
||||||
|
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue