From 949612c23e1c11b86628994494832cf0acc6ab4e Mon Sep 17 00:00:00 2001 From: Aleksei German Date: Tue, 19 Sep 2023 17:37:06 +0200 Subject: [PATCH] QmlJsEditor: Fix crash on mode switch after save Task-number: QDS-10709 Change-Id: I0eceef3815b6358d88329828d199d5918a273edf Reviewed-by: Thomas Hartmann Reviewed-by: Qt CI Patch Build Bot --- src/plugins/qmljseditor/qmljsoutline.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index a987120731d..75e0b0fdc22 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -145,10 +145,15 @@ void QmlJSOutlineWidget::setEditor(QmlJSEditorWidget *editor) connect(m_editor, &QmlJSEditorWidget::outlineModelIndexChanged, this, &QmlJSOutlineWidget::updateSelectionInTree); - connect(m_editor->qmlJsEditorDocument()->outlineModel(), &QmlOutlineModel::updated, this, [this] () { - m_treeView->expandAll(); - m_editor->updateOutlineIndexNow(); - }); + connect(m_editor->qmlJsEditorDocument()->outlineModel(), + &QmlOutlineModel::updated, + this, + [treeView = QPointer(m_treeView), editor = QPointer(m_editor)]() { + if (treeView) + treeView->expandAll(); + if (editor) + editor->updateOutlineIndexNow(); + }); } QList QmlJSOutlineWidget::filterMenuActions() const