mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-17 06:50:11 +02:00
Merge pull request #1289 from birarda/master
add a mutex lock and unlock on Menu instance creation
This commit is contained in:
commit
d4847987bf
1 changed files with 7 additions and 0 deletions
|
@ -36,11 +36,18 @@
|
|||
Menu* Menu::_instance = NULL;
|
||||
|
||||
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) {
|
||||
qDebug("First call to Menu::getInstance() - initing menu.\n");
|
||||
|
||||
_instance = new Menu();
|
||||
}
|
||||
|
||||
menuInstanceMutex.unlock();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue