diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-05-25 17:23:42 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-28 02:42:55 +0200 |
commit | f62ab0a3dfaa873bb15cd1526f98f50a17228a9c (patch) | |
tree | 483c980f2d17eca24438e47e097bf1034d916daa /tests/auto/qml/qqmlecmascript/testtypes.h | |
parent | 1deba22774e59458dc2e485f1cdf8f5b547d2941 (diff) |
Fix crash caused by unregistered enum types
If the enum type isn't registered with Q_ENUMS, the metatype lookup
fails, which results in a crash in certain circumstances.
This commit ensures that when assigning an undefined value to an
unregistered-enum-type property, no crash occurs.
Change-Id: I0b539b591c9c9d6262c748300e4f4b6813d4f9a6
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/testtypes.h')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index d02f982f99..8e2b68f51c 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1412,6 +1412,27 @@ Q_SIGNALS: void done(const QString &result); }; +class MyUnregisteredEnumTypeObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty) + +public: + MyUnregisteredEnumTypeObject() : QObject(), m_ev(FirstValue) {} + ~MyUnregisteredEnumTypeObject() {} + + enum MyEnum { + FirstValue = 1, + SecondValue = 2 + }; + + MyEnum enumProperty() const { return m_ev; } + void setEnumProperty(MyEnum v) { m_ev = v; } + +private: + MyEnum m_ev; +}; + void registerTypes(); #endif // TESTTYPES_H |