fixed crash on shutdown with multiple scripts

This commit is contained in:
ZappoMan 2014-02-13 20:55:16 -08:00
parent 9d841ce918
commit dbd6cb71c9
2 changed files with 12 additions and 2 deletions

View file

@ -11,13 +11,19 @@
#include "OctreeScriptingInterface.h" #include "OctreeScriptingInterface.h"
OctreeScriptingInterface::OctreeScriptingInterface(OctreeEditPacketSender* packetSender, OctreeScriptingInterface::OctreeScriptingInterface(OctreeEditPacketSender* packetSender,
JurisdictionListener* jurisdictionListener) JurisdictionListener* jurisdictionListener) :
_packetSender(NULL),
_jurisdictionListener(NULL),
_managedPacketSender(false),
_managedJurisdictionListener(false),
_initialized(false)
{ {
setPacketSender(packetSender); setPacketSender(packetSender);
setJurisdictionListener(jurisdictionListener); setJurisdictionListener(jurisdictionListener);
} }
OctreeScriptingInterface::~OctreeScriptingInterface() { OctreeScriptingInterface::~OctreeScriptingInterface() {
qDebug() << "OctreeScriptingInterface::~OctreeScriptingInterface() this=" << this;
cleanupManagedObjects(); cleanupManagedObjects();
} }
@ -45,6 +51,9 @@ void OctreeScriptingInterface::setJurisdictionListener(JurisdictionListener* jur
} }
void OctreeScriptingInterface::init() { void OctreeScriptingInterface::init() {
if (_initialized) {
return;
}
if (_jurisdictionListener) { if (_jurisdictionListener) {
_managedJurisdictionListener = false; _managedJurisdictionListener = false;
} else { } else {
@ -64,5 +73,5 @@ void OctreeScriptingInterface::init() {
if (QCoreApplication::instance()) { if (QCoreApplication::instance()) {
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(cleanupManagedObjects())); connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(cleanupManagedObjects()));
} }
_initialized = true;
} }

View file

@ -93,6 +93,7 @@ protected:
JurisdictionListener* _jurisdictionListener; JurisdictionListener* _jurisdictionListener;
bool _managedPacketSender; bool _managedPacketSender;
bool _managedJurisdictionListener; bool _managedJurisdictionListener;
bool _initialized;
}; };
#endif /* defined(__hifi__OctreeScriptingInterface__) */ #endif /* defined(__hifi__OctreeScriptingInterface__) */