QmlDesigner: Crash fix

We have to use deleteLater.
If a file change is triggered by the text editor (F2 follow symbol),
the new text editor is set, while some text editor code
is still keeping a pointer to the original text editor.

Change-Id: I25e271f3800b763d644d9f2c5dd2b80b74ecf990
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-02-28 17:48:50 +01:00
committed by Tim Jenssen
parent c887de8c1a
commit 20b082b327

View File

@@ -61,6 +61,7 @@ TextEditorWidget::TextEditorWidget(TextEditorView *textEditorView)
void TextEditorWidget::setTextEditor(TextEditor::BaseTextEditor *textEditor) void TextEditorWidget::setTextEditor(TextEditor::BaseTextEditor *textEditor)
{ {
TextEditor::BaseTextEditor *oldEditor = m_textEditor.release();
m_textEditor.reset(textEditor); m_textEditor.reset(textEditor);
layout()->removeWidget(m_statusBar); layout()->removeWidget(m_statusBar);
layout()->addWidget(textEditor->editorWidget()); layout()->addWidget(textEditor->editorWidget());
@@ -70,6 +71,9 @@ void TextEditorWidget::setTextEditor(TextEditor::BaseTextEditor *textEditor)
connect(textEditor->editorWidget(), &QPlainTextEdit::cursorPositionChanged, connect(textEditor->editorWidget(), &QPlainTextEdit::cursorPositionChanged,
&m_updateSelectionTimer, static_cast<void (QTimer::*)()>(&QTimer::start)); &m_updateSelectionTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
textEditor->editorWidget()->installEventFilter(this); textEditor->editorWidget()->installEventFilter(this);
if (oldEditor)
oldEditor->deleteLater();
} }
QString TextEditorWidget::contextHelpId() const QString TextEditorWidget::contextHelpId() const