Fix Q_DECLARE_METATYPE macro
The macro should stringify value of the given token not the token itself. Task-number: QTBUG-37547 Change-Id: I90f4fa613bd13d5a581828ab13f620b40dfd3593 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
8212e0cfad
commit
ac178eae4e
@ -1706,7 +1706,8 @@ inline int qRegisterMetaTypeStreamOperators()
|
||||
} QT_END_NAMESPACE \
|
||||
/**/
|
||||
|
||||
#define Q_DECLARE_METATYPE(TYPE) \
|
||||
#define Q_DECLARE_METATYPE(TYPE) Q_DECLARE_METATYPE_IMPL(TYPE)
|
||||
#define Q_DECLARE_METATYPE_IMPL(TYPE) \
|
||||
QT_BEGIN_NAMESPACE \
|
||||
template <> \
|
||||
struct QMetaTypeId< TYPE > \
|
||||
|
@ -278,15 +278,21 @@ void tst_QMetaType::threadSafety()
|
||||
namespace TestSpace
|
||||
{
|
||||
struct Foo { double d; };
|
||||
|
||||
struct QungTfu {};
|
||||
}
|
||||
Q_DECLARE_METATYPE(TestSpace::Foo)
|
||||
|
||||
#define ADD_TESTSPACE(F) TestSpace::F
|
||||
Q_DECLARE_METATYPE(ADD_TESTSPACE(QungTfu))
|
||||
|
||||
void tst_QMetaType::namespaces()
|
||||
{
|
||||
TestSpace::Foo nf = { 11.12 };
|
||||
QVariant v = QVariant::fromValue(nf);
|
||||
QCOMPARE(qvariant_cast<TestSpace::Foo>(v).d, 11.12);
|
||||
|
||||
int qungTfuId = qRegisterMetaType<ADD_TESTSPACE(QungTfu)>();
|
||||
QCOMPARE(QMetaType::typeName(qungTfuId), "TestSpace::QungTfu");
|
||||
}
|
||||
|
||||
void tst_QMetaType::qMetaTypeId()
|
||||
|
Loading…
Reference in New Issue
Block a user