diff options
author | Alan Alpert <aalpert@blackberry.com> | 2013-08-21 13:21:03 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-22 21:12:58 +0200 |
commit | fac5337abfef36c631fe73152157446aae0ea3ea (patch) | |
tree | a54f9cd915cf480487359ffb7ad86d65f2ddeb5e /tests/auto/qml/qqmlecmascript/testtypes.h | |
parent | da91b1c7312379ee18118059ee03faaf147a7d17 (diff) |
Don't crash with deferred properties
There are cases where a qmlExecuteDeferred(o) can be postponed until the
context of o is being destroyed, at which point it's too late to create
an object in that context.
Task-number: QTBUG-33112
Change-Id: I7f981b5e34e3cb8a52c00de4742a7242d7e4df54
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/testtypes.h')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 4d30816b0a..2aa5fce534 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -376,6 +376,34 @@ private: QObject *m_object2; }; +class MyVeryDeferredObject : public QObject +{ + Q_OBJECT + //For inDestruction test + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty) + Q_CLASSINFO("DeferredPropertyNames", "objectProperty") + +public: + MyVeryDeferredObject() : m_value(0), m_object(0) {} + ~MyVeryDeferredObject() { + qmlExecuteDeferred(this); //Not a realistic case, see QTBUG-33112 to see how this could happen in practice + } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; emit valueChanged(); } + + QObject *objectProperty() const { return m_object; } + void setObjectProperty(QObject *obj) { m_object = obj; } + +signals: + void valueChanged(); + +private: + int m_value; + QObject *m_object; +}; + class MyBaseExtendedObject : public QObject { Q_OBJECT |