From 51cc3957b49b5bc305409ec012f3f97fa8db419b Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 6 Apr 2018 09:24:48 +0200 Subject: [PATCH] AutoTest: Replace expensive function call Depending on the underlying project manager it can be pretty expensive calling PE::canRunStartupProject(). AutoTest plugin used this to determine whether its global actions should be enabled or not and updating these actions is triggered for too many causes. Replace this function call by some simple checks that have almost no cost to avoid blocking UI. Task-number: QTCREATORBUG-20175 Change-Id: I0e3cce683f33abe82bf1354ec5276250f5e30068 Reviewed-by: Christian Kandeler --- src/plugins/autotest/autotestplugin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index ed81d60a28d..e618f20c818 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -50,6 +50,8 @@ #include #include #include +#include +#include #include #include @@ -192,12 +194,16 @@ void AutotestPlugin::onRunSelectedTriggered() void AutotestPlugin::updateMenuItemsEnabledState() { + const ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); + const ProjectExplorer::Target *target = project ? project->activeTarget() : nullptr; const bool canScan = !TestRunner::instance()->isTestRunning() && TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle; const bool hasTests = TestTreeModel::instance()->hasTests(); + // avoid expensive call to PE::canRunStartupProject() - limit to minimum necessary checks const bool canRun = hasTests && canScan - && ProjectExplorer::ProjectExplorerPlugin::canRunStartupProject( - ProjectExplorer::Constants::NORMAL_RUN_MODE); + && project && !project->needsConfiguration() + && target && target->activeRunConfiguration() + && !ProjectExplorer::BuildManager::isBuilding(); ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(canRun); ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()->setEnabled(canRun);