forked from qt-creator/qt-creator
ProjectExplorer: Add option to stop applications from the same build directory
Creator can stop running applications when a build starts. This prevents isssues on windows where the running application locks files in the build directory, which in turn will make the build fail. In addition to the current options to kill all applications or just those from the current project, add a new option to kill all applications of the current project that live in the same build directory. Task-number: QTCREATORBUG-16470 Change-Id: Ib4a74e2452055eaf5f9e384555be5ef14de1cd40 Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -1144,7 +1144,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
dd->m_projectExplorerSettings.environmentId = QUuid::createUuid();
|
||||
int tmp = s->value(QLatin1String("ProjectExplorer/Settings/StopBeforeBuild"),
|
||||
Utils::HostOsInfo::isWindowsHost() ? 1 : 0).toInt();
|
||||
if (tmp < 0 || tmp > ProjectExplorerSettings::StopAll)
|
||||
if (tmp < 0 || tmp > ProjectExplorerSettings::StopSameBuildDir)
|
||||
tmp = Utils::HostOsInfo::isWindowsHost() ? 1 : 0;
|
||||
dd->m_projectExplorerSettings.stopBeforeBuild = ProjectExplorerSettings::StopBeforeBuild(tmp);
|
||||
|
||||
@@ -2225,10 +2225,36 @@ int ProjectExplorerPluginPrivate::queue(QList<Project *> projects, QList<Id> ste
|
||||
|
||||
if (m_projectExplorerSettings.stopBeforeBuild != ProjectExplorerSettings::StopNone
|
||||
&& stepIds.contains(Constants::BUILDSTEPS_BUILD)) {
|
||||
bool stopAll = (m_projectExplorerSettings.stopBeforeBuild == ProjectExplorerSettings::StopAll);
|
||||
ProjectExplorerSettings::StopBeforeBuild stopCondition = m_projectExplorerSettings.stopBeforeBuild;
|
||||
const QList<RunControl *> toStop
|
||||
= Utils::filtered(m_outputPane->allRunControls(), [&projects, stopAll](RunControl *rc) {
|
||||
return rc->isRunning() && (stopAll || projects.contains(rc->project()));
|
||||
= Utils::filtered(m_outputPane->allRunControls(), [&projects, stopCondition](RunControl *rc) -> bool {
|
||||
if (!rc->isRunning())
|
||||
return false;
|
||||
|
||||
switch (stopCondition) {
|
||||
case ProjectExplorerSettings::StopNone:
|
||||
return false;
|
||||
case ProjectExplorerSettings::StopAll:
|
||||
return true;
|
||||
case ProjectExplorerSettings::StopSameProject:
|
||||
return projects.contains(rc->project());
|
||||
case ProjectExplorerSettings::StopSameBuildDir:
|
||||
return Utils::contains(projects, [rc](Project *p) {
|
||||
Target *t = p ? p->activeTarget() : nullptr;
|
||||
BuildConfiguration *bc = t ? t->activeBuildConfiguration() : nullptr;
|
||||
if (!bc)
|
||||
return false;
|
||||
if (!rc->runnable().is<StandardRunnable>())
|
||||
return false;
|
||||
if (!Utils::FileName::fromString(rc->runnable().as<StandardRunnable>().executable).isChildOf(bc->buildDirectory()))
|
||||
return false;
|
||||
IDevice::ConstPtr device = rc->runnable().as<StandardRunnable>().device;
|
||||
if (device.isNull())
|
||||
device = DeviceKitInformation::device(t->kit());
|
||||
return !device.isNull() && device->type() == Core::Id(Constants::DESKTOP_DEVICE_TYPE);
|
||||
});
|
||||
}
|
||||
return false; // Can't get here!
|
||||
});
|
||||
|
||||
if (!toStop.isEmpty()) {
|
||||
|
@@ -33,7 +33,7 @@ namespace Internal {
|
||||
class ProjectExplorerSettings
|
||||
{
|
||||
public:
|
||||
enum StopBeforeBuild { StopNone = 0, StopSameProject = 1, StopAll = 2 };
|
||||
enum StopBeforeBuild { StopNone = 0, StopSameProject, StopAll, StopSameBuildDir };
|
||||
|
||||
bool buildBeforeDeploy = true;
|
||||
bool deployBeforeRun = true;
|
||||
|
@@ -109,7 +109,7 @@ ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const
|
||||
m_settings.useJom = m_ui.jomCheckbox->isChecked();
|
||||
m_settings.prompToStopRunControl = m_ui.promptToStopRunControlCheckBox->isChecked();
|
||||
m_settings.maxAppOutputLines = m_ui.maxAppOutputBox->value();
|
||||
m_settings.stopBeforeBuild = ProjectExplorerSettings::StopBeforeBuild(m_ui.stopBeforeBuildComboBox->currentIndex());
|
||||
m_settings.stopBeforeBuild = static_cast<ProjectExplorerSettings::StopBeforeBuild>(m_ui.stopBeforeBuildComboBox->currentIndex());
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void ProjectExplorerSettingsWidget::setSettings(const ProjectExplorerSettings &
|
||||
m_ui.jomCheckbox->setChecked(m_settings.useJom);
|
||||
m_ui.promptToStopRunControlCheckBox->setChecked(m_settings.prompToStopRunControl);
|
||||
m_ui.maxAppOutputBox->setValue(m_settings.maxAppOutputLines);
|
||||
m_ui.stopBeforeBuildComboBox->setCurrentIndex(pes.stopBeforeBuild);
|
||||
m_ui.stopBeforeBuildComboBox->setCurrentIndex(static_cast<int>(pes.stopBeforeBuild));
|
||||
}
|
||||
|
||||
QString ProjectExplorerSettingsWidget::projectsDirectory() const
|
||||
|
@@ -202,6 +202,11 @@
|
||||
<string>All</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Same Build Directory</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
Reference in New Issue
Block a user