io/fileview: write values into correct JsonObjects in deserialize

Property writes were being done on the JsonAdapter and not the child
JsonObject, resulting in the data of children being set on the
adapter's props, and occasional crashes.
This commit is contained in:
outfoxxed 2026-04-03 21:28:09 -07:00
parent 50cdf98868
commit aaff22f4b0
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
2 changed files with 4 additions and 3 deletions

View file

@ -155,13 +155,13 @@ void JsonAdapter::deserializeRec(const QJsonObject& json, QObject* obj, const QM
if (prop.metaType() == QMetaType::fromType<QVariant>()) {
auto variant = jval.toVariant();
auto oldValue = prop.read(this).value<QJSValue>();
auto oldValue = prop.read(obj).value<QJSValue>();
// Calling prop.write with a new QJSValue will cause a property update
// even if content is identical.
if (jval.toVariant() != oldValue.toVariant()) {
auto jsValue = qmlEngine(this)->fromVariant<QJSValue>(jval.toVariant());
prop.write(this, QVariant::fromValue(jsValue));
prop.write(obj, QVariant::fromValue(jsValue));
}
} else if (QMetaType::canView(prop.metaType(), QMetaType::fromType<JsonObject*>())) {
// FIXME: This doesn't support creating descendants of JsonObject, as QMetaType.metaObject()
@ -196,7 +196,7 @@ void JsonAdapter::deserializeRec(const QJsonObject& json, QObject* obj, const QM
QMetaType::fromType<QQmlListProperty<JsonObject>>()
))
{
auto pval = prop.read(this);
auto pval = prop.read(obj);
if (pval.canConvert<QQmlListProperty<JsonObject>>()) {
auto lp = pval.value<QQmlListProperty<JsonObject>>();