forked from qt-creator/qt-creator
ClangTools: Fix crash in document tool runner
Prevent removing refactor markers from already destroyed widgets. Fixes: QTCREATORBUG-24982 Change-Id: Icf8950f8f8407fa8733a1ef30d05abb4a2b44dd4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -105,15 +105,21 @@ Diagnostics DocumentClangToolRunner::diagnosticsAtLine(int lineNumber) const
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
static void removeClangToolRefactorMarkers(TextEditor::TextEditorWidget *editor)
|
||||
{
|
||||
if (!editor)
|
||||
return;
|
||||
editor->setRefactorMarkers(
|
||||
TextEditor::RefactorMarker::filterOutType(editor->refactorMarkers(),
|
||||
Constants::CLANG_TOOL_FIXIT_AVAILABLE_MARKER_ID));
|
||||
}
|
||||
|
||||
void DocumentClangToolRunner::scheduleRun()
|
||||
{
|
||||
for (DiagnosticMark *mark : m_marks)
|
||||
mark->disable();
|
||||
for (TextEditor::TextEditorWidget *editor : m_editorsWithMarkers) {
|
||||
editor->setRefactorMarkers(
|
||||
TextEditor::RefactorMarker::filterOutType(editor->refactorMarkers(),
|
||||
Constants::CLANG_TOOL_FIXIT_AVAILABLE_MARKER_ID));
|
||||
}
|
||||
for (TextEditor::TextEditorWidget *editor : m_editorsWithMarkers)
|
||||
removeClangToolRefactorMarkers(editor);
|
||||
m_runTimer.start();
|
||||
}
|
||||
|
||||
@@ -325,7 +331,8 @@ void DocumentClangToolRunner::onSuccess()
|
||||
for (auto editor : TextEditor::BaseTextEditor::textEditorsForDocument(doc)) {
|
||||
if (TextEditor::TextEditorWidget *widget = editor->editorWidget()) {
|
||||
widget->setRefactorMarkers(markers + widget->refactorMarkers());
|
||||
m_editorsWithMarkers << widget;
|
||||
if (!m_editorsWithMarkers.contains(widget))
|
||||
m_editorsWithMarkers << widget;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -83,7 +83,7 @@ private:
|
||||
QList<DiagnosticMark *> m_marks;
|
||||
FileInfo m_fileInfo;
|
||||
QMetaObject::Connection m_projectSettingsUpdate;
|
||||
QSet<TextEditor::TextEditorWidget *> m_editorsWithMarkers;
|
||||
QList<QPointer<TextEditor::TextEditorWidget>> m_editorsWithMarkers;
|
||||
SuppressedDiagnosticsList m_suppressed;
|
||||
Utils::FilePath m_lastProjectDirectory;
|
||||
};
|
||||
|
Reference in New Issue
Block a user