mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 09:07:08 +02:00
Tidy JSON relative URLs importing
This commit is contained in:
parent
f2cc30d6d9
commit
4214182b2f
3 changed files with 9 additions and 8 deletions
|
@ -867,7 +867,7 @@ bool Octree::readJSONFromStream(
|
|||
}
|
||||
|
||||
OctreeEntitiesFileParser octreeParser;
|
||||
octreeParser.relativeURL = relativeURL;
|
||||
octreeParser.setRelativeURL(relativeURL);
|
||||
octreeParser.setEntitiesString(jsonBuffer);
|
||||
|
||||
QVariantMap asMap;
|
||||
|
|
|
@ -240,9 +240,9 @@ bool OctreeEntitiesFileParser::readEntitiesArray(QVariantList& entitiesArray) {
|
|||
QJsonObject entityObject = entity.object();
|
||||
|
||||
// resolve urls starting with ./ or ../
|
||||
if (relativeURL.isEmpty() == false) {
|
||||
if (!_relativeURL.isEmpty()) {
|
||||
bool isDirty = false;
|
||||
|
||||
|
||||
const QStringList urlKeys {
|
||||
// model
|
||||
"modelURL",
|
||||
|
@ -280,9 +280,9 @@ bool OctreeEntitiesFileParser::readEntitiesArray(QVariantList& entitiesArray) {
|
|||
|
||||
if (childObject.contains(childKey) && childObject[childKey].isString()) {
|
||||
const QString url = childObject[childKey].toString();
|
||||
|
||||
|
||||
if (url.startsWith("./") || url.startsWith("../")) {
|
||||
childObject[childKey] = relativeURL.resolved(url).toString();
|
||||
childObject[childKey] = _relativeURL.resolved(url).toString();
|
||||
entityObject[entityKey] = childObject;
|
||||
isDirty = true;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ bool OctreeEntitiesFileParser::readEntitiesArray(QVariantList& entitiesArray) {
|
|||
const QString url = entityObject[key].toString();
|
||||
|
||||
if (url.startsWith("./") || url.startsWith("../")) {
|
||||
entityObject[key] = relativeURL.resolved(url).toString();
|
||||
entityObject[key] = _relativeURL.resolved(url).toString();
|
||||
isDirty = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
#define hifi_OctreeEntitiesFileParser_h
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QVariant>
|
||||
#include <QUrl>
|
||||
#include <QVariant>
|
||||
|
||||
class OctreeEntitiesFileParser {
|
||||
public:
|
||||
void setEntitiesString(const QByteArray& entitiesContents);
|
||||
void setRelativeURL(const QUrl& relativeURL) { _relativeURL = relativeURL; }
|
||||
bool parseEntities(QVariantMap& parsedEntities);
|
||||
std::string getErrorString() const;
|
||||
QUrl relativeURL;
|
||||
|
||||
private:
|
||||
int nextToken();
|
||||
|
@ -33,6 +33,7 @@ private:
|
|||
int findMatchingBrace() const;
|
||||
|
||||
QByteArray _entitiesContents;
|
||||
QUrl _relativeURL;
|
||||
int _position { 0 };
|
||||
int _line { 1 };
|
||||
int _entitiesLength { 0 };
|
||||
|
|
Loading…
Reference in a new issue