QmlDesigner: Reset possible imports explicitly

We do not reset/set the possible imports whenever we change
the document anymore, since this became really slow.
Instead we set those once per project, but we can reset them
explicitly when required.

The bundleimporter and assetimporter creates new imports, therefore we
reset the possible imports.

Change-Id: I112bd3c42f1c92f5314407883e86b4dedff45f75
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2022-10-21 15:18:38 +02:00
parent 1593f869ed
commit b56de3d8be
6 changed files with 21 additions and 0 deletions

View File

@@ -692,6 +692,7 @@ void ItemLibraryAssetImporter::finalizeQuick3DImport()
QTimer *timer = new QTimer(parent());
static int counter;
counter = 0;
timer->callOnTimeout([this, timer, progressTitle, model, result]() {
if (!isCancelled()) {
notifyProgress(++counter, progressTitle);
@@ -699,6 +700,8 @@ void ItemLibraryAssetImporter::finalizeQuick3DImport()
if (result.isCanceled() || result.isFinished())
counter = 49; // skip to next step
} else if (counter == 50) {
if (model && model->rewriterView())
model->rewriterView()->resetPossibleImports();
model->rewriterView()->textModifier()->replace(0, 0, {});
} else if (counter < 100) {
try {

View File

@@ -205,6 +205,9 @@ void BundleImporter::handleImportTimer()
return;
}
if (model && model->rewriterView())
model->rewriterView()->resetPossibleImports();
if (m_importAddPending) {
try {
Import import = Import::createLibraryImport(m_moduleName, "1.0");

View File

@@ -162,6 +162,9 @@ public:
void setAllowComponentRoot(bool allow);
bool allowComponentRoot() const;
void resetPossibleImports();
signals:
void modelInterfaceProjectUpdated();

View File

@@ -688,6 +688,11 @@ bool RewriterView::allowComponentRoot() const
return m_allowComponentRoot;
}
void RewriterView::resetPossibleImports()
{
m_textToModelMerger->clearPossibleImportKeys();
}
Internal::ModelNodePositionStorage *RewriterView::positionStorage() const
{
return m_positionStorage.data();

View File

@@ -2452,6 +2452,11 @@ QList<QmlTypeData> TextToModelMerger::getQMLSingletons() const
return list;
}
void TextToModelMerger::clearPossibleImportKeys()
{
m_possibleImportKeys.clear();
}
QString TextToModelMerger::textAt(const Document::Ptr &doc,
const SourceLocation &location)
{

View File

@@ -119,6 +119,8 @@ public:
QList<QmlTypeData> getQMLSingletons() const;
void clearPossibleImportKeys();
private:
void setupCustomParserNode(const ModelNode &node);
void setupComponent(const ModelNode &node);