From aac824fb993a4b69e108e8ea393abbce7cad5c37 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 1 Apr 2015 13:47:25 -0700 Subject: [PATCH] fix crash on shutdown --- interface/src/Application.cpp | 3 +++ libraries/entities-renderer/src/EntityTreeRenderer.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7bab72ff0d..6311c0afef 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -566,6 +566,9 @@ void Application::aboutToQuit() { } void Application::cleanupBeforeQuit() { + + _entities.clear(); // this will allow entity scripts to properly shutdown + _datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts ScriptEngine::stopAllScripts(this); // stop all currently running global scripts diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 95ca30a90f..be87d2c993 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -969,6 +969,10 @@ void EntityTreeRenderer::checkAndCallUnload(const EntityItemID& entityID) { QScriptValueList entityArgs = createEntityArgs(entityID); entityScript.property("unload").call(entityScript, entityArgs); } + + // In the event that the entity script connected to any of our signals + // we want to disconnect it so we don't have anything dangling + _entitiesScriptEngine->disconnect(entityScript.toQObject()); } }