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
11#include "MenuScriptingInterface.h"11#include "MenuScriptingInterface.h"
12 12
13 13
14MenuScriptingInterface* MenuScriptingInterface::_instance = NULL;
15QMutex MenuScriptingInterface::_instanceMutex;
16
17MenuScriptingInterface* MenuScriptingInterface::getInstance() {14MenuScriptingInterface* MenuScriptingInterface::getInstance() {
18 // lock the menu instance mutex to make sure we don't race and create two menus and crash15 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
27void MenuScriptingInterface::deleteLaterIfExists() {
28 _instanceMutex.lock();
29 if (_instance) {
30 _instance->deleteLater();
31 _instance = NULL;
32 }
33 _instanceMutex.unlock();
34}17}
35 18
36void MenuScriptingInterface::menuItemTriggered() {19void MenuScriptingInterface::menuItemTriggered() {