mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 08:11:59 +02:00
Add entity url back into entity script filenames
This commit is contained in:
parent
e3be333144
commit
8e3f4b705f
1 changed files with 21 additions and 2 deletions
|
@ -1096,7 +1096,7 @@ QUrl ScriptEngine::resolvePath(const QString& include) const {
|
|||
|
||||
// we apparently weren't a fully qualified url, so, let's assume we're relative
|
||||
// to the original URL of our script
|
||||
QUrl parentURL = contextInfo.fileName();
|
||||
QUrl parentURL = extractUrlFromEntityUrl(contextInfo.fileName());
|
||||
if (parentURL.isEmpty()) {
|
||||
if (_parentURL.isEmpty()) {
|
||||
parentURL = QUrl(_fileNameString);
|
||||
|
@ -1303,6 +1303,25 @@ void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const
|
|||
}, forceRedownload);
|
||||
}
|
||||
|
||||
// The purpose of the following two function is to embed entity ids into entity script filenames
|
||||
// so that they show up in stacktraces
|
||||
//
|
||||
// Extract the url portion of a url that has been encoded with encodeEntityIdIntoEntityUrl(...)
|
||||
QString extractUrlFromEntityUrl(QString url) {
|
||||
auto parts = url.split(' ', QString::SkipEmptyParts);
|
||||
if (parts.length() > 0) {
|
||||
return parts[0];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Encode an entity id into an entity url
|
||||
// Example: http://www.example.com/some/path.js [EntityID:{9fdd355f-d226-4887-9484-44432d29520e}]
|
||||
QString encodeEntityIdIntoEntityUrl(QString url, QString entityID) {
|
||||
return url + " [EntityID:" + entityID + "]";
|
||||
}
|
||||
|
||||
// since all of these operations can be asynch we will always do the actual work in the response handler
|
||||
// for the download
|
||||
void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, const QString& scriptOrURL, const QString& contents, bool isURL, bool success) {
|
||||
|
@ -1329,7 +1348,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co
|
|||
|
||||
auto scriptCache = DependencyManager::get<ScriptCache>();
|
||||
bool isFileUrl = isURL && scriptOrURL.startsWith("file://");
|
||||
auto fileName = isURL ? scriptOrURL : "EmbeddedEntityScript";
|
||||
auto fileName = isURL ? encodeEntityIdIntoEntityUrl(scriptOrURL, entityID) : "EmbeddedEntityScript";
|
||||
|
||||
QScriptProgram program(contents, fileName);
|
||||
if (!hasCorrectSyntax(program)) {
|
||||
|
|
Loading…
Reference in a new issue