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
1214 QString contents = data[url];1214 QString contents = data[url];
1215 if (contents.isNull()) {1215 if (contents.isNull()) {
1216 qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;1216 qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
1217 } else if (!_includedURLs.contains(url)) {1217 } else {
1218 _includedURLs << url;1218 std::lock_guard<std::recursive_mutex> lock(_lock);
1219 // Set the parent url so that path resolution will be relative1219 if (!_includedURLs.contains(url)) {
1220 // to this script's url during its initial evaluation1220 _includedURLs << url;
1221 _parentURL = url.toString();1221 // Set the parent url so that path resolution will be relative
1222 auto operation = [&]() {1222 // to this script's url during its initial evaluation
1223 evaluate(contents, url.toString());1223 _parentURL = url.toString();
1224 };1224 auto operation = [&]() {
1225 1225 evaluate(contents, url.toString());
1226 doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);1226 };
1227
1228 doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);
1229 }
1227 }1230 }
1228 }1231 }
1229 _parentURL = parentURL;1232 _parentURL = parentURL;