diff options
author | Chris Adams <christopher.adams@nokia.com> | 2011-08-03 15:45:47 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-04 02:37:58 +0200 |
commit | 02a19405aab1df31a40896de3d928d8878402052 (patch) | |
tree | ca07a8e64051e1d16eaa3a7c88e668d8f59a1704 | |
parent | 6aa16ad7728094f94f113aa9c12a4b135eb135f4 (diff) |
Fix crash in QDeclarativeProperty
This commit ensures that we don't attempt to dereference a null
pointer in QDeclarativeProperty. It also fixes a unit test failure
by adding appropriate test files.
Related to commit 9f9b23fd7943a3d125cb1cc9f333ce430b2706ea
Task-number: QTBUG-14697
Change-Id: Ic60521e46401835029e293349a00610342d0d58f
Reviewed-on: http://codereview.qt.nokia.com/2538
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
3 files changed, 13 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 98c758267d..3406109a28 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -399,7 +399,7 @@ const char *QDeclarativeProperty::propertyTypeName() const return 0; if (d->isValueType()) { - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->engine); + QDeclarativeEnginePrivate *ep = d->engine?QDeclarativeEnginePrivate::get(d->engine):0; QDeclarativeValueType *valueType = 0; if (ep) valueType = ep->valueTypes[d->core.propType]; else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType); @@ -987,7 +987,7 @@ QVariant QDeclarativePropertyPrivate::readValueProperty() { if (isValueType()) { - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + QDeclarativeEnginePrivate *ep = engine?QDeclarativeEnginePrivate::get(engine):0; QDeclarativeValueType *valueType = 0; if (ep) valueType = ep->valueTypes[core.propType]; else valueType = QDeclarativeValueTypeFactory::valueType(core.propType); @@ -1072,7 +1072,7 @@ bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, Writ bool rv = false; if (isValueType()) { - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + QDeclarativeEnginePrivate *ep = engine?QDeclarativeEnginePrivate::get(engine):0; QDeclarativeValueType *writeBack = 0; if (ep) { diff --git a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml b/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml new file mode 100644 index 0000000000..f58967cbb2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property string someString +} diff --git a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml b/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml new file mode 100644 index 0000000000..4b3672873d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property NoContextTypeA myTypeA +} |