diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-22 23:45:52 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-28 01:18:53 +0300 |
commit | c452a43b5973269fd4fef1dd288745f4ff56a6fa (patch) | |
tree | 0e866260e1bf1ad0b6c2ebd221bec79471704180 /src/tools/moc/moc.cpp | |
parent | 10510c0405f6aff26a623e9d679373abc2c7e1ab (diff) |
Moc: only call checkSuperClasses() if the class inherits another
I.e. if def.superclassList is empty, calling checkSuperClasses() is
no-op. Spotted by Fabian in code review.
Change-Id: I499baf1d2cf6dd08a26394221a48af991ccea4ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r-- | src/tools/moc/moc.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 3766e7f916..eee0092a2d 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -969,7 +969,9 @@ void Moc::parse() if (!def.pluginData.iid.isEmpty()) def.pluginData.metaArgs = metaArgs; - checkSuperClasses(&def); + if (def.hasQObject && !def.superclassList.isEmpty()) + checkSuperClasses(&def); + checkProperties(&def); classList += def; @@ -1804,7 +1806,8 @@ bool Moc::until(Token target) { void Moc::checkSuperClasses(ClassDef *def) { - const QByteArray firstSuperclass = def->superclassList.value(0).first; + Q_ASSERT(!def->superclassList.isEmpty()); + const QByteArray &firstSuperclass = def->superclassList.at(0).first; if (!knownQObjectClasses.contains(firstSuperclass)) { // enable once we /require/ include paths @@ -1828,8 +1831,7 @@ void Moc::checkSuperClasses(ClassDef *def) }; const auto end = def->superclassList.cend(); - auto it = std::next(def->superclassList.cbegin(), - !def->superclassList.isEmpty() ? 1 : 0); + auto it = def->superclassList.cbegin() + 1; for (; it != end; ++it) { const QByteArray &superClass = it->first; if (knownQObjectClasses.contains(superClass)) { |