Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 9 files). Show all
Unified · Split
| @@ -38,6 +38,7 @@ · 37 unmodified lines | ||
| 38 | 38 | |
| 39 | 39 | #include <QtScriptTools/QScriptEngineDebugger> |
| 40 | 40 | |
| 41 | +#include <shared/LocalFileAccessGate.h> | |
| 41 | 42 | #include <shared/QtHelpers.h> |
| 42 | 43 | #include <AudioConstants.h> |
| 43 | 44 | #include <AudioEffectOptions.h> |
| @@ -1123,6 +1124,12 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 1079 unmodified lines | ||
| 1123 | 1124 | } |
| 1124 | 1125 | |
| 1125 | 1126 | void ScriptEngine::run() { |
| 1127 | + if (QThread::currentThread() != qApp->thread() && _context == Context::CLIENT_SCRIPT) { | |
| 1128 | + // Flag that we're allowed to access local HTML files on UI created from C++ calls on this thread | |
| 1129 | + // (because we're a client script) | |
| 1130 | + hifi::scripting::setLocalAccessSafeThread(true); | |
| 1131 | + } | |
| 1132 | + | |
| 1126 | 1133 | auto filenameParts = _fileNameString.split("/"); |
| 1127 | 1134 | auto name = filenameParts.size() > 0 ? filenameParts[filenameParts.size() - 1] : "unknown"; |
| 1128 | 1135 | PROFILE_SET_THREAD_NAME("Script: " + name); |
| @@ -1300,6 +1307,9 @@ void ScriptEngine::run() { · 171 unmodified lines | ||
| 1300 | 1307 | |
| 1301 | 1308 | emit finished(_fileNameString, qSharedPointerCast<ScriptEngine>(sharedFromThis())); |
| 1302 | 1309 | |
| 1310 | + // Don't leave our local-file-access flag laying around, reset it to false when the scriptengine | |
| 1311 | + // thread is finished | |
| 1312 | + hifi::scripting::setLocalAccessSafeThread(false); | |
| 1303 | 1313 | _isRunning = false; |
| 1304 | 1314 | emit runningStateChanged(); |
| 1305 | 1315 | emit doneRunning(); |