diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-06-06 14:41:19 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-06-18 11:04:35 +0200 |
commit | 13d2d499ab95de10330fdfd44d53e50bf5a853b9 (patch) | |
tree | 15b3f33646e333e44ea10c65d859f22e878c574a /src/plugins/cpptools/cppsnapshotupdater.cpp | |
parent | 528fa525bc415a071d6a69d12f2f2c8c4f406b97 (diff) | |
download | qt-creator-13d2d499ab95de10330fdfd44d53e50bf5a853b9.tar.gz |
C++: move post-sourceprocessing action into callback.
Change-Id: Iac6c9fe1ada27ac0d96417e490cc5723e6969541
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppsnapshotupdater.cpp')
-rw-r--r-- | src/plugins/cpptools/cppsnapshotupdater.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/plugins/cpptools/cppsnapshotupdater.cpp b/src/plugins/cpptools/cppsnapshotupdater.cpp index c37473d0c7..63dc943d96 100644 --- a/src/plugins/cpptools/cppsnapshotupdater.cpp +++ b/src/plugins/cpptools/cppsnapshotupdater.cpp @@ -159,7 +159,17 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy) workingCopy.insert(editorDefinesFileName, m_editorDefines); } - CppSourceProcessor sourceProcessor(modelManager, m_snapshot); + CppSourceProcessor sourceProcessor(m_snapshot, [&](const Document::Ptr &doc) { + const QString fileName = doc->fileName(); + const bool isInEditor = fileName == fileInEditor(); + Document::Ptr otherDoc = modelManager->document(fileName); + unsigned newRev = otherDoc.isNull() ? 1U : otherDoc->revision() + 1; + if (isInEditor) + newRev = qMax(rev + 1, newRev); + doc->setRevision(newRev); + modelManager->emitDocumentUpdated(doc); + doc->releaseSourceAndAST(); + }); Snapshot globalSnapshot = modelManager->snapshot(); globalSnapshot.remove(fileInEditor()); sourceProcessor.setGlobalSnapshot(globalSnapshot); @@ -185,20 +195,6 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy) } m_snapshot = newSnapshot; m_deps.build(m_snapshot); - - foreach (Document::Ptr doc, m_snapshot) { - QString fileName = doc->fileName(); - if (doc->revision() == 0) { - Document::Ptr otherDoc = globalSnapshot.document(fileName); - doc->setRevision(otherDoc.isNull() ? 0 : otherDoc->revision()); - } - if (fileName != fileInEditor()) - doc->releaseSourceAndAST(); - } - - QTC_CHECK(document()); - if (Document::Ptr doc = document()) - doc->setRevision(rev + 1); } } |