diff --git a/plugins/execute/nativeappjob.h b/plugins/execute/nativeappjob.h --- a/plugins/execute/nativeappjob.h +++ b/plugins/execute/nativeappjob.h @@ -41,7 +41,7 @@ void start() override; private: - QString m_cfgname; + QString m_name; }; #endif diff --git a/plugins/execute/nativeappjob.cpp b/plugins/execute/nativeappjob.cpp --- a/plugins/execute/nativeappjob.cpp +++ b/plugins/execute/nativeappjob.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -36,15 +37,21 @@ #include #include -#include "iexecuteplugin.h" +#include "executeplugin.h" #include "debug.h" using namespace KDevelop; NativeAppJob::NativeAppJob(QObject* parent, KDevelop::ILaunchConfiguration* cfg) : KDevelop::OutputExecuteJob( parent ) - , m_cfgname(cfg->name()) + , m_name(cfg->name()) { + { + auto cfgGroup = cfg->config(); + if (cfgGroup.readEntry(ExecutePlugin::isExecutableEntry, false)) { + m_name = cfgGroup.readEntry(ExecutePlugin::executableEntry, cfg->name()).section('/', -1); + } + } setCapabilities(Killable); IExecutePlugin* iface = KDevelop::ICore::self()->pluginController()->pluginForExtension(QStringLiteral("org.kdevelop.IExecutePlugin"), QStringLiteral("kdevexecute"))->extension(); @@ -112,7 +119,7 @@ *this << arguments; } - setJobName(cfg->name()); + setJobName(m_name); } NativeAppJob* findNativeJob(KJob* j) @@ -129,12 +136,18 @@ void NativeAppJob::start() { // we kill any execution of the configuration - foreach(KJob* j, ICore::self()->runController()->currentJobs()) { - NativeAppJob* job = findNativeJob(j); - if (job && job != this && job->m_cfgname == m_cfgname) { - QMessageBox::StandardButton button = QMessageBox::question(nullptr, i18n("Job already running"), i18n("'%1' is already being executed. Should we kill the previous instance?", m_cfgname)); - if (button != QMessageBox::No && ICore::self()->runController()->currentJobs().contains(j)) - j->kill(); + auto currentJobs = ICore::self()->runController()->currentJobs(); + for (auto it = currentJobs.begin(); it != currentJobs.end();) { + NativeAppJob* job = findNativeJob(*it); + if (job && job != this && job->m_name == m_name) { + QMessageBox::StandardButton button = QMessageBox::question(nullptr, i18n("Job already running"), i18n("'%1' is already being executed. Should we kill the previous instance?", m_name)); + if (button != QMessageBox::No && ICore::self()->runController()->currentJobs().contains(*it)) { + (*it)->kill(); + } + currentJobs = ICore::self()->runController()->currentJobs(); + it = currentJobs.begin(); + } else { + ++it; } } diff --git a/util/executecompositejob.cpp b/util/executecompositejob.cpp --- a/util/executecompositejob.cpp +++ b/util/executecompositejob.cpp @@ -106,16 +106,18 @@ emitPercent(ratio * 100, 100); qCDebug(UTIL) << "finished: "<< job << job->error() << "percent:" << ratio * 100; + bool emitDone = false; if (d->m_abortOnError && job->error()) { qCDebug(UTIL) << "JOB ERROR:" << job->error() << job->errorString(); - KCompositeJob::slotResult(job); + KCompositeJob::slotResult(job); // calls emitResult() + emitDone = true; } else removeSubjob(job); if (hasSubjobs() && !error() && !d->m_killing) { qCDebug(UTIL) << "remaining: " << subjobs().count() << subjobs(); d->startNextJob(subjobs().first()); - } else { + } else if (!emitDone) { setError(job->error()); setErrorText(job->errorString()); emitResult();