forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user