Showing the changes to interface/src/MenuScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -11,26 +11,9 @@ · 10 unmodified lines | |||
| 11 | #include "MenuScriptingInterface.h" | 11 | #include "MenuScriptingInterface.h" |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | MenuScriptingInterface* MenuScriptingInterface::_instance = NULL; | ||
| 15 | QMutex MenuScriptingInterface::_instanceMutex; | ||
| 16 | |||
| 17 | MenuScriptingInterface* MenuScriptingInterface::getInstance() { | 14 | MenuScriptingInterface* MenuScriptingInterface::getInstance() { |
| 18 | // lock the menu instance mutex to make sure we don't race and create two menus and crash | 15 | static MenuScriptingInterface sharedInstance; |
| 19 | _instanceMutex.lock(); | 16 | return &sharedInstance; |
| 20 | if (!_instance) { | ||
| 21 | _instance = new MenuScriptingInterface(); | ||
| 22 | } | ||
| 23 | _instanceMutex.unlock(); | ||
| 24 | return _instance; | ||
| 25 | } | ||
| 26 | |||
| 27 | void MenuScriptingInterface::deleteLaterIfExists() { | ||
| 28 | _instanceMutex.lock(); | ||
| 29 | if (_instance) { | ||
| 30 | _instance->deleteLater(); | ||
| 31 | _instance = NULL; | ||
| 32 | } | ||
| 33 | _instanceMutex.unlock(); | ||
| 34 | } | 17 | } |
| 35 | 18 | ||
| 36 | void MenuScriptingInterface::menuItemTriggered() { | 19 | void MenuScriptingInterface::menuItemTriggered() { |