From 66efbc9a652df96e9e6f3d1fc55ccc643d3216a5 Mon Sep 17 00:00:00 2001 From: Marco Bubke <marco.bubke@nokia.com> Date: Wed, 7 Apr 2010 16:59:25 +0200 Subject: [PATCH] Abort reparenting if list interface is not fully supported --- .../core/instances/objectnodeinstance.cpp | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp b/src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp index db259b6ec4f..4dc99587e72 100644 --- a/src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp +++ b/src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp @@ -331,9 +331,20 @@ static QVariant objectToVariant(QObject *object) return QVariant::fromValue(object); } +static bool hasFullImplementedListInterface(const QDeclarativeListReference &list) +{ + return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear(); +} + static void removeObjectFromList(const QDeclarativeProperty &metaProperty, QObject *objectToBeRemoved, QDeclarativeEngine * engine) { QDeclarativeListReference listReference(metaProperty.object(), metaProperty.name().toLatin1(), engine); + +#ifndef QT_DEBUG + if (!hasFullImplementedListInterface(listReference)) + return; +#endif + int count = listReference.count(); QObjectList objectList; @@ -376,6 +387,12 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c if (isList(metaProperty)) { QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(metaProperty.read()); + +#ifndef QT_DEBUG + if (!hasFullImplementedListInterface(listReference)) + return; +#endif + Q_ASSERT(list.canAppend()); list.append(object); } else if (isObject(metaProperty)) { @@ -469,6 +486,11 @@ void ObjectNodeInstance::deleteObjectsInList(const QDeclarativeProperty &metaPro QObjectList objectList; QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(metaProperty.read()); +#ifndef QT_DEBUG + if (!hasFullImplementedListInterface(list)) + return; +#endif + Q_ASSERT(list.canCount()); Q_ASSERT(list.canAt()); @@ -557,7 +579,12 @@ void ObjectNodeInstance::resetProperty(QObject *object, const QString &propertyN return; property.write(resetValue(propertyName)); } else if (property.propertyTypeCategory() == QDeclarativeProperty::List) { - qvariant_cast<QDeclarativeListReference>(property.read()).clear(); + QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(property.read()); +#ifndef QT_DEBUG + if (!hasFullImplementedListInterface(list)) + return; +#endif + list.clear(); } } -- GitLab