Fix automatic declaration of QSharedPointer<T> metatypes.
authorStephen Kelly <stephen.kelly@kdab.com>
Thu, 24 May 2012 12:23:54 +0000 (14:23 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 12 Jun 2012 09:16:45 +0000 (11:16 +0200)
commit32bc019ac1292a0dafabd1d2d2430b44501cbda1
treea506a2ad6cef37f8d39221b6550a4d86505cf084
parent7462033cc5ccce22e6cc5e8b7e5f5d29c0facffb
Fix automatic declaration of QSharedPointer<T> metatypes.

QSharedPointer doesn't work like the other automatic template metatype
declarations because in some cases T* is declared as a metatype, but we
are interested in QSharedPointer<T> (eg QObject*). In other cases, T is
declared as a metatype and we are interested
in QSharedPointer<T> (eg char).

In particular the macro used before this patch was attempting to get the
metatype id of the element_type using for example qMetaTypeId<QObject>()
instead of qMetaTypeId<QObject*>(), which did not work.

Similarly, the variadic macro driven test is no good, because it was
testing QSharedPointer<QObject*> instead of QSharedPointer<QObject>,
so that is removed.

In the end, the only thing we can sensibly automatically declare as
metatypes are QSharedPointers to QObject derived types. That is also
the type that makes the most sense in a QML context anyway.

Change-Id: I13dd40147e2e6bedf38661f898102abaaaa96208
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
src/corelib/kernel/qmetatype.h
tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp