diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5a84c7895a..baa7dd633d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -336,6 +336,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _datagramProcessor = new DatagramProcessor(nodeList.data()); + // have the NodeList use deleteLater from DM customDeleter + nodeList->setCustomDeleter([](Dependency* dependency) { + static_cast(dependency)->deleteLater(); + }); + // put the NodeList and datagram processing on the node thread nodeList->moveToThread(nodeThread); @@ -609,9 +614,8 @@ Application::~Application() { //DependencyManager::destroy(); DependencyManager::destroy(); - auto nodeList = DependencyManager::get(); - QThread* nodeThread = nodeList->thread(); - nodeList->deleteLater(); + QThread* nodeThread = DependencyManager::get()->thread(); + DependencyManager::destroy(); // ask the node thread to quit and wait until it is done nodeThread->quit(); diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index 1c6de4bb6c..ccfaa7a4cf 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -37,6 +37,7 @@ const quint64 DOMAIN_SERVER_CHECK_IN_MSECS = 1 * 1000; const int MAX_SILENT_DOMAIN_SERVER_CHECK_INS = 5; +class Application; class Assignment; class NodeList : public LimitedNodeList { @@ -95,6 +96,8 @@ private: HifiSockAddr _assignmentServerSocket; bool _hasCompletedInitialSTUNFailure; unsigned int _stunRequestsSinceSuccess; + + friend class Application; }; #endif // hifi_NodeList_h