CppTools: Fix updating pending queue in CppLocatorData

Fix that the invocations

  CppLocatorData::onDocumentUpdated(Document{"bla.cpp", revision=5}),
  CppLocatorData::onDocumentUpdated(Document{"bla.cpp", revision=3}),

would add two entries in m_pendingDocuments. The document from the
latter invocation should be ignored due to its outdated revision.

Change-Id: I5e9eb4de77f59633d5525d808bd60ca1259f894d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-07-16 11:48:08 +02:00
parent 56dc926b9d
commit 2778a5adab

View File

@@ -44,16 +44,18 @@ void CppLocatorData::onDocumentUpdated(const CPlusPlus::Document::Ptr &document)
{
QMutexLocker locker(&m_pendingDocumentsMutex);
int i = 0, ei = m_pendingDocuments.size();
for (; i < ei; ++i) {
bool isPending = false;
for (int i = 0, ei = m_pendingDocuments.size(); i < ei; ++i) {
const CPlusPlus::Document::Ptr &doc = m_pendingDocuments.at(i);
if (doc->fileName() == document->fileName() && doc->revision() <= document->revision()) {
m_pendingDocuments[i] = document;
if (doc->fileName() == document->fileName()) {
isPending = true;
if (document->revision() >= doc->revision())
m_pendingDocuments[i] = document;
break;
}
}
if (i == ei && QFileInfo(document->fileName()).suffix() != "moc")
if (!isPending && QFileInfo(document->fileName()).suffix() != "moc")
m_pendingDocuments.append(document);
flushPendingDocument(false);