From 0198ed15f34c15b906d752f1025ebcb6ffe11c57 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 31 Jan 2023 16:02:26 +0100 Subject: [PATCH] QmlDesigner: Skip makeComponentChain in TextToModelMerger::load This is not required in the context of QmlDesigner and can become very slow. Change-Id: Id4a4ae30c5fa55e88ed295624365efb724e26f62 Reviewed-by: Vikas Pachdha Reviewed-by: Qt CI Bot Reviewed-by: --- src/libs/qmljs/qmljsscopechain.cpp | 10 ++++++++++ src/libs/qmljs/qmljsscopechain.h | 4 ++++ .../designercore/model/texttomodelmerger.cpp | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/libs/qmljs/qmljsscopechain.cpp b/src/libs/qmljs/qmljsscopechain.cpp index 5ba80fd713f..e2f24a78397 100644 --- a/src/libs/qmljs/qmljsscopechain.cpp +++ b/src/libs/qmljs/qmljsscopechain.cpp @@ -11,6 +11,8 @@ using namespace QmlJS; +bool ScopeChain::s_setSkipmakeComponentChain = false; + /*! \class QmlJS::ScopeChain \brief The ScopeChain class describes the scopes used for global lookup in @@ -210,6 +212,11 @@ QList ScopeChain::all() const return m_all; } +void ScopeChain::setSkipmakeComponentChain(bool b) +{ + s_setSkipmakeComponentChain = b; +} + static void collectScopes(const QmlComponentChain *chain, QList *target) { foreach (const QmlComponentChain *parent, chain->instantiatingComponents()) @@ -351,6 +358,9 @@ void ScopeChain::makeComponentChain( const Snapshot &snapshot, QHash *components) { + if (s_setSkipmakeComponentChain) + return; + Document::Ptr doc = target->document(); if (!doc->qmlProgram()) return; diff --git a/src/libs/qmljs/qmljsscopechain.h b/src/libs/qmljs/qmljsscopechain.h index f3b8ae2bb58..88d7772b678 100644 --- a/src/libs/qmljs/qmljsscopechain.h +++ b/src/libs/qmljs/qmljsscopechain.h @@ -77,6 +77,8 @@ public: QList all() const; + static void setSkipmakeComponentChain(bool b); + private: void update() const; void initializeRootScope(); @@ -97,6 +99,8 @@ private: mutable bool m_modified; mutable QList m_all; + + static bool s_setSkipmakeComponentChain; }; } // namespace QmlJS diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index bb7bbb16c0b..a4fd078b761 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -1092,6 +1092,9 @@ Document::MutablePtr TextToModelMerger::createParsedDocument(const QUrl &url, co bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceHandler) { + QmlJS::ScopeChain::setSkipmakeComponentChain(true); + QScopeGuard unSkip([]() { QmlJS::ScopeChain::setSkipmakeComponentChain(false); }); + qCInfo(rewriterBenchmark) << Q_FUNC_INFO; const bool justSanityCheck = !differenceHandler.isAmender();