Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 1 file). Show all
Unified · Split
| @@ -118,9 +118,9 @@ void ScriptEngines::registerScriptInitializer(ScriptInitializer initializer) { · 117 unmodified lines | ||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | void ScriptEngines::addScriptEngine(ScriptEngine* engine) { |
| 121 | − _allScriptsMutex.lock(); | |
| 122 | − _allKnownScriptEngines.insert(engine); | |
| 123 | − _allScriptsMutex.unlock(); | |
| 121 | + if (!_stoppingAllScripts) { | |
| 122 | + _allKnownScriptEngines.insert(engine); | |
| 123 | + } | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | void ScriptEngines::removeScriptEngine(ScriptEngine* engine) { |
| @@ -128,16 +128,15 @@ void ScriptEngines::removeScriptEngine(ScriptEngine* engine) { · 1 unmodified line | ||
| 128 | 128 | // from the list of running scripts. We don't do this if we're in the process of stopping all scripts |
| 129 | 129 | // because that method removes scripts from its list as it iterates them |
| 130 | 130 | if (!_stoppingAllScripts) { |
| 131 | − _allScriptsMutex.lock(); | |
| 131 | + QMutexLocker locker(&_allScriptsMutex); | |
| 132 | 132 | _allKnownScriptEngines.remove(engine); |
| 133 | − _allScriptsMutex.unlock(); | |
| 134 | 133 | } |
| 135 | 134 | } |
| 136 | 135 | |
| 137 | 136 | void ScriptEngines::shutdownScripting() { |
| 138 | − _allScriptsMutex.lock(); | |
| 139 | 137 | _stoppingAllScripts = true; |
| 140 | 138 | ScriptEngine::_stoppingAllScripts = true; |
| 139 | + QMutexLocker locker(&_allScriptsMutex); | |
| 141 | 140 | qCDebug(scriptengine) << "Stopping all scripts.... currently known scripts:" << _allKnownScriptEngines.size(); |
| 142 | 141 | |
| 143 | 142 | QMutableSetIterator<ScriptEngine*> i(_allKnownScriptEngines); |
| @@ -173,8 +172,6 @@ void ScriptEngines::shutdownScripting() { · 29 unmodified lines | ||
| 173 | 172 | i.remove(); |
| 174 | 173 | } |
| 175 | 174 | } |
| 176 | − _stoppingAllScripts = false; | |
| 177 | − _allScriptsMutex.unlock(); | |
| 178 | 175 | qCDebug(scriptengine) << "DONE Stopping all scripts...."; |
| 179 | 176 | } |
| 180 | 177 | |