forked from qt-creator/qt-creator
QmlJSEditor: fix assigning outline toolbar widget
Instead of adding a second toolbar widget, replace the current one. This avoids weird situations where you get two outline toolbar widgets, one provided by qmljseditorwidget and another one provided by qmlls. Turning the language server on deletes the combobox created by qmljseditorwidget, such that qmljseditorwidget has to recreate its combobox after the language server stopped being in use. Also make sure that m_outlineCombo is set to nullptr after it gets deleted, such that late jumpToOutlineElement and updateOutlineIndexNow() calls do no try to attempt stuff on an already free'd pointer. Change-Id: Ie323a7b3e7a4d5e24407fcedf8383dd2f0efe525 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
committed by
Sami Shalayel
parent
441ce652e7
commit
5f8ffd66ff
@@ -267,6 +267,8 @@ bool QmlJSEditorWidget::isOutlineCursorChangesBlocked()
|
|||||||
|
|
||||||
void QmlJSEditorWidget::jumpToOutlineElement(int /*index*/)
|
void QmlJSEditorWidget::jumpToOutlineElement(int /*index*/)
|
||||||
{
|
{
|
||||||
|
if (!m_outlineCombo)
|
||||||
|
return;
|
||||||
QModelIndex index = m_outlineCombo->view()->currentIndex();
|
QModelIndex index = m_outlineCombo->view()->currentIndex();
|
||||||
SourceLocation location = m_qmlJsEditorDocument->outlineModel()->sourceLocation(index);
|
SourceLocation location = m_qmlJsEditorDocument->outlineModel()->sourceLocation(index);
|
||||||
|
|
||||||
@@ -285,6 +287,8 @@ void QmlJSEditorWidget::jumpToOutlineElement(int /*index*/)
|
|||||||
|
|
||||||
void QmlJSEditorWidget::updateOutlineIndexNow()
|
void QmlJSEditorWidget::updateOutlineIndexNow()
|
||||||
{
|
{
|
||||||
|
if (!m_outlineCombo)
|
||||||
|
return;
|
||||||
if (!m_qmlJsEditorDocument->outlineModel()->document())
|
if (!m_qmlJsEditorDocument->outlineModel()->document())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -570,8 +574,19 @@ void QmlJSEditorWidget::createToolBar()
|
|||||||
|
|
||||||
connect(this, &QmlJSEditorWidget::cursorPositionChanged,
|
connect(this, &QmlJSEditorWidget::cursorPositionChanged,
|
||||||
&m_updateOutlineIndexTimer, QOverload<>::of(&QTimer::start));
|
&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
|
class CodeModelInspector : public MemberProcessor
|
||||||
|
@@ -79,6 +79,7 @@ protected:
|
|||||||
void scrollContentsBy(int dx, int dy) override;
|
void scrollContentsBy(int dx, int dy) override;
|
||||||
void applyFontSettings() override;
|
void applyFontSettings() override;
|
||||||
void createToolBar();
|
void createToolBar();
|
||||||
|
void updateOutline(QWidget *newOutline);
|
||||||
void findLinkAt(const QTextCursor &cursor,
|
void findLinkAt(const QTextCursor &cursor,
|
||||||
const Utils::LinkHandler &processLinkCallback,
|
const Utils::LinkHandler &processLinkCallback,
|
||||||
bool resolveTarget = true,
|
bool resolveTarget = true,
|
||||||
|
Reference in New Issue
Block a user