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().
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -646,13 +646,14 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 645 unmodified lines | ||
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | 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 | + | |
| 652 | 653 | if (!_isInitialized) { |
| 653 | 654 | init(); |
| 654 | 655 | } |
| 655 | − | |
| 656 | + | |
| 656 | 657 | _isRunning = true; |
| 657 | 658 | _isFinished = false; |
| 658 | 659 | if (_wantSignals) { |