From e18f4bca288804cf13c87b06c6dfe21291ca274a Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 12 Jan 2015 15:55:13 +0100 Subject: moc: Don't link to inexistent parent staticMetaObject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jędrzej Nowacki --- src/tools/moc/generator.cpp | 2 +- src/tools/moc/moc.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 2c41b17b68..f27c155da5 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -530,7 +530,7 @@ void Generator::generateCode() if (isQObject) fprintf(out, " { Q_NULLPTR, "); - else if (cdef->superclassList.size()) + else if (cdef->superclassList.size() && (!cdef->hasQGadget || knownGadgets.contains(purestSuperClass))) fprintf(out, " { &%s::staticMetaObject, ", purestSuperClass.constData()); else fprintf(out, " { Q_NULLPTR, "); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 5506dc75c5..75349191d4 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -139,6 +139,12 @@ bool Moc::parseClassHead(ClassDef *def) def->superclassList += qMakePair(type, access); } } while (test(COMMA)); + + if (knownGadgets.contains(def->superclassList.first().first)) { + // Q_GADGET subclasses are treated as Q_GADGETs + knownGadgets.insert(def->classname, def->qualified); + knownGadgets.insert(def->qualified, def->qualified); + } } if (!test(LBRACE)) return false; -- cgit v1.2.3