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
646}646}
647 647
648void ScriptEngine::run() {648void ScriptEngine::run() {
649 // TODO: can we add a short circuit for _stoppingAllScripts here? What does it mean to not start running if649 if (_stoppingAllScripts) {
650 // we're in the process of stopping?650 return; // bail early - avoid setting state in init(), as evaluate() will bail too
651 651 }
652
652 if (!_isInitialized) {653 if (!_isInitialized) {
653 init();654 init();
654 }655 }
655 656
656 _isRunning = true;657 _isRunning = true;
657 _isFinished = false;658 _isFinished = false;
658 if (_wantSignals) {659 if (_wantSignals) {