mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:13:28 +02:00
change singleton approach to not require delete
This commit is contained in:
parent
e03c7be5ef
commit
81bff60645
3 changed files with 3 additions and 25 deletions
|
@ -360,7 +360,6 @@ Application::~Application() {
|
|||
|
||||
VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown
|
||||
Menu::getInstance()->deleteLater();
|
||||
MenuScriptingInterface::deleteLaterIfExists();
|
||||
|
||||
_myAvatar = NULL;
|
||||
|
||||
|
|
|
@ -11,26 +11,9 @@
|
|||
#include "MenuScriptingInterface.h"
|
||||
|
||||
|
||||
MenuScriptingInterface* MenuScriptingInterface::_instance = NULL;
|
||||
QMutex MenuScriptingInterface::_instanceMutex;
|
||||
|
||||
MenuScriptingInterface* MenuScriptingInterface::getInstance() {
|
||||
// lock the menu instance mutex to make sure we don't race and create two menus and crash
|
||||
_instanceMutex.lock();
|
||||
if (!_instance) {
|
||||
_instance = new MenuScriptingInterface();
|
||||
}
|
||||
_instanceMutex.unlock();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::deleteLaterIfExists() {
|
||||
_instanceMutex.lock();
|
||||
if (_instance) {
|
||||
_instance->deleteLater();
|
||||
_instance = NULL;
|
||||
}
|
||||
_instanceMutex.unlock();
|
||||
static MenuScriptingInterface sharedInstance;
|
||||
return &sharedInstance;
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::menuItemTriggered() {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#ifndef __hifi__MenuScriptingInterface__
|
||||
#define __hifi__MenuScriptingInterface__
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
@ -21,7 +22,6 @@ class MenuScriptingInterface : public QObject {
|
|||
MenuScriptingInterface() { };
|
||||
public:
|
||||
static MenuScriptingInterface* getInstance();
|
||||
static void deleteLaterIfExists();
|
||||
|
||||
private slots:
|
||||
friend class Menu;
|
||||
|
@ -44,10 +44,6 @@ public slots:
|
|||
|
||||
signals:
|
||||
void menuItemEvent(const QString& menuItem);
|
||||
|
||||
private:
|
||||
static QMutex _instanceMutex;
|
||||
static MenuScriptingInterface* _instance;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MenuScriptingInterface__) */
|
||||
|
|
Loading…
Reference in a new issue