mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 00:00:00 +02:00
use a mutex to avoid a smaller race
This commit is contained in:
parent
aef39ce6fa
commit
576eed9941
2 changed files with 13 additions and 9 deletions
|
@ -1214,16 +1214,19 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac
|
|||
QString contents = data[url];
|
||||
if (contents.isNull()) {
|
||||
qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
|
||||
} else if (!_includedURLs.contains(url)) {
|
||||
_includedURLs << url;
|
||||
// Set the parent url so that path resolution will be relative
|
||||
// to this script's url during its initial evaluation
|
||||
_parentURL = url.toString();
|
||||
auto operation = [&]() {
|
||||
evaluate(contents, url.toString());
|
||||
};
|
||||
} else {
|
||||
std::lock_guard<std::recursive_mutex> lock(_lock);
|
||||
if (!_includedURLs.contains(url)) {
|
||||
_includedURLs << url;
|
||||
// Set the parent url so that path resolution will be relative
|
||||
// to this script's url during its initial evaluation
|
||||
_parentURL = url.toString();
|
||||
auto operation = [&]() {
|
||||
evaluate(contents, url.toString());
|
||||
};
|
||||
|
||||
doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);
|
||||
doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
_parentURL = parentURL;
|
||||
|
|
|
@ -245,6 +245,7 @@ protected:
|
|||
|
||||
std::function<bool()> _emitScriptUpdates{ [](){ return true; } };
|
||||
|
||||
std::recursive_mutex _lock;
|
||||
};
|
||||
|
||||
#endif // hifi_ScriptEngine_h
|
||||
|
|
Loading…
Reference in a new issue