From b88bfbb55a8e50c9ddaef9f7e803658009c0df6f Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 14 Apr 2015 15:24:31 +0200 Subject: [PATCH] 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 --- plugins/autotest/autotestplugin.cpp | 9 ++++++--- plugins/autotest/testcodeparser.cpp | 14 +++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/plugins/autotest/autotestplugin.cpp b/plugins/autotest/autotestplugin.cpp index 724841f025c..a2ab7834187 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 c3ae634b598..8c0b7b43d7b 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); } }