summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-04-14 15:24:31 +0200
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-04-16 16:22:21 +0300
commitb88bfbb55a8e50c9ddaef9f7e803658009c0df6f (patch)
treeac6047c97f475afd2275c7933c7ddb00de5688fa
parenta1e8cc5e44b8ab4bb5e78ec4a6fe08615038c0ae (diff)
downloadqt-creator-b88bfbb55a8e50c9ddaef9f7e803658009c0df6f.tar.gz
Fix state handling of parser...
...and enable/disable respective menu items accordingly. Now it should be impossible to trigger more than one parse at a time or setting a state and invalidating a state with higher priority. Change-Id: I0bcbeca6626209918e0a74b0bd2722583fc47bb3 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
-rw-r--r--plugins/autotest/autotestplugin.cpp9
-rw-r--r--plugins/autotest/testcodeparser.cpp14
2 files changed, 15 insertions, 8 deletions
diff --git a/plugins/autotest/autotestplugin.cpp b/plugins/autotest/autotestplugin.cpp
index 724841f025..a2ab783418 100644
--- a/plugins/autotest/autotestplugin.cpp
+++ b/plugins/autotest/autotestplugin.cpp
@@ -126,8 +126,10 @@ void AutotestPlugin::initializeMenuEntries()
TestTreeModel::instance()->parser(), &TestCodeParser::updateTestTree);
menu->addAction(command);
- ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
- connect(menu->menu(), &QMenu::aboutToShow, this, &AutotestPlugin::updateMenuItemsEnabledState);
+ ActionContainer *toolsMenu = ActionManager::actionContainer(Core::Constants::M_TOOLS);
+ toolsMenu->addMenu(menu);
+ connect(toolsMenu->menu(), &QMenu::aboutToShow,
+ this, &AutotestPlugin::updateMenuItemsEnabledState);
}
bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorString)
@@ -175,7 +177,8 @@ void AutotestPlugin::onRunSelectedTriggered()
void AutotestPlugin::updateMenuItemsEnabledState()
{
- const bool enabled = !TestRunner::instance()->isTestRunning();
+ const bool enabled = !TestRunner::instance()->isTestRunning()
+ && TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle;
const bool hasTests = TestTreeModel::instance()->hasTests();
ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(enabled && hasTests);
diff --git a/plugins/autotest/testcodeparser.cpp b/plugins/autotest/testcodeparser.cpp
index c3ae634b59..8c0b7b43d7 100644
--- a/plugins/autotest/testcodeparser.cpp
+++ b/plugins/autotest/testcodeparser.cpp
@@ -86,10 +86,15 @@ ProjectExplorer::Project *currentProject()
void TestCodeParser::setState(State state)
{
- m_parserState = state;
// avoid triggering parse before code model parsing has finished
if (!m_parserEnabled)
return;
+
+ if ((state == Disabled || state == Idle)
+ && (m_parserState == PartialParse || m_parserState == FullParse))
+ return;
+ m_parserState = state;
+
if (m_parserState == Disabled) {
m_fullUpdatePostponed = m_partialUpdatePostponed = false;
m_postponedFiles.clear();
@@ -738,8 +743,8 @@ void TestCodeParser::onAllTasksFinished(Core::Id type)
return;
m_parserEnabled = true;
// avoid illegal parser state if respective widgets became hidden while parsing
- if (m_parserState == Disabled)
- m_parserState = Idle;
+ setState(Idle);
+
if (m_fullUpdatePostponed)
updateTestTree();
else if (m_partialUpdatePostponed) {
@@ -902,8 +907,7 @@ void TestCodeParser::onProFileEvaluated()
foreach (auto projectFile, p->files)
files.append(projectFile.path);
// avoid illegal parser state when respective widgets became hidden while evaluating
- if (m_parserState == Disabled)
- m_parserState = Idle;
+ setState(Idle);
scanForTests(files);
}
}