diff --git a/plugins/execute/nativeappjob.cpp b/plugins/execute/nativeappjob.cpp --- a/plugins/execute/nativeappjob.cpp +++ b/plugins/execute/nativeappjob.cpp @@ -19,6 +19,8 @@ #include "nativeappjob.h" +#include + #include #include @@ -133,14 +135,23 @@ void NativeAppJob::start() { - // we kill any execution of the configuration auto currentJobs = ICore::self()->runController()->currentJobs(); + std::set ignoreJobs{this}; 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(); + if (job && job->m_name == m_name && !ignoreJobs.count(job)) { + switch (QMessageBox::question(nullptr, i18n("Job already running"), i18n("'%1' is already being executed. Should we kill the previous instance?", m_name), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel)) { + case QMessageBox::Yes: // kill the running instance + if (ICore::self()->runController()->currentJobs().contains(*it)) { + (*it)->kill(); + } + break; + case QMessageBox::No: // simply start another job + ignoreJobs.emplace(job); + break; + default: // cancel starting a new job + kill(); + return; } currentJobs = ICore::self()->runController()->currentJobs(); it = currentJobs.begin();