diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 651586ee43f..c3a465b27b5 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -984,8 +984,8 @@ static UiQualifiedId *qualifiedTypeNameId(UiObjectMember *m) void QmlJSTextEditor::updateCursorPositionNow() { - if (m_contextPane && document() && !semanticInfo().document.isNull() && - document()->revision() == semanticInfo().document->editorRevision()) + if (m_contextPane && document() && semanticInfo().isValid() + && document()->revision() == semanticInfo().document->editorRevision()) { Node *oldNode = m_semanticInfo.declaringMemberNoProperties(m_oldCursorPosition); Node *newNode = m_semanticInfo.declaringMemberNoProperties(position()); @@ -1225,7 +1225,7 @@ void QmlJSTextEditor::setSelectedElements() endPos = textCursor().position(); } - if (m_semanticInfo.document) { + if (m_semanticInfo.isValid()) { SelectedElement selectedMembers; QList members = selectedMembers(m_semanticInfo.lookupContext(), startPos, endPos); @@ -1459,7 +1459,7 @@ void QmlJSTextEditor::findUsages() void QmlJSTextEditor::showContextPane() { - if (m_contextPane) { + if (m_contextPane && m_semanticInfo.isValid()) { Node *newNode = m_semanticInfo.declaringMemberNoProperties(position()); m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, false, true); m_oldCursorPosition = position(); @@ -1487,7 +1487,7 @@ void QmlJSTextEditor::updateToolTipNow() if (!TextEditor::ToolTip::instance()->isVisible()) return; - if (m_contextPane) { + if (m_contextPane && m_semanticInfo.isValid()) { Node *newNode = m_semanticInfo.declaringMemberNoProperties(m_toolTipPosition); m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), newNode, false, true); m_oldCursorPosition = m_toolTipPosition; @@ -1574,8 +1574,12 @@ void QmlJSTextEditor::wheelEvent(QWheelEvent *event) BaseTextEditor::wheelEvent(event); - if (visible) - m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), m_semanticInfo.declaringMemberNoProperties(position()), false, true); + if (visible) { + LookupContext::Ptr lookupContext; + if (m_semanticInfo.isValid()) + lookupContext = m_semanticInfo.lookupContext(); + m_contextPane->apply(editableInterface(), lookupContext, m_semanticInfo.declaringMemberNoProperties(position()), false, true); + } } void QmlJSTextEditor::resizeEvent(QResizeEvent *event) @@ -1876,8 +1880,12 @@ QModelIndex QmlJSTextEditor::indexForPosition(unsigned cursorPosition, const QMo bool QmlJSTextEditor::hideContextPane() { bool b = (m_contextPane) && m_contextPane->widget()->isVisible(); - if (b) - m_contextPane->apply(editableInterface(), m_semanticInfo.lookupContext(), 0, false); + if (b) { + LookupContext::Ptr lookupContext; + if (m_semanticInfo.isValid()) + lookupContext = m_semanticInfo.lookupContext(); + m_contextPane->apply(editableInterface(), lookupContext, 0, false); + } return b; } diff --git a/src/plugins/qmljseditor/qmloutlinemodel.cpp b/src/plugins/qmljseditor/qmloutlinemodel.cpp index 595cf7afe7a..b2a44a93666 100644 --- a/src/plugins/qmljseditor/qmloutlinemodel.cpp +++ b/src/plugins/qmljseditor/qmloutlinemodel.cpp @@ -38,7 +38,7 @@ QVariant QmlOutlineItem::data(int role) const if (role == Qt::ToolTipRole) { AST::SourceLocation location = m_outlineModel->sourceLocation(index()); AST::UiQualifiedId *uiQualifiedId = m_outlineModel->idNode(index()); - if (!uiQualifiedId || !location.isValid()) + if (!uiQualifiedId || !location.isValid() || !m_outlineModel->m_semanticInfo.isValid()) return QVariant(); QList astPath = m_outlineModel->m_semanticInfo.astPath(location.begin());