From 6b894b50e62961e2ecaa0601eadb36740e87dd53 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Wed, 3 Dec 2014 12:11:48 +0100 Subject: [PATCH] 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: Eike Ziller --- src/plugins/cpptools/cppmodelmanager.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index adbb7b8bfa3..e2948e9fd75 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -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 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); } }