diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 540e5559de6..11dc5cf9ae8 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -267,6 +267,8 @@ bool QmlJSEditorWidget::isOutlineCursorChangesBlocked() void QmlJSEditorWidget::jumpToOutlineElement(int /*index*/) { + if (!m_outlineCombo) + return; QModelIndex index = m_outlineCombo->view()->currentIndex(); SourceLocation location = m_qmlJsEditorDocument->outlineModel()->sourceLocation(index); @@ -285,6 +287,8 @@ void QmlJSEditorWidget::jumpToOutlineElement(int /*index*/) void QmlJSEditorWidget::updateOutlineIndexNow() { + if (!m_outlineCombo) + return; if (!m_qmlJsEditorDocument->outlineModel()->document()) return; @@ -570,8 +574,19 @@ void QmlJSEditorWidget::createToolBar() connect(this, &QmlJSEditorWidget::cursorPositionChanged, &m_updateOutlineIndexTimer, QOverload<>::of(&QTimer::start)); + connect(this, &QmlJSEditorWidget::toolbarOutlineChanged, + this, &QmlJSEditorWidget::updateOutline); - insertExtraToolBarWidget(TextEditorWidget::Left, m_outlineCombo); + setToolbarOutline(m_outlineCombo); +} + +void QmlJSEditorWidget::updateOutline(QWidget *newOutline) +{ + if (!newOutline) { + createToolBar(); + } else if (newOutline != m_outlineCombo){ + m_outlineCombo = nullptr; + } } class CodeModelInspector : public MemberProcessor diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index d5279fe78e7..0929fa552a4 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -79,6 +79,7 @@ protected: void scrollContentsBy(int dx, int dy) override; void applyFontSettings() override; void createToolBar(); + void updateOutline(QWidget *newOutline); void findLinkAt(const QTextCursor &cursor, const Utils::LinkHandler &processLinkCallback, bool resolveTarget = true,