forked from qt-creator/qt-creator
Improve handling of disabled parser and re-enabling parser
Instead of always parsing again when re-enabling parser do it only if there are changes of the current project. If the current project has not changed since last parsing just rely on the cached information. Change-Id: I7681318132f37172730648604ddbecf1cd37d177 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com> Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -51,8 +51,7 @@ TestTreeModel::TestTreeModel(QObject *parent) :
|
||||
m_autoTestRootItem(new TestTreeItem(tr("Auto Tests"), QString(), TestTreeItem::ROOT, m_rootItem)),
|
||||
m_quickTestRootItem(new TestTreeItem(tr("Qt Quick Tests"), QString(), TestTreeItem::ROOT, m_rootItem)),
|
||||
m_parser(new TestCodeParser(this)),
|
||||
m_connectionsInitialized(false),
|
||||
m_initializationCounter(0)
|
||||
m_connectionsInitialized(false)
|
||||
{
|
||||
m_rootItem->appendChild(m_autoTestRootItem);
|
||||
m_rootItem->appendChild(m_quickTestRootItem);
|
||||
@@ -103,13 +102,10 @@ TestTreeModel::~TestTreeModel()
|
||||
|
||||
void TestTreeModel::enableParsing()
|
||||
{
|
||||
++m_initializationCounter;
|
||||
|
||||
m_parser->setState(TestCodeParser::Idle);
|
||||
if (m_connectionsInitialized)
|
||||
return;
|
||||
|
||||
m_parser->setState(TestCodeParser::Idle);
|
||||
|
||||
ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
|
||||
connect(sm, &ProjectExplorer::SessionManager::startupProjectChanged,
|
||||
m_parser, &TestCodeParser::emitUpdateTestTree);
|
||||
@@ -126,35 +122,11 @@ void TestTreeModel::enableParsing()
|
||||
connect(qmlJsMM, &QmlJS::ModelManagerInterface::aboutToRemoveFiles,
|
||||
m_parser, &TestCodeParser::removeFiles, Qt::QueuedConnection);
|
||||
m_connectionsInitialized = true;
|
||||
m_parser->updateTestTree();
|
||||
}
|
||||
|
||||
void TestTreeModel::disableParsing()
|
||||
{
|
||||
if (!m_connectionsInitialized)
|
||||
return;
|
||||
if (--m_initializationCounter != 0)
|
||||
return;
|
||||
|
||||
ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
|
||||
disconnect(sm, &ProjectExplorer::SessionManager::startupProjectChanged,
|
||||
m_parser, &TestCodeParser::emitUpdateTestTree);
|
||||
|
||||
CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
|
||||
disconnect(cppMM, &CppTools::CppModelManager::documentUpdated,
|
||||
m_parser, &TestCodeParser::onCppDocumentUpdated);
|
||||
disconnect(cppMM, &CppTools::CppModelManager::aboutToRemoveFiles,
|
||||
m_parser, &TestCodeParser::removeFiles);
|
||||
|
||||
QmlJS::ModelManagerInterface *qmlJsMM = QmlJS::ModelManagerInterface::instance();
|
||||
disconnect(qmlJsMM, &QmlJS::ModelManagerInterface::documentUpdated,
|
||||
m_parser, &TestCodeParser::onQmlDocumentUpdated);
|
||||
disconnect(qmlJsMM, &QmlJS::ModelManagerInterface::aboutToRemoveFiles,
|
||||
m_parser, &TestCodeParser::removeFiles);
|
||||
|
||||
m_parser->setState(TestCodeParser::Disabled);
|
||||
|
||||
m_connectionsInitialized = false;
|
||||
}
|
||||
|
||||
QModelIndex TestTreeModel::index(int row, int column, const QModelIndex &parent) const
|
||||
|
||||
Reference in New Issue
Block a user