From 9338c217cd5e6dd1f53ff8c70138718a0144fecd Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 9 Jun 2018 16:58:49 +1200 Subject: [PATCH] Fix memory leak when reloading scripts --- libraries/script-engine/src/ScriptEngines.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index ad6e1debe9..39df9406bc 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -191,6 +191,7 @@ void ScriptEngines::shutdownScripting() { // Gracefully stop the engine's scripting thread scriptEngine->stop(); + removeScriptEngine(scriptEngine); // We need to wait for the engine to be done running before we proceed, because we don't // want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing @@ -394,6 +395,7 @@ void ScriptEngines::stopAllScripts(bool restart) { // stop all scripts qCDebug(scriptengine) << "stopping script..." << it.key(); scriptEngine->stop(); + removeScriptEngine(scriptEngine); } // wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before // triggering reload of any Client scripts / Entity scripts @@ -438,6 +440,7 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) { }); } scriptEngine->stop(); + removeScriptEngine(scriptEngine); stoppedScript = true; qCDebug(scriptengine) << "stopping script..." << scriptURL; }