diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2021-12-16 10:10:25 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-12-18 23:52:34 +0000 |
commit | bd51e41cc29283fb1a75c67c163d42c0733bdf12 (patch) | |
tree | bbc10ec001172f8cc41529d8855b17bb0eed1cb5 /tools/qmltc | |
parent | c5efa5bdba3c563933faf02185b0c2be16f2dccb (diff) |
qmltc: Do not crash on import namespaces
Change-Id: I9767857076ea6ae565c7efd75d64cb47a82b7be7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 790d257ef01e0f95b776db873ad34bebe16396a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools/qmltc')
-rw-r--r-- | tools/qmltc/prototype/typeresolver.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/qmltc/prototype/typeresolver.h b/tools/qmltc/prototype/typeresolver.h index 6dd98bb470..dc747fd042 100644 --- a/tools/qmltc/prototype/typeresolver.h +++ b/tools/qmltc/prototype/typeresolver.h @@ -49,10 +49,18 @@ public: QHash<QString, QQmlJSScope::ConstPtr> builtins = m_importer->builtinInternalNames(); cppNames.reserve(builtins.size() + m_imports.size()); const auto getInternalName = [](const QQmlJSScope::ConstPtr &t) { + if (!t) + return QString(); return t->internalName(); }; std::transform(builtins.cbegin(), builtins.cend(), std::back_inserter(cppNames), getInternalName); + + // builtins must be valid: all QQmlJSScopes are not nullptr and have + // non-empty internal names. m_imports may have nullptrs, due to import + // namespaces + Q_ASSERT(std::find(cppNames.cbegin(), cppNames.cend(), QString()) == cppNames.cend()); + std::transform(m_imports.cbegin(), m_imports.cend(), std::back_inserter(cppNames), getInternalName); return cppNames; |