History

Fix memory leak when reloading scripts

David Rowe committed 8 years ago

Commit 9338c211 parent 87e6df31 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
@@ -438,6 +440,7 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) { · 38 unmodified lines
438 });440 });
439 }441 }
440 scriptEngine->stop();442 scriptEngine->stop();
443 removeScriptEngine(scriptEngine);
441 stoppedScript = true;444 stoppedScript = true;
442 qCDebug(scriptengine) << "stopping script..." << scriptURL;445 qCDebug(scriptengine) << "stopping script..." << scriptURL;
443 }446 }