From e27af202fc264425049a065115bb1448f09a5170 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Thu, 13 Oct 2022 14:13:00 +0200 Subject: [PATCH] qmlls: move isSematicInfoOutdated to private object this avoid use of the (still unintialized q->d) in settingsChanged in the constructor Change-Id: Idd756fc88df166124c34a6177a9d598604634057 Reviewed-by: David Schulz --- src/plugins/qmljseditor/qmljseditordocument.cpp | 13 +++++++++---- src/plugins/qmljseditor/qmljseditordocument_p.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 68b235d0c18..711b5c18403 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -587,12 +587,17 @@ void QmlJSEditorDocumentPrivate::acceptNewSemanticInfo(const SemanticInfo &seman void QmlJSEditorDocumentPrivate::updateOutlineModel() { - if (q->isSemanticInfoOutdated()) + if (isSemanticInfoOutdated()) return; // outline update will be retriggered when semantic info is updated m_outlineModel->update(m_semanticInfo); } +bool QmlJSEditorDocumentPrivate::isSemanticInfoOutdated() const +{ + return m_semanticInfo.revision() != q->document()->revision(); +} + static void cleanMarks(QVector *marks, TextEditor::TextDocument *doc) { // if doc is null, this method is improperly called, so better do nothing that leave an @@ -664,7 +669,7 @@ void QmlJSEditorDocumentPrivate::setSemanticWarningSource(QmllsStatus::Source ne m_semanticHighlighter->setEnableWarnings(false); cleanDiagnosticMarks(); cleanSemanticMarks(); - if (!q->isSemanticInfoOutdated()) { + if (m_semanticInfo.isValid() && !isSemanticInfoOutdated()) { // clean up underlines for warning messages m_semanticHighlightingNecessary = false; m_semanticHighlighter->rerun(m_semanticInfo); @@ -690,7 +695,7 @@ void QmlJSEditorDocumentPrivate::setSemanticHighlightSource(QmllsStatus::Source break; case QmllsStatus::Source::EmbeddedCodeModel: m_semanticHighlighter->setEnableHighlighting(true); - if (!q->isSemanticInfoOutdated()) { + if (m_semanticInfo.isValid() && !isSemanticInfoOutdated()) { m_semanticHighlightingNecessary = false; m_semanticHighlighter->rerun(m_semanticInfo); } @@ -835,7 +840,7 @@ const SemanticInfo &QmlJSEditorDocument::semanticInfo() const bool QmlJSEditorDocument::isSemanticInfoOutdated() const { - return d->m_semanticInfo.revision() != document()->revision(); + return d->isSemanticInfoOutdated(); } QVector QmlJSEditorDocument::diagnosticRanges() const diff --git a/src/plugins/qmljseditor/qmljseditordocument_p.h b/src/plugins/qmljseditor/qmljseditordocument_p.h index 7be1ec6d345..2cc21fe9fb6 100644 --- a/src/plugins/qmljseditor/qmljseditordocument_p.h +++ b/src/plugins/qmljseditor/qmljseditordocument_p.h @@ -48,6 +48,7 @@ public: void onDocumentUpdated(QmlJS::Document::Ptr doc); void reupdateSemanticInfo(); void acceptNewSemanticInfo(const QmlJSTools::SemanticInfo &semanticInfo); + bool isSemanticInfoOutdated() const; void updateOutlineModel(); void createTextMarks(const QList &diagnostics);