diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2013-09-05 18:03:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-06 16:18:32 +0200 |
commit | 2ff15ff065ef5f189ba8727ec6424c0e79285864 (patch) | |
tree | e28b3bc6eeb2c708cffad05da720d5145fcd274b /tests | |
parent | 87ff0af425656d12c4766a57db60674d63ffa584 (diff) |
Fix the automatic declaration of smart pointer types.
Before this patch,
qRegisterMetaType<QSharedPointer<double> >("QSharedPointer<double>")
without a metatype declaration fails to compile, whereas it works
with Qt 5.1 (ie, before commit e9a69c3ba928bd88974563b386b000ad6583f969)
Change-Id: I9408f711c9df810ff29b879b7696dab81c1160f1
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 6baf6c4310..0b50bc7576 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -2259,6 +2259,28 @@ struct Converter } }; +namespace MyNS { + +template<typename T> +class SmartPointer +{ + T* pointer; +public: + typedef T element_type; + explicit SmartPointer(T *t = 0) + : pointer(t) + { + } + + T* operator->() const { return pointer; } +}; + +} + +Q_DECLARE_SMART_POINTER_METATYPE(MyNS::SmartPointer) + +Q_DECLARE_METATYPE(MyNS::SmartPointer<int>) + void tst_QVariant::qvariant_cast_QObject_wrapper() { QMetaType::registerConverter<QObjectWrapper, QObject*>(&QObjectWrapper::getObject); @@ -2270,6 +2292,10 @@ void tst_QVariant::qvariant_cast_QObject_wrapper() v.convert(qMetaTypeId<QObject*>()); QCOMPARE(v.value<QObject*>(), object); + // Compile tests: + qRegisterMetaType<MyNS::SmartPointer<int> >(); + // Not declared as a metatype: + qRegisterMetaType<MyNS::SmartPointer<double> >("MyNS::SmartPointer<double>"); } void tst_QVariant::convertToQUint8() const |