summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/moc/tst_moc.cpp
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-01-12 15:55:13 +0100
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-01-13 11:25:53 +0100
commite18f4bca288804cf13c87b06c6dfe21291ca274a (patch)
treedb6d26dcdc68b6215f5f2dac4a12301bb4c19371 /tests/auto/tools/moc/tst_moc.cpp
parentdf6d2290e6399471431811160a0c0ff2eb16cb62 (diff)
moc: Don't link to inexistent parent staticMetaObject
Contrarily to Q_OBJECTs, Q_GADGETs are not guaranteed to descend from a Q_GADGET. Here, we ensure that if the first superclass is a Q_GADGET, then the derived class will be treated as one. This allows gaps in the Q_GADGET hierarchy while preventing from trying to link to the inexistent staticMetaObject if there's no such ancestor. Change-Id: If10fb952e23655102a425bb18fe8babaf447a47f Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index d67b3e011a..3117bcd09a 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -72,6 +72,9 @@
#include "related-metaobjects-in-gadget.h"
#include "related-metaobjects-name-conflict.h"
+#include "non-gadget-parent-class.h"
+#include "grand-parent-gadget-class.h"
+
QT_USE_NAMESPACE
template <bool b> struct QTBUG_31218 {};
@@ -574,6 +577,7 @@ private slots:
void relatedMetaObjectsNameConflict();
void strignLiteralsInMacroExtension();
void veryLongStringData();
+ void gadgetHierarchy();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -3379,6 +3383,12 @@ void tst_Moc::veryLongStringData()
QCOMPARE(strlen(mobj->classInfo(3).value()), static_cast<size_t>(1));
}
+void tst_Moc::gadgetHierarchy()
+{
+ QCOMPARE(NonGadgetParent::Derived::staticMetaObject.superClass(), static_cast<const QMetaObject*>(Q_NULLPTR));
+ QCOMPARE(GrandParentGadget::DerivedGadget::staticMetaObject.superClass(), &GrandParentGadget::BaseGadget::staticMetaObject);
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS