summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/autotest/testcodeparser.cpp15
-rw-r--r--plugins/autotest/testcodeparser.h4
-rw-r--r--plugins/autotest/testnavigationwidget.cpp27
-rw-r--r--plugins/autotest/testnavigationwidget.h1
-rw-r--r--plugins/autotest/testresultspane.cpp22
-rw-r--r--plugins/autotest/testresultspane.h3
-rw-r--r--plugins/autotest/testtreemodel.cpp62
-rw-r--r--plugins/autotest/testtreemodel.h4
8 files changed, 109 insertions, 29 deletions
diff --git a/plugins/autotest/testcodeparser.cpp b/plugins/autotest/testcodeparser.cpp
index 0f950d305b..2fc0fff3ca 100644
--- a/plugins/autotest/testcodeparser.cpp
+++ b/plugins/autotest/testcodeparser.cpp
@@ -69,6 +69,15 @@ TestCodeParser::~TestCodeParser()
clearMaps();
}
+void TestCodeParser::setState(State state)
+{
+ m_parserState = state;
+ if (m_parserState == Disabled) {
+ m_pendingUpdate = m_fullUpdatePostPoned = m_partialUpdatePostPoned = false;
+ m_postPonedFiles.clear();
+ }
+}
+
void TestCodeParser::emitUpdateTestTree()
{
QTimer::singleShot(1000, this, SLOT(updateTestTree()));
@@ -527,6 +536,9 @@ bool TestCodeParser::postponed(const QStringList &fileList)
m_partialUpdatePostPoned = true;
}
return true;
+ case Disabled:
+ qWarning("Checking for postponing but being disabled...");
+ return false;
}
QTC_ASSERT(false, return false); // should not happen at all
}
@@ -565,7 +577,8 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
m_parserState = Idle;
emit parsingFinished();
break;
- case Idle:
+ default:
+ qWarning("I should not be here...");
break;
}
}
diff --git a/plugins/autotest/testcodeparser.h b/plugins/autotest/testcodeparser.h
index d846769b37..9b6670c320 100644
--- a/plugins/autotest/testcodeparser.h
+++ b/plugins/autotest/testcodeparser.h
@@ -46,11 +46,13 @@ public:
enum State {
Idle,
PartialParse,
- FullParse
+ FullParse,
+ Disabled
};
explicit TestCodeParser(TestTreeModel *parent = 0);
virtual ~TestCodeParser();
+ void setState(State state);
#ifdef WITH_TESTS
int autoTestsCount() const;
diff --git a/plugins/autotest/testnavigationwidget.cpp b/plugins/autotest/testnavigationwidget.cpp
index 0f1fca7a41..8338455623 100644
--- a/plugins/autotest/testnavigationwidget.cpp
+++ b/plugins/autotest/testnavigationwidget.cpp
@@ -26,12 +26,8 @@
#include "testtreeitem.h"
#include <coreplugin/find/itemviewfind.h>
-#include <projectexplorer/session.h>
-#include <cpptools/cppmodelmanager.h>
-#include <qmljstools/qmljsmodelmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
-#include <projectexplorer/project.h>
#include <texteditor/texteditor.h>
#include <QToolButton>
@@ -58,26 +54,14 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) :
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_view));
setLayout(layout);
- TestCodeParser *parser = m_model->parser();
- ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
- connect(sm, &ProjectExplorer::SessionManager::startupProjectChanged,
- parser, &TestCodeParser::emitUpdateTestTree);
-
- CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
- connect(cppMM, &CppTools::CppModelManager::documentUpdated,
- parser, &TestCodeParser::onCppDocumentUpdated, Qt::QueuedConnection);
- connect(cppMM, &CppTools::CppModelManager::aboutToRemoveFiles,
- parser, &TestCodeParser::removeFiles, Qt::QueuedConnection);
-
- QmlJS::ModelManagerInterface *qmlJsMM = QmlJSTools::Internal::ModelManager::instance();
- connect(qmlJsMM, &QmlJS::ModelManagerInterface::documentUpdated,
- parser, &TestCodeParser::onQmlDocumentUpdated, Qt::QueuedConnection);
- connect(qmlJsMM, &QmlJS::ModelManagerInterface::aboutToRemoveFiles,
- parser, &TestCodeParser::removeFiles, Qt::QueuedConnection);
-
connect(m_view, &TestTreeView::activated, this, &TestNavigationWidget::onItemActivated);
}
+TestNavigationWidget::~TestNavigationWidget()
+{
+ m_model->disableParsing();
+}
+
void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
{
const bool enabled = !TestRunner::instance()->isTestRunning();
@@ -223,6 +207,7 @@ Core::NavigationView TestNavigationWidgetFactory::createWidget()
Core::NavigationView view;
view.widget = treeViewWidget;
view.dockToolBarWidgets = treeViewWidget->createToolButtons();
+ TestTreeModel::instance()->enableParsing();
return view;
}
diff --git a/plugins/autotest/testnavigationwidget.h b/plugins/autotest/testnavigationwidget.h
index 2700cf2c12..50d6ae8970 100644
--- a/plugins/autotest/testnavigationwidget.h
+++ b/plugins/autotest/testnavigationwidget.h
@@ -46,6 +46,7 @@ class TestNavigationWidget : public QWidget
public:
explicit TestNavigationWidget(QWidget *parent = 0);
+ ~TestNavigationWidget();
void contextMenuEvent(QContextMenuEvent *event);
QList<QToolButton *> createToolButtons();
diff --git a/plugins/autotest/testresultspane.cpp b/plugins/autotest/testresultspane.cpp
index f2430fd420..cb93d156fa 100644
--- a/plugins/autotest/testresultspane.cpp
+++ b/plugins/autotest/testresultspane.cpp
@@ -42,7 +42,8 @@ namespace Internal {
TestResultsPane::TestResultsPane(QObject *parent) :
Core::IOutputPane(parent),
- m_context(new Core::IContext(this))
+ m_context(new Core::IContext(this)),
+ m_wasVisibleBefore(false)
{
m_outputWidget = new QWidget;
QVBoxLayout *outputLayout = new QVBoxLayout;
@@ -87,8 +88,6 @@ TestResultsPane::TestResultsPane(QObject *parent) :
this, &TestResultsPane::onTestRunStarted);
connect(TestRunner::instance(), &TestRunner::testRunFinished,
this, &TestResultsPane::onTestRunFinished);
- connect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged,
- this, &TestResultsPane::onTestTreeModelChanged);
}
void TestResultsPane::createToolButtons()
@@ -178,8 +177,23 @@ void TestResultsPane::clearContents()
m_summaryWidget->setVisible(false);
}
-void TestResultsPane::visibilityChanged(bool)
+void TestResultsPane::visibilityChanged(bool visible)
{
+ if (visible) {
+ if (m_wasVisibleBefore)
+ return;
+ connect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged,
+ this, &TestResultsPane::onTestTreeModelChanged);
+ m_wasVisibleBefore = true;
+ TestTreeModel::instance()->enableParsing();
+ } else {
+ if (!m_wasVisibleBefore)
+ return;
+ disconnect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged,
+ this, &TestResultsPane::onTestTreeModelChanged);
+ m_wasVisibleBefore = false;
+ TestTreeModel::instance()->disableParsing();
+ }
}
void TestResultsPane::setFocus()
diff --git a/plugins/autotest/testresultspane.h b/plugins/autotest/testresultspane.h
index 99c3555236..3567bd292e 100644
--- a/plugins/autotest/testresultspane.h
+++ b/plugins/autotest/testresultspane.h
@@ -58,7 +58,7 @@ public:
QString displayName() const;
int priorityInStatusBar() const;
void clearContents();
- void visibilityChanged(bool);
+ void visibilityChanged(bool visible);
void setFocus();
bool hasFocus() const;
bool canFocus() const;
@@ -102,6 +102,7 @@ private:
QToolButton *m_stopTestRun;
QToolButton *m_filterButton;
QMenu *m_filterMenu;
+ bool m_wasVisibleBefore;
};
} // namespace Internal
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index bccabf898a..cc54b6969a 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -31,6 +31,8 @@
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
+#include <qmljs/qmljsmodelmanagerinterface.h>
+
#include <texteditor/texteditor.h>
#include <utils/fileutils.h>
@@ -46,7 +48,9 @@ TestTreeModel::TestTreeModel(QObject *parent) :
m_rootItem(new TestTreeItem(QString(), QString(), TestTreeItem::ROOT)),
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_parser(new TestCodeParser(this)),
+ m_connectionsInitialized(false),
+ m_initializationCounter(0)
{
m_rootItem->appendChild(m_autoTestRootItem);
m_rootItem->appendChild(m_quickTestRootItem);
@@ -90,6 +94,62 @@ TestTreeModel::~TestTreeModel()
m_instance = 0;
}
+void TestTreeModel::enableParsing()
+{
+ ++m_initializationCounter;
+
+ if (m_connectionsInitialized)
+ return;
+
+ m_parser->setState(TestCodeParser::Idle);
+
+ ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance();
+ connect(sm, &ProjectExplorer::SessionManager::startupProjectChanged,
+ m_parser, &TestCodeParser::emitUpdateTestTree);
+
+ CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
+ connect(cppMM, &CppTools::CppModelManager::documentUpdated,
+ m_parser, &TestCodeParser::onCppDocumentUpdated, Qt::QueuedConnection);
+ connect(cppMM, &CppTools::CppModelManager::aboutToRemoveFiles,
+ m_parser, &TestCodeParser::removeFiles, Qt::QueuedConnection);
+
+ QmlJS::ModelManagerInterface *qmlJsMM = QmlJS::ModelManagerInterface::instance();
+ connect(qmlJsMM, &QmlJS::ModelManagerInterface::documentUpdated,
+ m_parser, &TestCodeParser::onQmlDocumentUpdated, Qt::QueuedConnection);
+ 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
{
if (!hasIndex(row, column, parent))
diff --git a/plugins/autotest/testtreemodel.h b/plugins/autotest/testtreemodel.h
index b21eafbb7f..46a7b28a95 100644
--- a/plugins/autotest/testtreemodel.h
+++ b/plugins/autotest/testtreemodel.h
@@ -53,6 +53,8 @@ public:
static TestTreeModel* instance();
~TestTreeModel();
+ void enableParsing();
+ void disableParsing();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
@@ -109,6 +111,8 @@ private:
TestTreeItem *m_autoTestRootItem;
TestTreeItem *m_quickTestRootItem;
TestCodeParser *m_parser;
+ bool m_connectionsInitialized;
+ int m_initializationCounter;
};