mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Merge pull request #12538 from huffman/fix/gzipped-json-export
Fix Edit -> Export Entities exporting gzipped json
This commit is contained in:
commit
746f43c0fc
3 changed files with 15 additions and 12 deletions
|
@ -1778,7 +1778,7 @@ bool Octree::writeToFile(const char* fileName, const OctreeElementPointer& eleme
|
|||
return success;
|
||||
}
|
||||
|
||||
bool Octree::toJSON(QJsonDocument* doc, const OctreeElementPointer& element) {
|
||||
bool Octree::toJSONDocument(QJsonDocument* doc, const OctreeElementPointer& element) {
|
||||
QVariantMap entityDescription;
|
||||
|
||||
OctreeElementPointer top;
|
||||
|
@ -1804,18 +1804,22 @@ bool Octree::toJSON(QJsonDocument* doc, const OctreeElementPointer& element) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Octree::toGzippedJSON(QByteArray* data, const OctreeElementPointer& element) {
|
||||
bool Octree::toJSON(QByteArray* data, const OctreeElementPointer& element, bool doGzip) {
|
||||
QJsonDocument doc;
|
||||
if (!toJSON(&doc, element)) {
|
||||
if (!toJSONDocument(&doc, element)) {
|
||||
qCritical("Failed to convert Entities to QVariantMap while converting to json.");
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray jsonData = doc.toJson();
|
||||
if (doGzip) {
|
||||
QByteArray jsonData = doc.toJson();
|
||||
|
||||
if (!gzip(jsonData, *data, -1)) {
|
||||
qCritical("Unable to gzip data while saving to json.");
|
||||
return false;
|
||||
if (!gzip(jsonData, *data, -1)) {
|
||||
qCritical("Unable to gzip data while saving to json.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
*data = doc.toJson();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1825,7 +1829,7 @@ bool Octree::writeToJSONFile(const char* fileName, const OctreeElementPointer& e
|
|||
qCDebug(octree, "Saving JSON SVO to file %s...", fileName);
|
||||
|
||||
QByteArray jsonDataForFile;
|
||||
if (!toGzippedJSON(&jsonDataForFile)) {
|
||||
if (!toJSON(&jsonDataForFile, element, doGzip)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1837,7 +1841,6 @@ bool Octree::writeToJSONFile(const char* fileName, const OctreeElementPointer& e
|
|||
qCritical("Could not write to JSON description of entities.");
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
@ -284,8 +284,8 @@ public:
|
|||
void loadOctreeFile(const char* fileName);
|
||||
|
||||
// Octree exporters
|
||||
bool toJSON(QJsonDocument* doc, const OctreeElementPointer& element = nullptr);
|
||||
bool toGzippedJSON(QByteArray* data, const OctreeElementPointer& element = nullptr);
|
||||
bool toJSONDocument(QJsonDocument* doc, const OctreeElementPointer& element = nullptr);
|
||||
bool toJSON(QByteArray* data, const OctreeElementPointer& element = nullptr, bool doGzip = false);
|
||||
bool writeToFile(const char* filename, const OctreeElementPointer& element = nullptr, QString persistAsFileType = "json.gz");
|
||||
bool writeToJSONFile(const char* filename, const OctreeElementPointer& element = nullptr, bool doGzip = false);
|
||||
virtual bool writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues,
|
||||
|
|
|
@ -341,7 +341,7 @@ void OctreePersistThread::sendLatestEntityDataToDS() {
|
|||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||
|
||||
QByteArray data;
|
||||
if (_tree->toGzippedJSON(&data)) {
|
||||
if (_tree->toJSON(&data, nullptr, true)) {
|
||||
auto message = NLPacketList::create(PacketType::OctreeDataPersist, QByteArray(), true, true);
|
||||
message->write(data);
|
||||
nodeList->sendPacketList(std::move(message), domainHandler.getSockAddr());
|
||||
|
|
Loading…
Reference in a new issue