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
52 52
53#include "MIDIEvent.h"53#include "MIDIEvent.h"
54 54
55std::atomic<bool> ScriptEngine::_stoppingAllScripts { false };
56
57static const QString SCRIPT_EXCEPTION_FORMAT = "[UncaughtException] %1 in %2:%3";55static const QString SCRIPT_EXCEPTION_FORMAT = "[UncaughtException] %1 in %2:%3";
58 56
59Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature)57Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature)
@@ -655,7 +653,7 @@ void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& · 595 unmodified lines
655 653
656 654
657QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fileName, int lineNumber) {655QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fileName, int lineNumber) {
658 if (_stoppingAllScripts) {656 if (DependencyManager::get<ScriptEngines>()->_stopped) {
659 return QScriptValue(); // bail early657 return QScriptValue(); // bail early
660 }658 }
661 659
@@ -691,7 +689,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 29 unmodified lines
691}689}
692 690
693void ScriptEngine::run() {691void ScriptEngine::run() {
694 if (_stoppingAllScripts) {692 if (DependencyManager::get<ScriptEngines>()->_stopped) {
695 return; // bail early - avoid setting state in init(), as evaluate() will bail too693 return; // bail early - avoid setting state in init(), as evaluate() will bail too
696 }694 }
697 695
@@ -901,7 +899,7 @@ QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int · 203 unmodified lines
901}899}
902 900
903QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) {901QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) {
904 if (_stoppingAllScripts) {902 if (DependencyManager::get<ScriptEngines>()->_stopped) {
905 qCDebug(scriptengine) << "Script.setInterval() while shutting down is ignored... parent script:" << getFilename();903 qCDebug(scriptengine) << "Script.setInterval() while shutting down is ignored... parent script:" << getFilename();
906 return NULL; // bail early904 return NULL; // bail early
907 }905 }
@@ -910,7 +908,7 @@ QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) · 2 unmodified lines
910}908}
911 909
912QObject* ScriptEngine::setTimeout(const QScriptValue& function, int timeoutMS) {910QObject* ScriptEngine::setTimeout(const QScriptValue& function, int timeoutMS) {
913 if (_stoppingAllScripts) {911 if (DependencyManager::get<ScriptEngines>()->_stopped) {
914 qCDebug(scriptengine) << "Script.setTimeout() while shutting down is ignored... parent script:" << getFilename();912 qCDebug(scriptengine) << "Script.setTimeout() while shutting down is ignored... parent script:" << getFilename();
915 return NULL; // bail early913 return NULL; // bail early
916 }914 }
@@ -962,7 +960,7 @@ void ScriptEngine::print(const QString& message) { · 45 unmodified lines
962// If no callback is specified, the included files will be loaded synchronously and will block execution until960// If no callback is specified, the included files will be loaded synchronously and will block execution until
963// all of the files have finished loading.961// all of the files have finished loading.
964void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) {962void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) {
965 if (_stoppingAllScripts) {963 if (DependencyManager::get<ScriptEngines>()->_stopped) {
966 qCDebug(scriptengine) << "Script.include() while shutting down is ignored..."964 qCDebug(scriptengine) << "Script.include() while shutting down is ignored..."
967 << "includeFiles:" << includeFiles << "parent script:" << getFilename();965 << "includeFiles:" << includeFiles << "parent script:" << getFilename();
968 return; // bail early966 return; // bail early
@@ -1063,7 +1061,7 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 94 unmodified lines
1063}1061}
1064 1062
1065void ScriptEngine::include(const QString& includeFile, QScriptValue callback) {1063void ScriptEngine::include(const QString& includeFile, QScriptValue callback) {
1066 if (_stoppingAllScripts) {1064 if (DependencyManager::get<ScriptEngines>()->_stopped) {
1067 qCDebug(scriptengine) << "Script.include() while shutting down is ignored... "1065 qCDebug(scriptengine) << "Script.include() while shutting down is ignored... "
1068 << "includeFile:" << includeFile << "parent script:" << getFilename();1066 << "includeFile:" << includeFile << "parent script:" << getFilename();
1069 return; // bail early1067 return; // bail early
@@ -1078,7 +1076,7 @@ void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { · 8 unmodified lines
1078// as a stand-alone script. To accomplish this, the ScriptEngine class just emits a signal which1076// as a stand-alone script. To accomplish this, the ScriptEngine class just emits a signal which
1079// the Application or other context will connect to in order to know to actually load the script1077// the Application or other context will connect to in order to know to actually load the script
1080void ScriptEngine::load(const QString& loadFile) {1078void ScriptEngine::load(const QString& loadFile) {
1081 if (_stoppingAllScripts) {1079 if (DependencyManager::get<ScriptEngines>()->_stopped) {
1082 qCDebug(scriptengine) << "Script.load() while shutting down is ignored... "1080 qCDebug(scriptengine) << "Script.load() while shutting down is ignored... "
1083 << "loadFile:" << loadFile << "parent script:" << getFilename();1081 << "loadFile:" << loadFile << "parent script:" << getFilename();
1084 return; // bail early1082 return; // bail early