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
191 191
192 // Gracefully stop the engine's scripting thread192 // Gracefully stop the engine's scripting thread
193 scriptEngine->stop();193 scriptEngine->stop();
194 removeScriptEngine(scriptEngine);
194 195
195 // We need to wait for the engine to be done running before we proceed, because we don't196 // We need to wait for the engine to be done running before we proceed, because we don't
196 // want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing197 // 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
394 // stop all scripts395 // stop all scripts
395 qCDebug(scriptengine) << "stopping script..." << it.key();396 qCDebug(scriptengine) << "stopping script..." << it.key();
396 scriptEngine->stop();397 scriptEngine->stop();
398 removeScriptEngine(scriptEngine);
397 }399 }
398 // wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before400 // wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before
399 // triggering reload of any Client scripts / Entity scripts401 // triggering reload of any Client scripts / Entity scripts
@@ -441,6 +443,7 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) { · 41 unmodified lines
441 }443 }
442 }444 }
443 scriptEngine->stop();445 scriptEngine->stop();
446 removeScriptEngine(scriptEngine);
444 stoppedScript = true;447 stoppedScript = true;
445 qCDebug(scriptengine) << "stopping script..." << scriptURL;448 qCDebug(scriptengine) << "stopping script..." << scriptURL;
446 }449 }