From 787f0498cad08416f6af514764a9a19fc51019dd Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 20 Apr 2018 13:55:49 +0200 Subject: [PATCH] Clang: Fix wrong QTC_ASSERTS If the last editor is closed, "editor" becomes a nullptr, which is valid value in this case. Change-Id: Id5f92cb4367199d782e33acc37077103e9986644 Reviewed-by: David Schulz --- .../clangcodemodel/clangeditordocumentprocessor.cpp | 2 +- .../clangcodemodel/clangeditordocumentprocessor.h | 2 +- .../clangcodemodel/clangmodelmanagersupport.cpp | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index a3f08b12c7c..05e5f37fa73 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -243,7 +243,7 @@ const QVector void ClangEditorDocumentProcessor::clearTaskHubIssues() { - m_diagnosticManager.clearTaskHubIssues(); + ClangDiagnosticManager::clearTaskHubIssues(); } void ClangEditorDocumentProcessor::generateTaskHubIssues() diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.h b/src/plugins/clangcodemodel/clangeditordocumentprocessor.h index 018536be210..cf4f1e51ed2 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.h +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.h @@ -103,7 +103,7 @@ public: const QVector &tokenInfos() const; - void clearTaskHubIssues(); + static void clearTaskHubIssues(); void generateTaskHubIssues(); public: diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index f0bb8d92981..0d7a0575b60 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -165,14 +165,12 @@ void ModelManagerSupportClang::onCurrentEditorChanged(Core::IEditor *editor) m_communicator.updateTranslationUnitVisiblity(); // Update task hub issues for current CppEditorDocument - QTC_ASSERT(editor, return); - Core::IDocument *document = editor->document(); - QTC_ASSERT(document, return); - TextEditor::TextDocument *textDocument = qobject_cast(document); + ClangEditorDocumentProcessor::clearTaskHubIssues(); + if (!editor || !editor->document() || !cppModelManager()->isCppEditor(editor)) + return; - auto processor = ClangEditorDocumentProcessor::get(document->filePath().toString()); - processor->clearTaskHubIssues(); - if (textDocument && cppModelManager()->isCppEditor(editor)) + const ::Utils::FileName filePath = editor->document()->filePath(); + if (auto processor = ClangEditorDocumentProcessor::get(filePath.toString())) processor->generateTaskHubIssues(); }