Showing the changes to libraries/octree/src/OctreeScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -6,6 +6,8 @@ · 5 unmodified lines | ||
| 6 | 6 | // Copyright (c) 2013 HighFidelity, Inc. All rights reserved. |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | +#include <QCoreApplication> | |
| 10 | + | |
| 9 | 11 | #include "OctreeScriptingInterface.h" |
| 10 | 12 | |
| 11 | 13 | OctreeScriptingInterface::OctreeScriptingInterface(OctreeEditPacketSender* packetSender, |
| @@ -16,18 +18,21 @@ OctreeScriptingInterface::OctreeScriptingInterface(OctreeEditPacketSender* packe · 4 unmodified lines | ||
| 16 | 18 | } |
| 17 | 19 | |
| 18 | 20 | OctreeScriptingInterface::~OctreeScriptingInterface() { |
| 19 | − //printf("OctreeScriptingInterface::~OctreeScriptingInterface()\n"); | |
| 21 | + cleanupManagedObjects(); | |
| 22 | +} | |
| 23 | + | |
| 24 | +void OctreeScriptingInterface::cleanupManagedObjects() { | |
| 20 | 25 | if (_managedJurisdictionListener) { |
| 21 | − //printf("OctreeScriptingInterface::~OctreeScriptingInterface() _managedJurisdictionListener... _jurisdictionListener->terminate()\n"); | |
| 22 | 26 | _jurisdictionListener->terminate(); |
| 23 | − //printf("OctreeScriptingInterface::~OctreeScriptingInterface() _managedJurisdictionListener... deleting _jurisdictionListener\n"); | |
| 24 | − delete _jurisdictionListener; | |
| 27 | + _jurisdictionListener->deleteLater(); | |
| 28 | + _managedJurisdictionListener = false; | |
| 29 | + _jurisdictionListener = NULL; | |
| 25 | 30 | } |
| 26 | 31 | if (_managedPacketSender) { |
| 27 | − //printf("OctreeScriptingInterface::~OctreeScriptingInterface() _managedJurisdictionListener... _packetSender->terminate()\n"); | |
| 28 | 32 | _packetSender->terminate(); |
| 29 | − //printf("OctreeScriptingInterface::~OctreeScriptingInterface() _managedPacketSender... deleting _packetSender\n"); | |
| 30 | − delete _packetSender; | |
| 33 | + _packetSender->deleteLater(); | |
| 34 | + _managedPacketSender = false; | |
| 35 | + _packetSender = NULL; | |
| 31 | 36 | } |
| 32 | 37 | } |
| 33 | 38 | |
| @@ -40,13 +45,11 @@ void OctreeScriptingInterface::setJurisdictionListener(JurisdictionListener* jur · 6 unmodified lines | ||
| 40 | 45 | } |
| 41 | 46 | |
| 42 | 47 | void OctreeScriptingInterface::init() { |
| 43 | − //printf("OctreeScriptingInterface::init()\n"); | |
| 44 | 48 | if (_jurisdictionListener) { |
| 45 | 49 | _managedJurisdictionListener = false; |
| 46 | 50 | } else { |
| 47 | 51 | _managedJurisdictionListener = true; |
| 48 | 52 | _jurisdictionListener = new JurisdictionListener(getServerNodeType()); |
| 49 | − //qDebug("OctreeScriptingInterface::init() _managedJurisdictionListener=true, creating _jurisdictionListener=%p", _jurisdictionListener); | |
| 50 | 53 | _jurisdictionListener->initialize(true); |
| 51 | 54 | } |
| 52 | 55 | |
| @@ -55,7 +58,11 @@ void OctreeScriptingInterface::init() { · 2 unmodified lines | ||
| 55 | 58 | } else { |
| 56 | 59 | _managedPacketSender = true; |
| 57 | 60 | _packetSender = createPacketSender(); |
| 58 | − //qDebug("OctreeScriptingInterface::init() _managedPacketSender=true, creating _packetSender=%p", _packetSender); | |
| 59 | 61 | _packetSender->setServerJurisdictions(_jurisdictionListener->getJurisdictions()); |
| 60 | 62 | } |
| 63 | + | |
| 64 | + if (QCoreApplication::instance()) { | |
| 65 | + connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(cleanupManagedObjects())); | |
| 66 | + } | |
| 67 | + | |
| 61 | 68 | } |