diff options
author | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2014-12-03 12:11:48 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2014-12-03 13:07:58 +0100 |
commit | 6b894b50e62961e2ecaa0601eadb36740e87dd53 (patch) | |
tree | 390ee0534b89fac537b94e7f102d1d992b34be6b | |
parent | 64d6d64c933711afbb32c4ecf91c168d82f8e407 (diff) | |
download | qt-creator-6b894b50e62961e2ecaa0601eadb36740e87dd53.tar.gz |
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 <eike.ziller@theqtcompany.com>
-rw-r--r-- | src/plugins/cpptools/cppmodelmanager.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index adbb7b8bfa..e2948e9fd7 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<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); } } |