diff --git a/changelog/next.md b/changelog/next.md index cb31dc1..0f9e25c 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -12,3 +12,4 @@ - Fixed unhandled notifications sending `NotificationClosed` out of order. - Fixed `qs kill` not waiting for the process to exit. - Fixed IPC calls from children of a crashed and relaunched process crashing. +- Fixed JsonAdapter crashing when deserializing new objects into an array. diff --git a/src/io/jsonadapter.cpp b/src/io/jsonadapter.cpp index 369ccbe..fbf4b1a 100644 --- a/src/io/jsonadapter.cpp +++ b/src/io/jsonadapter.cpp @@ -225,15 +225,15 @@ void JsonAdapter::deserializeRec(const QJsonObject& json, QObject* obj, const QM const auto& jsonValue = array.at(i); if (jsonValue.isObject()) { if (isNew) { - currentValue = lp.at(&lp, i); - if (this->oldCreatedObjects.removeOne(currentValue)) { - this->createdObjects.push_back(currentValue); - } - } else { // FIXME: should be the type inside the QQmlListProperty but how can we get that? currentValue = static_cast(QMetaType::fromType().create()); currentValue->setParent(this); this->createdObjects.push_back(currentValue); + } else { + currentValue = lp.at(&lp, i); + if (this->oldCreatedObjects.removeOne(currentValue)) { + this->createdObjects.push_back(currentValue); + } } this->deserializeRec(