forked from qt-creator/qt-creator
ClangCodeModel: Fix crash on git diff/show
currentEditorChanged is emitted also for none TextEditors, so check the qobject casted TextDocument before accessing it. Change-Id: I57080221bec34b879f21e022029524818ea92569 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -176,11 +176,12 @@ void ClangCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor *newCurren
|
||||
m_currentEditor = newCurrent;
|
||||
Core::IDocument *document = m_currentEditor->document();
|
||||
QTC_ASSERT(document, return;);
|
||||
auto *textDocument = qobject_cast<TextEditor::TextDocument *>(document);
|
||||
m_currentPath = textDocument->filePath().toString();
|
||||
} else {
|
||||
reset();
|
||||
if (auto *textDocument = qobject_cast<TextEditor::TextDocument *>(document)) {
|
||||
m_currentPath = textDocument->filePath().toString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
} // namespace ClangCodeModel
|
||||
|
||||
Reference in New Issue
Block a user