Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 4 files). Show all
Unified · Split
| @@ -52,8 +52,6 @@ · 51 unmodified lines | |||
| 52 | 52 | ||
| 53 | #include "MIDIEvent.h" | 53 | #include "MIDIEvent.h" |
| 54 | 54 | ||
| 55 | std::atomic<bool> ScriptEngine::_stoppingAllScripts { false }; | ||
| 56 | |||
| 57 | static const QString SCRIPT_EXCEPTION_FORMAT = "[UncaughtException] %1 in %2:%3"; | 55 | static const QString SCRIPT_EXCEPTION_FORMAT = "[UncaughtException] %1 in %2:%3"; |
| 58 | 56 | ||
| 59 | Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature) | 57 | Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature) |
| @@ -655,7 +653,7 @@ void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& · 595 unmodified lines | |||
| 655 | 653 | ||
| 656 | 654 | ||
| 657 | QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fileName, int lineNumber) { | 655 | QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fileName, int lineNumber) { |
| 658 | if (_stoppingAllScripts) { | 656 | if (DependencyManager::get<ScriptEngines>()->_stopped) { |
| 659 | return QScriptValue(); // bail early | 657 | 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 | ||
| 693 | void ScriptEngine::run() { | 691 | void ScriptEngine::run() { |
| 694 | if (_stoppingAllScripts) { | 692 | if (DependencyManager::get<ScriptEngines>()->_stopped) { |
| 695 | return; // bail early - avoid setting state in init(), as evaluate() will bail too | 693 | 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 | ||
| 903 | QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) { | 901 | QObject* 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 early | 904 | 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 | ||
| 912 | QObject* ScriptEngine::setTimeout(const QScriptValue& function, int timeoutMS) { | 910 | QObject* 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 early | 913 | 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 until | 960 | // 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. |
| 964 | void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) { | 962 | void 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 early | 966 | return; // bail early |
| @@ -1063,7 +1061,7 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 94 unmodified lines | |||
| 1063 | } | 1061 | } |
| 1064 | 1062 | ||
| 1065 | void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { | 1063 | void 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 early | 1067 | 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 which | 1076 | // 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 script | 1077 | // the Application or other context will connect to in order to know to actually load the script |
| 1080 | void ScriptEngine::load(const QString& loadFile) { | 1078 | void 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 early | 1082 | return; // bail early |