forked from qt-creator/qt-creator
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:
@@ -44,16 +44,18 @@ void CppLocatorData::onDocumentUpdated(const CPlusPlus::Document::Ptr &document)
|
|||||||
{
|
{
|
||||||
QMutexLocker locker(&m_pendingDocumentsMutex);
|
QMutexLocker locker(&m_pendingDocumentsMutex);
|
||||||
|
|
||||||
int i = 0, ei = m_pendingDocuments.size();
|
bool isPending = false;
|
||||||
for (; i < ei; ++i) {
|
for (int i = 0, ei = m_pendingDocuments.size(); i < ei; ++i) {
|
||||||
const CPlusPlus::Document::Ptr &doc = m_pendingDocuments.at(i);
|
const CPlusPlus::Document::Ptr &doc = m_pendingDocuments.at(i);
|
||||||
if (doc->fileName() == document->fileName() && doc->revision() <= document->revision()) {
|
if (doc->fileName() == document->fileName()) {
|
||||||
|
isPending = true;
|
||||||
|
if (document->revision() >= doc->revision())
|
||||||
m_pendingDocuments[i] = document;
|
m_pendingDocuments[i] = document;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == ei && QFileInfo(document->fileName()).suffix() != "moc")
|
if (!isPending && QFileInfo(document->fileName()).suffix() != "moc")
|
||||||
m_pendingDocuments.append(document);
|
m_pendingDocuments.append(document);
|
||||||
|
|
||||||
flushPendingDocument(false);
|
flushPendingDocument(false);
|
||||||
|
Reference in New Issue
Block a user