qmljs: cleanup locator's entries when closing a project

Task-number: QTCREATORBUG-13459
Change-Id: Icebe06a8a49389511a12506728f2109dc0b95287
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
Marco Benelli
2018-05-08 13:40:45 +02:00
parent 8a45da420a
commit 5aef87f155

View File

@@ -25,6 +25,9 @@
#include "qmljslocatordata.h" #include "qmljslocatordata.h"
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include <qmljs/qmljsmodelmanagerinterface.h> #include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsutils.h> #include <qmljs/qmljsutils.h>
//#include <qmljs/qmljsinterpreter.h> //#include <qmljs/qmljsinterpreter.h>
@@ -40,10 +43,25 @@ LocatorData::LocatorData()
{ {
ModelManagerInterface *manager = ModelManagerInterface::instance(); ModelManagerInterface *manager = ModelManagerInterface::instance();
// Force the updating of source file when updating a project (they could be cached, in such
// case LocatorData::onDocumentUpdated will not be called.
connect(manager, &ModelManagerInterface::projectInfoUpdated,
[manager](const ModelManagerInterface::ProjectInfo &info) {
QStringList files;
for (const Utils::FileName &f: info.project->files(ProjectExplorer::Project::SourceFiles))
files << f.toString();
manager->updateSourceFiles(files, true);
});
connect(manager, &ModelManagerInterface::documentUpdated, connect(manager, &ModelManagerInterface::documentUpdated,
this, &LocatorData::onDocumentUpdated); this, &LocatorData::onDocumentUpdated);
connect(manager, &ModelManagerInterface::aboutToRemoveFiles, connect(manager, &ModelManagerInterface::aboutToRemoveFiles,
this, &LocatorData::onAboutToRemoveFiles); this, &LocatorData::onAboutToRemoveFiles);
ProjectExplorer::SessionManager *session = ProjectExplorer::SessionManager::instance();
if (session)
connect(session, &ProjectExplorer::SessionManager::projectRemoved,
[this] (ProjectExplorer::Project*) { m_entries.clear(); });
} }
LocatorData::~LocatorData() LocatorData::~LocatorData()
@@ -233,4 +251,3 @@ void LocatorData::onAboutToRemoveFiles(const QStringList &files)
m_entries.remove(file); m_entries.remove(file);
} }
} }