Moc: test if superclass list is not empty before accessing first()

Accessing QList().first() with an empty superclassList caused assertion
fail. Added check to fix it.

Change-Id: I1aff35e0d267fc0e670beadba1bd196b175a4da8
Co-authored-with: Olivier Goffart <ogoffart@woboq.com>
Task-number: QTBUG-45790
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Jacek Całusiński 2015-04-24 11:26:01 +02:00 committed by Gabriel de Dietrich
parent 2886935f96
commit 0635b1a69d
2 changed files with 6 additions and 1 deletions

View File

@ -140,7 +140,8 @@ bool Moc::parseClassHead(ClassDef *def)
}
} while (test(COMMA));
if (knownGadgets.contains(def->superclassList.first().first)) {
if (!def->superclassList.isEmpty()
&& 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);

View File

@ -83,6 +83,10 @@ QT_USE_NAMESPACE
template <bool b> struct QTBUG_31218 {};
struct QTBUG_31218_Derived : QTBUG_31218<-1<0> {};
#if defined(Q_MOC_RUN)
class QTBUG_45790 : Bug() { };
#endif
struct MyStruct {};
struct MyStruct2 {};