aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/testtypes.h
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@blackberry.com>2013-08-21 13:21:03 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-22 21:12:58 +0200
commitfac5337abfef36c631fe73152157446aae0ea3ea (patch)
treea54f9cd915cf480487359ffb7ad86d65f2ddeb5e /tests/auto/qml/qqmlecmascript/testtypes.h
parentda91b1c7312379ee18118059ee03faaf147a7d17 (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.h28
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