History

Merge pull request #16137 from jherico/fix/bugz-1398

Sam Gateau committed 7 years ago

Commit acf51ad2 parents 5d316a9 0511f879 files · +109 −4Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+10−0
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838
3939 #include <QtScriptTools/QScriptEngineDebugger>
4040
41+#include <shared/LocalFileAccessGate.h>
4142 #include <shared/QtHelpers.h>
4243 #include <AudioConstants.h>
4344 #include <AudioEffectOptions.h>
@@ -1123,6 +1124,12 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 1079 unmodified lines
11231124 }
11241125
11251126 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+
11261133 auto filenameParts = _fileNameString.split("/");
11271134 auto name = filenameParts.size() > 0 ? filenameParts[filenameParts.size() - 1] : "unknown";
11281135 PROFILE_SET_THREAD_NAME("Script: " + name);
@@ -1300,6 +1307,9 @@ void ScriptEngine::run() { · 171 unmodified lines
13001307
13011308 emit finished(_fileNameString, qSharedPointerCast<ScriptEngine>(sharedFromThis()));
13021309
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);
13031313 _isRunning = false;
13041314 emit runningStateChanged();
13051315 emit doneRunning();