History

Bail early from ScriptEngine::run if stopped

evaluate() bails anyway, so this will avoid the cost of init(). If run() is invoked from runInThread(), this may avoid a race where _isRunning is set after it is checked because the check occured during init().

Zach Pomerantz committed 11 years ago

Commit 6bf9a451 parent 27551b81 file · +5 −4Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+5−4
@@ -646,13 +646,14 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 645 unmodified lines
646646 }
647647
648648 void ScriptEngine::run() {
649− // TODO: can we add a short circuit for _stoppingAllScripts here? What does it mean to not start running if
650− // we're in the process of stopping?
651−
649+ if (_stoppingAllScripts) {
650+ return; // bail early - avoid setting state in init(), as evaluate() will bail too
651+ }
652+
652653 if (!_isInitialized) {
653654 init();
654655 }
655−
656+
656657 _isRunning = true;
657658 _isFinished = false;
658659 if (_wantSignals) {