Commit 9e81bd0b authored by Nikolai Kosjar's avatar Nikolai Kosjar

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: default avatarChristian Stenger <christian.stenger@digia.com>
parent 300c48e8
......@@ -255,7 +255,9 @@ void CppUseSelectionsUpdater::update(CallType callType)
{
CppEditorWidget *cppEditorWidget = qobject_cast<CppEditorWidget *>(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)
......
......@@ -110,7 +110,6 @@ private:
QTimer m_timer;
CPlusPlus::Document::Ptr m_document;
CPlusPlus::Snapshot m_snapshot;
QScopedPointer<QFutureWatcher<UseSelectionsResult>> m_findUsesWatcher;
int m_findUsesRevision;
......
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