forked from qt-creator/qt-creator
QmlDesigner: Don't cache possible imports until code model has settled
Code model can take a couple of seconds to fully resolve when a new project is launched for the first time, so we avoid caching possible imports until we detect no changes in the count of possible imports. Fixes: QDS-8128 Change-Id: I0d35b1eb2d5872f646c141067652645d2e2f106f Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -1158,6 +1158,7 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
||||
if (!errors.isEmpty()) {
|
||||
m_rewriterView->setErrors(errors);
|
||||
setActive(false);
|
||||
clearPossibleImportKeys();
|
||||
return false;
|
||||
}
|
||||
if (!justSanityCheck)
|
||||
@@ -1179,6 +1180,12 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
||||
|
||||
setActive(false);
|
||||
|
||||
// Clear possible imports cache if code model hasn't settled yet
|
||||
const int importKeysSize = m_possibleImportKeys.size();
|
||||
if (m_previousPossibleImportsSize != importKeysSize)
|
||||
m_possibleImportKeys.clear();
|
||||
m_previousPossibleImportsSize = importKeysSize;
|
||||
|
||||
return true;
|
||||
} catch (Exception &e) {
|
||||
DocumentMessage error(&e);
|
||||
@@ -2452,6 +2459,7 @@ QList<QmlTypeData> TextToModelMerger::getQMLSingletons() const
|
||||
void TextToModelMerger::clearPossibleImportKeys()
|
||||
{
|
||||
m_possibleImportKeys.clear();
|
||||
m_previousPossibleImportsSize = -1;
|
||||
}
|
||||
|
||||
QString TextToModelMerger::textAt(const Document::Ptr &doc,
|
||||
|
||||
@@ -151,6 +151,7 @@ private:
|
||||
QmlJS::ViewerContext m_vContext;
|
||||
QSet<QPair<QString, QString> > m_qrcMapping;
|
||||
QSet<QmlJS::ImportKey> m_possibleImportKeys;
|
||||
int m_previousPossibleImportsSize = -1;
|
||||
bool m_hasVersionlessImport = false;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user