diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-03-31 11:26:09 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-04-05 21:57:19 +0200 |
commit | 9c91b35c076b5c7d16fe7499bbe490291d1a6bcf (patch) | |
tree | f721f95127677d4d76431d9e12aafb41934bbca6 /tools/qmltc | |
parent | 3414e8ab16a42c8fd9e7c640a1e4787e4b3cb49c (diff) |
Avoid copying QQmlJSScope
The factory should populate the pre-existing scope rather than copy it
into place. This way we can detect inheritance cycles involving the
pre-existing scope.
However, now we may detect the inheritance cycles earlier, when
resolving the types inside the lazy loading. We have the right pointers
available there now, after all. Therefore, add a way to propagate base
type errors out of the factory. When clearing the base type, we can now
give a reason for that. When checking the inheritance cycles we
retrieve that reason and log it.
We also remove the special casing of the ScopeType property of
QQmlJSScope. There is no real reason to set it in the ctor. As we
delay the population of QQmlJSScope now, we have to set it later.
Task-number: QTBUG-102153
Change-Id: I49cf6e20f59fbdb6ed98a82040b3b159676f5975
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit aea732d607dbcc7ba2c86244ca1ab9086bb28ca6)
Diffstat (limited to 'tools/qmltc')
-rw-r--r-- | tools/qmltc/main.cpp | 3 | ||||
-rw-r--r-- | tools/qmltc/prototype/visitor.cpp | 4 | ||||
-rw-r--r-- | tools/qmltc/prototype/visitor.h | 3 | ||||
-rw-r--r-- | tools/qmltc/qmltcvisitor.cpp | 3 |
4 files changed, 8 insertions, 5 deletions
diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp index 5851f0d7ac..2fa8b64169 100644 --- a/tools/qmltc/main.cpp +++ b/tools/qmltc/main.cpp @@ -207,7 +207,8 @@ int main(int argc, char **argv) logger.setCode(sourceCode); setupLogger(logger); - Qmltc::Visitor visitor(&importer, &logger, + QQmlJSScope::Ptr target = QQmlJSScope::create(); + Qmltc::Visitor visitor(target, &importer, &logger, QQmlJSImportVisitor::implicitImportDirectory(url, &mapper), qmldirFiles); Qmltc::TypeResolver typeResolver { &importer }; typeResolver.init(visitor, document.program); diff --git a/tools/qmltc/prototype/visitor.cpp b/tools/qmltc/prototype/visitor.cpp index 307cb992ea..9aa3bbc63b 100644 --- a/tools/qmltc/prototype/visitor.cpp +++ b/tools/qmltc/prototype/visitor.cpp @@ -32,9 +32,9 @@ #include <QtCore/qfileinfo.h> namespace Qmltc { -Visitor::Visitor(QQmlJSImporter *importer, QQmlJSLogger *logger, +Visitor::Visitor(const QQmlJSScope::Ptr &target, QQmlJSImporter *importer, QQmlJSLogger *logger, const QString &implicitImportDirectory, const QStringList &qmltypesFiles) - : QQmlJSImportVisitor(importer, logger, implicitImportDirectory, qmltypesFiles) + : QQmlJSImportVisitor(target, importer, logger, implicitImportDirectory, qmltypesFiles) { } diff --git a/tools/qmltc/prototype/visitor.h b/tools/qmltc/prototype/visitor.h index 730021b66c..5684e01c6c 100644 --- a/tools/qmltc/prototype/visitor.h +++ b/tools/qmltc/prototype/visitor.h @@ -45,7 +45,8 @@ namespace Qmltc { class Visitor : public QQmlJSImportVisitor { public: - Visitor(QQmlJSImporter *importer, QQmlJSLogger *logger, const QString &implicitImportDirectory, + Visitor(const QQmlJSScope::Ptr &target, QQmlJSImporter *importer, QQmlJSLogger *logger, + const QString &implicitImportDirectory, const QStringList &qmltypesFiles = QStringList()); bool visit(QQmlJS::AST::UiInlineComponent *) override; diff --git a/tools/qmltc/qmltcvisitor.cpp b/tools/qmltc/qmltcvisitor.cpp index 691496d7c7..04b75749aa 100644 --- a/tools/qmltc/qmltcvisitor.cpp +++ b/tools/qmltc/qmltcvisitor.cpp @@ -45,7 +45,8 @@ static QString uniqueNameFromPieces(const QStringList &pieces, QHash<QString, in QmltcVisitor::QmltcVisitor(QQmlJSImporter *importer, QQmlJSLogger *logger, const QString &implicitImportDirectory, const QStringList &qmldirFiles) - : QQmlJSImportVisitor(importer, logger, implicitImportDirectory, qmldirFiles) + : QQmlJSImportVisitor( + QQmlJSScope::create(), importer, logger, implicitImportDirectory, qmldirFiles) { m_qmlTypeNames.append(QFileInfo(logger->fileName()).baseName()); // put document root } |