History

change singleton approach to not require delete

ZappoMan committed 12 years ago

Commit 81bff601 parent e03c7be3 files · +3 −25Browse files

Showing the changes to interface/src/MenuScriptingInterface.cpp (1 of 3 files). Show all

Unified · Split

interface/src/MenuScriptingInterface.cpp+2−19
@@ -11,26 +11,9 @@ · 10 unmodified lines
1111 #include "MenuScriptingInterface.h"
1212
1313
14−MenuScriptingInterface* MenuScriptingInterface::_instance = NULL;
15−QMutex MenuScriptingInterface::_instanceMutex;
16−
1714 MenuScriptingInterface* MenuScriptingInterface::getInstance() {
18− // lock the menu instance mutex to make sure we don't race and create two menus and crash
19− _instanceMutex.lock();
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();
15+ static MenuScriptingInterface sharedInstance;
16+ return &sharedInstance;
3417 }
3518
3619 void MenuScriptingInterface::menuItemTriggered() {