From 5cda1949899488ce19c4add30a9e0d82326499de Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 28 Jul 2009 08:11:36 +1000 Subject: Fix crashes on exit. --- src/declarative/fx/qfxitem.cpp | 3 ++- src/declarative/qml/qmlmetaproperty.cpp | 27 ++++++++++++++++++--------- src/declarative/qml/qmlmetaproperty_p.h | 3 ++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 6c6fcd3..bf272d0 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -404,7 +404,8 @@ QFxItem::~QFxItem() } for (int ii = 0; ii < d->dependantAnchors.count(); ++ii) { QFxAnchors *anchor = d->dependantAnchors.at(ii); - anchor->d_func()->updateOnComplete(); + if (anchor->d_func()->item && anchor->d_func()->item->parentItem() != this) //child will be deleted anyway + anchor->d_func()->updateOnComplete(); } delete d->_anchorLines; d->_anchorLines = 0; } diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 60b4ac6..3d040e5 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -313,7 +313,7 @@ QmlMetaPropertyPrivate::propertyCategory() const */ const char *QmlMetaProperty::propertyTypeName() const { - if (!d->name.isEmpty()) { + if (!d->name.isEmpty() && d->object) { return d->object->metaObject()->property(d->coreIdx).typeName(); } else { return 0; @@ -415,7 +415,7 @@ bool QmlMetaProperty::isWritable() const { if (propertyCategory() == List || propertyCategory() == QmlList) return true; - else if (!d->name.isEmpty()) + else if (!d->name.isEmpty() && d->object) return d->object->metaObject()->property(d->coreIdx).isWritable(); else if (type() & SignalProperty) return true; @@ -428,7 +428,7 @@ bool QmlMetaProperty::isWritable() const */ bool QmlMetaProperty::isDesignable() const { - if (!d->name.isEmpty()) + if (!d->name.isEmpty() && d->object) return d->object->metaObject()->property(d->coreIdx).isDesignable(); else return false; @@ -475,7 +475,10 @@ QString QmlMetaProperty::name() const */ QMetaProperty QmlMetaProperty::property() const { - return d->object->metaObject()->property(d->coreIdx); + if (d->object) + return d->object->metaObject()->property(d->coreIdx); + else + return QMetaProperty(); } /*! @@ -484,7 +487,7 @@ QMetaProperty QmlMetaProperty::property() const */ QmlBinding *QmlMetaProperty::binding() const { - if (!isProperty() || type() & Attached) + if (!isProperty() || (type() & Attached) || !d->object) return 0; const QObjectList &children = object()->children(); @@ -509,7 +512,7 @@ QmlBinding *QmlMetaProperty::binding() const */ QmlBinding *QmlMetaProperty::setBinding(QmlBinding *binding) const { - if (!isProperty() || type() & Attached) + if (!isProperty() || (type() & Attached) || !d->object) return 0; const QObjectList &children = object()->children(); @@ -577,6 +580,9 @@ QObject *QmlMetaPropertyPrivate::attachedObject() const */ QVariant QmlMetaProperty::read() const { + if (!d->object) + return QVariant(); + if (type() & SignalProperty) { const QObjectList &children = object()->children(); @@ -868,6 +874,9 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value) */ void QmlMetaProperty::write(const QVariant &value) const { + if (!d->object) + return; + QMetaProperty prop = d->object->metaObject()->property(d->coreIdx); if (type() & SignalProperty) { @@ -885,7 +894,7 @@ void QmlMetaProperty::write(const QVariant &value) const */ bool QmlMetaProperty::hasChangedNotifier() const { - if (type() & Property && !(type() & Attached)) { + if (type() & Property && !(type() & Attached) && d->object) { return d->object->metaObject()->property(d->coreIdx).hasNotifySignal(); } return false; @@ -914,7 +923,7 @@ bool QmlMetaProperty::needsChangedNotifier() const */ bool QmlMetaProperty::connectNotifier(QObject *dest, int method) const { - if (!(type() & Property) || type() & Attached) + if (!(type() & Property) || (type() & Attached) || !d->object) return false; QMetaProperty prop = d->object->metaObject()->property(d->coreIdx); @@ -935,7 +944,7 @@ bool QmlMetaProperty::connectNotifier(QObject *dest, int method) const */ bool QmlMetaProperty::connectNotifier(QObject *dest, const char *slot) const { - if (!(type() & Property) || type() & Attached) + if (!(type() & Property) || (type() & Attached) || !d->object) return false; QMetaProperty prop = d->object->metaObject()->property(d->coreIdx); diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 7efdb6e..d135eda 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -54,6 +54,7 @@ // #include "qmlmetaproperty.h" +#include "private/qguard_p.h" QT_BEGIN_NAMESPACE @@ -80,7 +81,7 @@ public: int valueTypeId; uint type; int attachedFunc; - QObject *object; + QGuard object; int propType; mutable QmlMetaProperty::PropertyCategory category; -- cgit v0.12