aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/autotest/autotestplugin.cpp
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2018-04-06 09:24:48 +0200
committerChristian Stenger <christian.stenger@qt.io>2018-04-09 10:38:23 +0000
commit51cc3957b49b5bc305409ec012f3f97fa8db419b (patch)
tree02b2c28f34b5b346fd1b1ebd77d45865da9635b0 /src/plugins/autotest/autotestplugin.cpp
parent9053cd7515a47605738a2e418d62d94db445ec8b (diff)
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 <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/autotest/autotestplugin.cpp')
-rw-r--r--src/plugins/autotest/autotestplugin.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp
index ed81d60a28..e618f20c81 100644
--- a/src/plugins/autotest/autotestplugin.cpp
+++ b/src/plugins/autotest/autotestplugin.cpp
@@ -50,6 +50,8 @@
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/session.h>
+#include <projectexplorer/target.h>
#include <utils/utilsicons.h>
#include <QAction>
@@ -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);