Commit 6b894b50 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Remove QTC_ASSERT in CppModelManager::editorDocument()

This fixes

    SOFT ASSERT: "!filePath.isEmpty()" in file
    /home/nik/dev/creator/creator-ut/src/plugins/cpptools/cppmodelmanager.cpp,
    line 467

which can be triggered by e.g. a "git show" document
(onCurrentEditorChanged does not check for an empty file path).

Change-Id: If4ed8e552069b290cb4ac93da52427b7ed2b91e8
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 64d6d64c
......@@ -464,7 +464,8 @@ void CppModelManager::removeExtraEditorSupport(AbstractEditorSupport *editorSupp
EditorDocumentHandle *CppModelManager::editorDocument(const QString &filePath) const
{
QTC_ASSERT(!filePath.isEmpty(), return 0);
if (filePath.isEmpty())
return 0;
QMutexLocker locker(&d->m_cppEditorsMutex);
return d->m_cppEditors.value(filePath, 0);
......@@ -697,12 +698,9 @@ void CppModelManager::updateCppEditorDocuments() const
QSet<Core::IDocument *> visibleCppEditorDocuments;
foreach (Core::IEditor *editor, Core::EditorManager::visibleEditors()) {
if (Core::IDocument *document = editor->document()) {
const QString filePath = document->filePath();
if (filePath.isEmpty())
continue;
if (EditorDocumentHandle *editor = editorDocument(filePath)) {
if (EditorDocumentHandle *cppEditorDocument = editorDocument(document->filePath())) {
visibleCppEditorDocuments.insert(document);
editor->processor()->run();
cppEditorDocument->processor()->run();
}
}
}
......@@ -712,11 +710,8 @@ void CppModelManager::updateCppEditorDocuments() const
= Core::DocumentModel::openedDocuments().toSet();
invisibleCppEditorDocuments.subtract(visibleCppEditorDocuments);
foreach (Core::IDocument *document, invisibleCppEditorDocuments) {
const QString filePath = document->filePath();
if (filePath.isEmpty())
continue;
if (EditorDocumentHandle *document = editorDocument(filePath))
document->setNeedsRefresh(true);
if (EditorDocumentHandle *cppEditorDocument = editorDocument(document->filePath()))
cppEditorDocument->setNeedsRefresh(true);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment