diff options
author | Marco Bubke <marco.bubke@nokia.com> | 2010-04-13 19:39:23 +0200 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2010-04-16 16:35:52 +0200 |
commit | e0d4c800cfe3d140fc50a0443a3e10833d175c23 (patch) | |
tree | 2f36a823215fc5b336978f6644056427491cd9cd | |
parent | cf06801cd0ea3cba657c1112a0a03d0c2612fbb7 (diff) |
Don't interact with list there the interface is not fully implemented
I changed this because we get "false" crash reports.
Reviewed-by: kkoehne
(cherry picked from commit 2eb96a8ed3f2b10c1ab5479b5ae514f15f4fe70c)
-rw-r--r-- | src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp b/src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp index 30fe189b54..b1881bdeef 100644 --- a/src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp +++ b/src/plugins/qmldesigner/core/instances/objectnodeinstance.cpp @@ -59,9 +59,13 @@ #include <QFileSystemWatcher> #include <QPixmapCache> +#include <QTextDocument> + #include <private/qdeclarativebinding_p.h> #include <private/qdeclarativemetatype_p.h> #include <private/qdeclarativevaluetype_p.h> +#include <private/qdeclarativetext_p.h> +#include <private/qdeclarativetext_p_p.h> namespace QmlDesigner { namespace Internal { @@ -340,27 +344,23 @@ static void removeObjectFromList(const QDeclarativeProperty &metaProperty, QObje { QDeclarativeListReference listReference(metaProperty.object(), metaProperty.name().toLatin1(), engine); -#ifndef QT_DEBUG - if (!hasFullImplementedListInterface(listReference)) + if (!hasFullImplementedListInterface(listReference)) { + qWarning() << "Property list interface not fully implemented for Class " << metaProperty.property().typeName() << " in property " << metaProperty.name() << "!"; return; -#endif + } int count = listReference.count(); QObjectList objectList; - Q_ASSERT(listReference.canCount()); - Q_ASSERT(listReference.canAt()); for(int i = 0; i < count; i ++) { QObject *listItem = listReference.at(i); if (listItem != objectToBeRemoved) objectList.append(listItem); } - Q_ASSERT(listReference.canClear()); listReference.clear(); - Q_ASSERT(listReference.canAppend()); foreach(QObject *object, objectList) listReference.append(object); } @@ -388,16 +388,16 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c if (isList(metaProperty)) { QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(metaProperty.read()); -#ifndef QT_DEBUG - if (!hasFullImplementedListInterface(list)) + if (!hasFullImplementedListInterface(list)) { + qWarning() << "Property list interface not fully implemented for Class " << metaProperty.property().typeName() << " in property " << metaProperty.name() << "!"; return; -#endif + } - Q_ASSERT(list.canAppend()); list.append(object); } else if (isObject(metaProperty)) { metaProperty.write(objectToVariant(object)); } + object->setParent(newParent); Q_ASSERT(objectToVariant(object).isValid()); @@ -486,20 +486,15 @@ void ObjectNodeInstance::deleteObjectsInList(const QDeclarativeProperty &metaPro QObjectList objectList; QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(metaProperty.read()); -#ifndef QT_DEBUG - if (!hasFullImplementedListInterface(list)) + if (!hasFullImplementedListInterface(list)) { + qWarning() << "Property list interface not fully implemented for Class " << metaProperty.property().typeName() << " in property " << metaProperty.name() << "!"; return; -#endif - - Q_ASSERT(list.canCount()); - Q_ASSERT(list.canAt()); + } for(int i = 0; i < list.count(); i++) { objectList += list.at(i); } - Q_ASSERT(list.canClear()); - list.clear(); } @@ -552,12 +547,12 @@ void ObjectNodeInstance::resetProperty(QObject *object, const QString &propertyN { m_modelAbstractPropertyHash.remove(propertyName); - QDeclarativeProperty property(object, propertyName, context()); + QDeclarativeProperty metaProperty(object, propertyName, context()); - if (!property.isValid()) + if (!metaProperty.isValid()) return; - QVariant oldValue = property.read(); + QVariant oldValue = metaProperty.read(); if (oldValue.type() == QVariant::Url) { QUrl url = oldValue.toUrl(); QString path = url.toLocalFile(); @@ -566,24 +561,26 @@ void ObjectNodeInstance::resetProperty(QObject *object, const QString &propertyN } - QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::binding(property); + QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::binding(metaProperty); if (binding) { binding->setEnabled(false, 0); binding->destroy(); } - if (property.isResettable()) { - property.reset(); - } else if (property.isWritable()) { - if (property.read() == resetValue(propertyName)) + if (metaProperty.isResettable()) { + metaProperty.reset(); + } else if (metaProperty.isWritable()) { + if (metaProperty.read() == resetValue(propertyName)) return; - property.write(resetValue(propertyName)); - } else if (property.propertyTypeCategory() == QDeclarativeProperty::List) { - QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(property.read()); -#ifndef QT_DEBUG - if (!hasFullImplementedListInterface(list)) + metaProperty.write(resetValue(propertyName)); + } else if (metaProperty.propertyTypeCategory() == QDeclarativeProperty::List) { + QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(metaProperty.read()); + + if (!hasFullImplementedListInterface(list)) { + qWarning() << "Property list interface not fully implemented for Class " << metaProperty.property().typeName() << " in property " << metaProperty.name() << "!"; return; -#endif + } + list.clear(); } } @@ -593,7 +590,6 @@ QVariant ObjectNodeInstance::property(const QString &name) const if (m_modelAbstractPropertyHash.contains(name)) return QVariant::fromValue(m_modelAbstractPropertyHash.value(name)); - // TODO: handle model nodes QDeclarativeProperty metaProperty(object(), name, context()); |