History

Consolidate stoppingAllScripts to ScriptEngines::_stopped

Zach Pomerantz committed 10 years ago

Commit 70d0ebb1 parent 68731974 files · +11 −18Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+7−9
@@ -52,8 +52,6 @@ · 51 unmodified lines
5252
5353 #include "MIDIEvent.h"
5454
55−std::atomic<bool> ScriptEngine::_stoppingAllScripts { false };
56−
5755 static const QString SCRIPT_EXCEPTION_FORMAT = "[UncaughtException] %1 in %2:%3";
5856
5957 Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature)
@@ -655,7 +653,7 @@ void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& · 595 unmodified lines
655653
656654
657655 QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fileName, int lineNumber) {
658− if (_stoppingAllScripts) {
656+ if (DependencyManager::get<ScriptEngines>()->_stopped) {
659657 return QScriptValue(); // bail early
660658 }
661659
@@ -691,7 +689,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 29 unmodified lines
691689 }
692690
693691 void ScriptEngine::run() {
694− if (_stoppingAllScripts) {
692+ if (DependencyManager::get<ScriptEngines>()->_stopped) {
695693 return; // bail early - avoid setting state in init(), as evaluate() will bail too
696694 }
697695
@@ -901,7 +899,7 @@ QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int · 203 unmodified lines
901899 }
902900
903901 QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) {
904− if (_stoppingAllScripts) {
902+ if (DependencyManager::get<ScriptEngines>()->_stopped) {
905903 qCDebug(scriptengine) << "Script.setInterval() while shutting down is ignored... parent script:" << getFilename();
906904 return NULL; // bail early
907905 }
@@ -910,7 +908,7 @@ QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) · 2 unmodified lines
910908 }
911909
912910 QObject* ScriptEngine::setTimeout(const QScriptValue& function, int timeoutMS) {
913− if (_stoppingAllScripts) {
911+ if (DependencyManager::get<ScriptEngines>()->_stopped) {
914912 qCDebug(scriptengine) << "Script.setTimeout() while shutting down is ignored... parent script:" << getFilename();
915913 return NULL; // bail early
916914 }
@@ -962,7 +960,7 @@ void ScriptEngine::print(const QString& message) { · 45 unmodified lines
962960 // If no callback is specified, the included files will be loaded synchronously and will block execution until
963961 // all of the files have finished loading.
964962 void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) {
965− if (_stoppingAllScripts) {
963+ if (DependencyManager::get<ScriptEngines>()->_stopped) {
966964 qCDebug(scriptengine) << "Script.include() while shutting down is ignored..."
967965 << "includeFiles:" << includeFiles << "parent script:" << getFilename();
968966 return; // bail early
@@ -1063,7 +1061,7 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 94 unmodified lines
10631061 }
10641062
10651063 void ScriptEngine::include(const QString& includeFile, QScriptValue callback) {
1066− if (_stoppingAllScripts) {
1064+ if (DependencyManager::get<ScriptEngines>()->_stopped) {
10671065 qCDebug(scriptengine) << "Script.include() while shutting down is ignored... "
10681066 << "includeFile:" << includeFile << "parent script:" << getFilename();
10691067 return; // bail early
@@ -1078,7 +1076,7 @@ void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { · 8 unmodified lines
10781076 // as a stand-alone script. To accomplish this, the ScriptEngine class just emits a signal which
10791077 // the Application or other context will connect to in order to know to actually load the script
10801078 void ScriptEngine::load(const QString& loadFile) {
1081− if (_stoppingAllScripts) {
1079+ if (DependencyManager::get<ScriptEngines>()->_stopped) {
10821080 qCDebug(scriptengine) << "Script.load() while shutting down is ignored... "
10831081 << "loadFile:" << loadFile << "parent script:" << getFilename();
10841082 return; // bail early