mirror of
https://github.com/quickshell-mirror/quickshell.git
synced 2026-10-27 02:54:36 +00:00
io/fileview: convert containers to QVariantList/Map before serialize
QJsonValue::fromVariant doesn't do this automatically for some reason.
This commit is contained in:
2 files changed
+12
-6
No files matched your search
@@ -69,6 +69,7 @@ set shell id.
|
||||
- Fixed ScreencopyView pixelation when scaled.
|
||||
- Fixed JsonAdapter crashing and providing bad data on read when using JsonObject.
|
||||
- Fixed JsonAdapter sending unnecessary property changes for primitive values.
|
||||
- Fixed JsonAdapter serialization for lists.
|
||||
|
||||
## Packaging Changes
|
||||
|
||||
|
||||
+11
-6
@@ -1,5 +1,6 @@
|
||||
#include "jsonadapter.hpp"
|
||||
|
||||
#include <qassociativeiterable.h>
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qjsonarray.h>
|
||||
#include <qjsondocument.h>
|
||||
@@ -14,6 +15,7 @@
|
||||
#include <qqmlengine.h>
|
||||
#include <qqmlinfo.h>
|
||||
#include <qqmllist.h>
|
||||
#include <qsequentialiterable.h>
|
||||
#include <qstringview.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
@@ -131,13 +133,16 @@ QJsonObject JsonAdapter::serializeRec(const QObject* obj, const QMetaObject* bas
|
||||
}
|
||||
|
||||
json.insert(prop.name(), array);
|
||||
} else if (val.canConvert<QJSValue>()) {
|
||||
auto variant = val.value<QJSValue>().toVariant();
|
||||
auto jv = QJsonValue::fromVariant(variant);
|
||||
json.insert(prop.name(), jv);
|
||||
} else {
|
||||
auto jv = QJsonValue::fromVariant(val);
|
||||
json.insert(prop.name(), jv);
|
||||
if (val.canConvert<QJSValue>()) val = val.value<QJSValue>().toVariant();
|
||||
|
||||
if (val.canConvert<QAssociativeIterable>()) {
|
||||
val.convert(QMetaType::fromType<QVariantMap>());
|
||||
} else if (val.canConvert<QSequentialIterable>()) {
|
||||
val.convert(QMetaType::fromType<QVariantList>());
|
||||
}
|
||||
|
||||
json.insert(prop.name(), QJsonValue::fromVariant(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user