Commit a48287f4 authored by Christoph Roick's avatar Christoph Roick

Do not block "Run All Tests" by dialog

- always start a new test job without asking to kill running jobs
  * disable the combo box in the launch config interface

By default, app jobs are compared by their executable name. If a new job
name matches an old job, a dialog pops up to ask whether the old instance
shall be killed. This blocks the "Run All Tests" function under some
circumstances (for instance when "cmake" is used to invoke the test).
The patch always makes a CTest-generated job run without asking the user.

BUG: 377639
FIXED-IN: 5.6.1
parent ff1c26d4
Pipeline #38573 failed with stage
in 48 minutes and 22 seconds
......@@ -55,6 +55,7 @@ QString ExecutePlugin::userIdToRunEntry = QStringLiteral("User Id to Run");
QString ExecutePlugin::dependencyActionEntry = QStringLiteral("Dependency Action");
QString ExecutePlugin::projectTargetEntry = QStringLiteral("Project Target");
QString ExecutePlugin::killBeforeExecutingAgain = QStringLiteral("Kill Before Executing Again");
QString ExecutePlugin::configuredByCTest = QStringLiteral("ConfiguredByCTest");
using namespace KDevelop;
......
......@@ -53,6 +53,7 @@ class ExecutePlugin : public KDevelop::IPlugin, public IExecutePlugin
static QString dependencyActionEntry;
static QString projectTargetEntry;
static QString killBeforeExecutingAgain;
static QString configuredByCTest;
void unload() override;
......
......@@ -40,7 +40,6 @@
#include <QIcon>
#include <QMenu>
#include <QMessageBox>
#include <KConfigGroup>
#include <KLineEdit>
......@@ -96,7 +95,12 @@ void NativeAppConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelo
dependencyAction->setCurrentIndex( dependencyAction->findData( cfg.readEntry( ExecutePlugin::dependencyActionEntry, "Nothing" ) ) );
killBeforeStartingAgain->setCurrentIndex(killBeforeStartingAgain->findData( cfg.readEntry<int>( ExecutePlugin::killBeforeExecutingAgain, QMessageBox::Cancel ) ));
if (cfg.readEntry<bool>(ExecutePlugin::configuredByCTest, false)) {
killBeforeStartingAgain->setCurrentIndex(killBeforeStartingAgain->findData(NativeAppJob::startAnother));
killBeforeStartingAgain->setDisabled(true);
} else {
killBeforeStartingAgain->setCurrentIndex(killBeforeStartingAgain->findData(cfg.readEntry<int>(ExecutePlugin::killBeforeExecutingAgain, NativeAppJob::askIfRunning)));
}
}
NativeAppConfigPage::NativeAppConfigPage( QWidget* parent )
......@@ -109,9 +113,9 @@ NativeAppConfigPage::NativeAppConfigPage( QWidget* parent )
dependencyAction->setItemData(2, QStringLiteral("Install"));
dependencyAction->setItemData(3, QStringLiteral("SudoInstall"));
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Ask If Running"), QMessageBox::Cancel);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Kill All Instances"), QMessageBox::No);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Start Another"), QMessageBox::Yes);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Ask If Running"), NativeAppJob::askIfRunning);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Kill All Instances"), NativeAppJob::killAllInstances);
killBeforeStartingAgain->addItem(i18nc("@item:inlistbox", "Start Another"), NativeAppJob::startAnother);
//Set workingdirectory widget to ask for directories rather than files
workingDirectory->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
......
......@@ -53,7 +53,9 @@ NativeAppJob::NativeAppJob(QObject* parent, KDevelop::ILaunchConfiguration* cfg)
if (cfgGroup.readEntry(ExecutePlugin::isExecutableEntry, false)) {
m_name = cfgGroup.readEntry(ExecutePlugin::executableEntry, cfg->name()).section(QLatin1Char('/'), -1);
}
m_killBeforeExecutingAgain = cfgGroup.readEntry<int>(ExecutePlugin::killBeforeExecutingAgain, QMessageBox::Cancel);
if (!cfgGroup.readEntry<bool>(ExecutePlugin::configuredByCTest, false)) {
m_killBeforeExecutingAgain = cfgGroup.readEntry<int>(ExecutePlugin::killBeforeExecutingAgain, askIfRunning);
}
}
setCapabilities(Killable);
......@@ -147,29 +149,29 @@ void NativeAppJob::start()
}
if (!currentJobs.isEmpty()) {
int killAllInstances = m_killBeforeExecutingAgain;
if (killAllInstances == QMessageBox::Cancel) {
int oldJobAction = m_killBeforeExecutingAgain;
if (oldJobAction == askIfRunning) {
QMessageBox msgBox(QMessageBox::Question,
i18nc("@title:window", "Job Already Running"),
i18n("'%1' is already being executed.", m_name),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
msgBox.button(QMessageBox::No)->setText(i18nc("@action:button", "Kill All Instances"));
msgBox.button(QMessageBox::Yes)->setText(i18nc("@action:button", "Start Another"));
startAnother | killAllInstances | QMessageBox::Cancel /* aka askIfRunning */);
msgBox.button(killAllInstances)->setText(i18nc("@action:button", "Kill All Instances"));
msgBox.button(startAnother)->setText(i18nc("@action:button", "Start Another"));
msgBox.setDefaultButton(QMessageBox::Cancel);
QCheckBox* remember = new QCheckBox(i18nc("@option:check", "Remember choice"));
msgBox.setCheckBox(remember);
killAllInstances = msgBox.exec();
if (remember->isChecked() && killAllInstances != QMessageBox::Cancel) {
Q_EMIT killBeforeExecutingAgainChanged(killAllInstances);
oldJobAction = msgBox.exec();
if (remember->isChecked() && oldJobAction != QMessageBox::Cancel) {
Q_EMIT killBeforeExecutingAgainChanged(oldJobAction);
}
}
switch (killAllInstances) {
case QMessageBox::Yes: // simply start another job
switch (oldJobAction) {
case startAnother:
break;
case QMessageBox::No: // kill the running instance
case killAllInstances:
for (auto & job : currentJobs) {
if (job)
job->kill(EmitResult);
......
......@@ -22,6 +22,8 @@
#include <outputview/outputexecutejob.h>
#include <QMessageBox>
namespace KDevelop
{
class ILaunchConfiguration;
......@@ -36,11 +38,16 @@ public:
void start() override;
// Actions for what to do when a job is already running
static constexpr auto startAnother = QMessageBox::Yes;
static constexpr auto killAllInstances = QMessageBox::No;
static constexpr auto askIfRunning = QMessageBox::Cancel;
Q_SIGNALS:
void killBeforeExecutingAgainChanged(int killBeforeExecutingAgainChanged);
private:
QString m_name;
int m_killBeforeExecutingAgain = -1;
int m_killBeforeExecutingAgain = startAnother;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment