From 4b92b7ac60586f034fd4117de90f61cd196e8976 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 2 Jul 2019 18:22:38 +0200 Subject: [PATCH] ProjectExplorer: Allow users to schedule a run ... while a build for the corresponding project is going on. The respective application will be run after the build has finished. Fixes: QTCREATORBUG-14297 Change-Id: Ib0931c2ff6529d891faa41d499afe7ede97a11db Reviewed-by: hjk --- src/plugins/projectexplorer/buildmanager.cpp | 9 ++++++++ src/plugins/projectexplorer/buildmanager.h | 1 + .../projectexplorer/projectexplorer.cpp | 22 ++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index c67c2a5893c..f8abc4c2234 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -76,6 +76,7 @@ public: int m_progress = 0; int m_maxProgress = 0; bool m_running = false; + bool m_isDeploying = false; // is set to true while canceling, so that nextBuildStep knows that the BuildStep finished because of canceling bool m_skipDisabled = false; bool m_canceling = false; @@ -180,6 +181,11 @@ bool BuildManager::isBuilding() return !d->m_buildQueue.isEmpty() || d->m_running; } +bool BuildManager::isDeploying() +{ + return d->m_isDeploying; +} + int BuildManager::getErrorTaskCount() { const int errors = @@ -243,6 +249,7 @@ void BuildManager::clearBuildQueue() d->m_buildQueue.clear(); d->m_enabledState.clear(); d->m_running = false; + d->m_isDeploying = false; d->m_previousBuildStepProject = nullptr; d->m_currentBuildStep = nullptr; @@ -452,6 +459,7 @@ void BuildManager::nextStep() d->m_currentBuildStep->run(); } else { d->m_running = false; + d->m_isDeploying = false; d->m_previousBuildStepProject = nullptr; d->m_progressFutureInterface->reportFinished(); d->m_progressWatcher.setFuture(QFuture()); @@ -532,6 +540,7 @@ bool BuildManager::buildLists(QList bsls, const QStringList &pr foreach (BuildStepList *list, bsls) { steps.append(list->steps()); stepListNames.append(ProjectExplorerPlugin::displayNameForStepId(list->id())); + d->m_isDeploying = d->m_isDeploying || list->id() == Constants::BUILDSTEPS_DEPLOY; } QStringList names; diff --git a/src/plugins/projectexplorer/buildmanager.h b/src/plugins/projectexplorer/buildmanager.h index fe452d6965e..ac63b2e6df5 100644 --- a/src/plugins/projectexplorer/buildmanager.h +++ b/src/plugins/projectexplorer/buildmanager.h @@ -49,6 +49,7 @@ public: static void extensionsInitialized(); static bool isBuilding(); + static bool isDeploying(); static bool tasksAvailable(); static bool buildLists(QList bsls, diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 2f029ccedda..03b19765c7a 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2368,6 +2368,7 @@ void ProjectExplorerPluginPrivate::buildQueueFinished(bool success) m_delayedRunConfiguration = nullptr; m_shouldHaveRunConfiguration = false; m_runMode = Constants::NO_RUN_MODE; + emit m_instance->updateRunActions(); } void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished() @@ -2857,9 +2858,10 @@ void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, QList stepIds; if (!forceSkipDeploy && dd->m_projectExplorerSettings.deployBeforeRun) { - if (dd->m_projectExplorerSettings.buildBeforeDeploy) + if (!BuildManager::isBuilding() && dd->m_projectExplorerSettings.buildBeforeDeploy) stepIds << Id(Constants::BUILDSTEPS_BUILD); - stepIds << Id(Constants::BUILDSTEPS_DEPLOY); + if (!BuildManager::isDeploying()) + stepIds << Id(Constants::BUILDSTEPS_DEPLOY); } Project *pro = rc->target()->project(); @@ -2868,7 +2870,9 @@ void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, if (queueCount < 0) // something went wrong return; - if (queueCount > 0) { + if (queueCount > 0 || BuildManager::isBuilding(rc->project())) { + QTC_ASSERT(dd->m_runMode == Constants::NO_RUN_MODE, return); + // delay running till after our queued steps were processed dd->m_runMode = runMode; dd->m_delayedRunConfiguration = rc; @@ -3083,9 +3087,9 @@ bool ProjectExplorerPlugin::canRunStartupProject(Core::Id runMode, QString *whyN return false; } - if (dd->m_projectExplorerSettings.buildBeforeDeploy && dd->m_projectExplorerSettings.deployBeforeRun + && !BuildManager::isBuilding(project) && hasBuildSettings(project)) { QPair buildState = dd->buildSettingsEnabled(project); if (!buildState.first) { @@ -3093,6 +3097,12 @@ bool ProjectExplorerPlugin::canRunStartupProject(Core::Id runMode, QString *whyN *whyNot = buildState.second; return false; } + + if (BuildManager::isBuilding()) { + if (whyNot) + *whyNot = tr("A build is still in progress."); + return false; + } } // shouldn't actually be shown to the user... @@ -3102,9 +3112,9 @@ bool ProjectExplorerPlugin::canRunStartupProject(Core::Id runMode, QString *whyN return false; } - if (BuildManager::isBuilding()) { + if (dd->m_delayedRunConfiguration && dd->m_delayedRunConfiguration->project() == project) { if (whyNot) - *whyNot = tr("A build is still in progress."); + *whyNot = tr("A run action is already scheduled for the active project."); return false; }