History

use a mutex to avoid a smaller race

Seth Alves committed 10 years ago

Commit 576eed91 parent aef39ce2 files · +14 −10Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+13−10
@@ -1214,16 +1214,19 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 1213 unmodified lines
12141214 QString contents = data[url];
12151215 if (contents.isNull()) {
12161216 qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
1217− } else if (!_includedURLs.contains(url)) {
1218− _includedURLs << url;
1219− // Set the parent url so that path resolution will be relative
1220− // to this script's url during its initial evaluation
1221− _parentURL = url.toString();
1222− auto operation = [&]() {
1223− evaluate(contents, url.toString());
1224− };
1225−
1226− doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);
1217+ } else {
1218+ std::lock_guard<std::recursive_mutex> lock(_lock);
1219+ if (!_includedURLs.contains(url)) {
1220+ _includedURLs << url;
1221+ // Set the parent url so that path resolution will be relative
1222+ // to this script's url during its initial evaluation
1223+ _parentURL = url.toString();
1224+ auto operation = [&]() {
1225+ evaluate(contents, url.toString());
1226+ };
1227+
1228+ doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);
1229+ }
12271230 }
12281231 }
12291232 _parentURL = parentURL;