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;
|
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()
|
void DocumentClangToolRunner::scheduleRun()
|
||||||
{
|
{
|
||||||
for (DiagnosticMark *mark : m_marks)
|
for (DiagnosticMark *mark : m_marks)
|
||||||
mark->disable();
|
mark->disable();
|
||||||
for (TextEditor::TextEditorWidget *editor : m_editorsWithMarkers) {
|
for (TextEditor::TextEditorWidget *editor : m_editorsWithMarkers)
|
||||||
editor->setRefactorMarkers(
|
removeClangToolRefactorMarkers(editor);
|
||||||
TextEditor::RefactorMarker::filterOutType(editor->refactorMarkers(),
|
|
||||||
Constants::CLANG_TOOL_FIXIT_AVAILABLE_MARKER_ID));
|
|
||||||
}
|
|
||||||
m_runTimer.start();
|
m_runTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +331,8 @@ void DocumentClangToolRunner::onSuccess()
|
|||||||
for (auto editor : TextEditor::BaseTextEditor::textEditorsForDocument(doc)) {
|
for (auto editor : TextEditor::BaseTextEditor::textEditorsForDocument(doc)) {
|
||||||
if (TextEditor::TextEditorWidget *widget = editor->editorWidget()) {
|
if (TextEditor::TextEditorWidget *widget = editor->editorWidget()) {
|
||||||
widget->setRefactorMarkers(markers + widget->refactorMarkers());
|
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;
|
QList<DiagnosticMark *> m_marks;
|
||||||
FileInfo m_fileInfo;
|
FileInfo m_fileInfo;
|
||||||
QMetaObject::Connection m_projectSettingsUpdate;
|
QMetaObject::Connection m_projectSettingsUpdate;
|
||||||
QSet<TextEditor::TextEditorWidget *> m_editorsWithMarkers;
|
QList<QPointer<TextEditor::TextEditorWidget>> m_editorsWithMarkers;
|
||||||
SuppressedDiagnosticsList m_suppressed;
|
SuppressedDiagnosticsList m_suppressed;
|
||||||
Utils::FilePath m_lastProjectDirectory;
|
Utils::FilePath m_lastProjectDirectory;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user