From 9e81bd0b36ff3fac14c599dad3d8fae750e45389 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 8 Sep 2014 10:15:31 +0200 Subject: [PATCH] CppEditor: Clean up CppUseSelectionsUpdater * Remove unused member m_snapshot * QTC_CHECK -> "if (!...)" - the revision might have changed in the mean time * Restore previous document in synchronous case Change-Id: Ie05c044fbb75e92edbf0fdb041178aadde8113c5 Reviewed-by: Christian Stenger --- src/plugins/cppeditor/cppuseselectionsupdater.cpp | 9 ++++++--- src/plugins/cppeditor/cppuseselectionsupdater.h | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/cppeditor/cppuseselectionsupdater.cpp b/src/plugins/cppeditor/cppuseselectionsupdater.cpp index a55999ecdc5..cfc8bce8071 100644 --- a/src/plugins/cppeditor/cppuseselectionsupdater.cpp +++ b/src/plugins/cppeditor/cppuseselectionsupdater.cpp @@ -255,7 +255,9 @@ void CppUseSelectionsUpdater::update(CallType callType) { CppEditorWidget *cppEditorWidget = qobject_cast(m_editorWidget); QTC_ASSERT(cppEditorWidget, return); - QTC_CHECK(cppEditorWidget->isSemanticInfoValidExceptLocalUses()); + if (!cppEditorWidget->isSemanticInfoValidExceptLocalUses()) + return; + const CppTools::SemanticInfo semanticInfo = cppEditorWidget->semanticInfo(); const Document::Ptr document = semanticInfo.doc; const Snapshot snapshot = semanticInfo.snapshot; @@ -296,7 +298,6 @@ void CppUseSelectionsUpdater::onFindUsesFinished() m_findUsesWatcher.reset(); m_document.reset(); - m_snapshot = Snapshot(); } bool CppUseSelectionsUpdater::handleMacroCase(const Document::Ptr document) @@ -342,7 +343,6 @@ void CppUseSelectionsUpdater::handleSymbolCaseAsynchronously(const Document::Ptr const Snapshot &snapshot) { m_document = document; - m_snapshot = snapshot; if (m_findUsesWatcher) m_findUsesWatcher->cancel(); @@ -359,11 +359,14 @@ void CppUseSelectionsUpdater::handleSymbolCaseAsynchronously(const Document::Ptr void CppUseSelectionsUpdater::handleSymbolCaseSynchronously(const Document::Ptr document, const Snapshot &snapshot) { + const CPlusPlus::Document::Ptr previousDocument = m_document; m_document = document; const Params params = Params(m_editorWidget->textCursor(), document, snapshot); const UseSelectionsResult result = findUses(params); processSymbolCaseResults(result); + + m_document = previousDocument; } void CppUseSelectionsUpdater::processSymbolCaseResults(const UseSelectionsResult &result) diff --git a/src/plugins/cppeditor/cppuseselectionsupdater.h b/src/plugins/cppeditor/cppuseselectionsupdater.h index bb615760f1e..2eb33e1035b 100644 --- a/src/plugins/cppeditor/cppuseselectionsupdater.h +++ b/src/plugins/cppeditor/cppuseselectionsupdater.h @@ -110,7 +110,6 @@ private: QTimer m_timer; CPlusPlus::Document::Ptr m_document; - CPlusPlus::Snapshot m_snapshot; QScopedPointer> m_findUsesWatcher; int m_findUsesRevision;