From aaff22f4b0239529f738770fa3c4388438f219fc Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 3 Apr 2026 21:28:09 -0700 Subject: [PATCH] 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. --- changelog/next.md | 1 + src/io/jsonadapter.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/changelog/next.md b/changelog/next.md index 8b22d07..3059cc9 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -66,6 +66,7 @@ set shell id. - Worked around Qt bug causing crashes when plugging and unplugging monitors. - Fixed HyprlandFocusGrab crashing if windows were destroyed after being passed to it. - Fixed ScreencopyView pixelation when scaled. +- Fixed JsonAdapter crashing and providing bad data on read when using JsonObject. ## Packaging Changes diff --git a/src/io/jsonadapter.cpp b/src/io/jsonadapter.cpp index e80c6f2..68e85ab 100644 --- a/src/io/jsonadapter.cpp +++ b/src/io/jsonadapter.cpp @@ -155,13 +155,13 @@ void JsonAdapter::deserializeRec(const QJsonObject& json, QObject* obj, const QM if (prop.metaType() == QMetaType::fromType()) { auto variant = jval.toVariant(); - auto oldValue = prop.read(this).value(); + auto oldValue = prop.read(obj).value(); // 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(jval.toVariant()); - prop.write(this, QVariant::fromValue(jsValue)); + prop.write(obj, QVariant::fromValue(jsValue)); } } else if (QMetaType::canView(prop.metaType(), QMetaType::fromType())) { // 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>() )) { - auto pval = prop.read(this); + auto pval = prop.read(obj); if (pval.canConvert>()) { auto lp = pval.value>();