From 98b77f9faa14822479deb20cd6fe0ce4fe9b56da Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 25 Jul 2012 09:08:33 +0200 Subject: QMetaType: remember whether a type was registered with Q_DECLARE_METATYPE There are two ways to register a type: using Q_DECLARE_METATYPE(T) and using qRegisterMetaType("T"). Doing one thing in one translation unit and another thing in another TU constitutes an ODR violation, because the value of QMetaTypeId::Defined will differ in the two TUs. By adding the information whether a type was declared with Q_DECLARE_METATYPE to the typeFlags(), such a use will trigger the existing binary-incompatibility failure that checks for equality of the incoming type flags with the stored ones (if any). I had to encode the type as a defaulted function argument in order to avoid the linker merging instantiations of the function templates and therefore rendering the detection moot. Change-Id: I82017caf300458b411cc8ac2f6653536fac64117 Reviewed-by: Lars Knoll --- tests/manual/qmetatype/qmetatype.pro | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/manual/qmetatype/qmetatype.pro (limited to 'tests/manual/qmetatype/qmetatype.pro') diff --git a/tests/manual/qmetatype/qmetatype.pro b/tests/manual/qmetatype/qmetatype.pro new file mode 100644 index 0000000000..a4f941e577 --- /dev/null +++ b/tests/manual/qmetatype/qmetatype.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +TARGET = tst_qmetatype_expect_fail +QT = core +HEADERS = declare_metatype_noninline.h +SOURCES = tst_qmetatype.cpp declare_metatype_noninline.cpp -- cgit v1.2.3