History

Merge pull request #13345 from ctrlaltdavid/21890

Fix memory leak when reloading scripts

Seth Alves committed 8 years ago

Commit 01632dd2 parents d9f8cd4 9338c211 file · +3 −0Browse files

Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngines.cpp+3−0
@@ -191,6 +191,7 @@ void ScriptEngines::shutdownScripting() { · 190 unmodified lines
191191
192192 // Gracefully stop the engine's scripting thread
193193 scriptEngine->stop();
194+ removeScriptEngine(scriptEngine);
194195
195196 // We need to wait for the engine to be done running before we proceed, because we don't
196197 // want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing
@@ -394,6 +395,7 @@ void ScriptEngines::stopAllScripts(bool restart) { · 197 unmodified lines
394395 // stop all scripts
395396 qCDebug(scriptengine) << "stopping script..." << it.key();
396397 scriptEngine->stop();
398+ removeScriptEngine(scriptEngine);
397399 }
398400 // wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before
399401 // triggering reload of any Client scripts / Entity scripts
@@ -441,6 +443,7 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) { · 41 unmodified lines
441443 }
442444 }
443445 scriptEngine->stop();
446+ removeScriptEngine(scriptEngine);
444447 stoppedScript = true;
445448 qCDebug(scriptengine) << "stopping script..." << scriptURL;
446449 }