aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvmemetaobject.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-01-07 10:04:25 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-01-13 16:47:57 +0100
commitd2b3cb0a8794dacbe929ae67447d16377efbccd7 (patch)
tree0cce7492bfc3bfea28a5197618389f2bfcae9e52 /src/qml/qml/qqmlvmemetaobject.cpp
parentdfea0cdb0b731c5ed06513bb620a058b49fbb266 (diff)
QQmlMetaObject: Don't assert on validity of list properties
Apparently the memberdata can be nullptr as long as you don't try to access it. This is what readPropertyAsList() does, and the ResolvedList ctor should follow suit. Fixes: QTBUG-81032 Change-Id: I9133ea9f7889884b2e91dba7630c4827fc97136d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index eff13ef2c3..42a90e234c 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -75,18 +75,23 @@ public:
Q_ASSERT(m_metaObject->object == prop->object);
Q_ASSERT(m_id <= quintptr(std::numeric_limits<int>::max() - m_metaObject->methodOffset()));
- // readPropertyAsList() with all the checks transformed into Q_ASSERT
+ // readPropertyAsList() with checks transformed into Q_ASSERT
// and without allocation.
- Q_ASSERT(!m_metaObject->propertyAndMethodStorage.isUndefined());
- auto *md = static_cast<QV4::MemberData *>(m_metaObject->propertyAndMethodStorage.asManaged());
- Q_ASSERT(md);
- const auto *v = (md->data() + m_id)->as<QV4::VariantObject>();
- Q_ASSERT(v);
- Q_ASSERT(v->d());
- QVariant &data = v->d()->data();
- Q_ASSERT(data.userType() == qMetaTypeId<QVector<QQmlGuard<QObject>>>());
- m_list = static_cast<QVector<QQmlGuard<QObject>> *>(data.data());
- Q_ASSERT(m_list);
+ if (m_metaObject->propertyAndMethodStorage.isUndefined() &&
+ m_metaObject->propertyAndMethodStorage.valueRef()) {
+ return;
+ }
+
+ if (auto *md = static_cast<QV4::MemberData *>(
+ m_metaObject->propertyAndMethodStorage.asManaged())) {
+ const auto *v = (md->data() + m_id)->as<QV4::VariantObject>();
+ Q_ASSERT(v);
+ Q_ASSERT(v->d());
+ QVariant &data = v->d()->data();
+ Q_ASSERT(data.userType() == qMetaTypeId<QVector<QQmlGuard<QObject>>>());
+ m_list = static_cast<QVector<QQmlGuard<QObject>> *>(data.data());
+ Q_ASSERT(m_list);
+ }
}
~ResolvedList() = default;