QmlJS: Make Snapshot discard outdated Documents.

Previously, fresh versions of a Document would be added to the
_documentsByPath QMultiHash without removing the old version first.
This means Link could pick up old versions of a Document.

Task-number: QTCREATORBUG-1418
This commit is contained in:
Christian Kamm
2010-05-17 12:01:54 +02:00
parent bb6af2131c
commit 6f4b864487

View File

@@ -251,8 +251,14 @@ Snapshot::~Snapshot()
void Snapshot::insert(const Document::Ptr &document)
{
if (document && (document->qmlProgram() || document->jsProgram())) {
_documents.insert(document->fileName(), document);
_documentsByPath.insert(document->path(), document);
const QString fileName = document->fileName();
const QString path = document->path();
Document::Ptr old = _documents.value(fileName);
if (old)
_documentsByPath.remove(path, old);
_documentsByPath.insert(path, document);
_documents.insert(fileName, document);
}
}