Skip to content

Commit

Permalink
GUI: prevent removal of running jobs
Browse files Browse the repository at this point in the history
Fixes #1220.
  • Loading branch information
mbunkus committed Jun 1, 2015
1 parent 531ef2d commit c826183
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2015-06-01 Moritz Bunkus <moritz@bunkus.org>

* MKVToolNix GUI: bug fix: running jobs cannot be removed from the
job queue anymore. Fixes #1220.

* MKVToolNix GUI: bug fix: when starting the GUI old jobs from the
queue were silently discarded if they included additional parts
(e.g. VOBs).
Expand Down
29 changes: 26 additions & 3 deletions src/mkvtoolnix-gui/jobs/tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,23 @@ Tool::onStart() {

void
Tool::onRemove() {
auto idsToRemove = QMap<uint64_t, bool>{};
auto idsToRemove = QMap<uint64_t, bool>{};
auto emitRunningWarning = false;

m_model->withSelectedJobs(ui->jobs, [&idsToRemove](Job &job) { idsToRemove[job.m_id] = true; });

m_model->removeJobsIf([&](Job const &job) { return idsToRemove[job.m_id]; });
m_model->removeJobsIf([&idsToRemove, &emitRunningWarning](Job const &job) -> bool {
if (!idsToRemove[job.m_id])
return false;
if (Job::Running != job.m_status)
return true;

emitRunningWarning = true;
return false;
});

if (emitRunningWarning)
MainWindow::get()->setStatusBarMessage(QY("Running jobs cannot be removed."));
}

void
Expand All @@ -149,7 +161,18 @@ Tool::onRemoveDoneOk() {

void
Tool::onRemoveAll() {
m_model->removeJobsIf([this](Job const &) { return true; });
auto emitRunningWarning = false;

m_model->removeJobsIf([&emitRunningWarning](Job const &job) -> bool {
if (Job::Running != job.m_status)
return true;

emitRunningWarning = true;
return false;
});

if (emitRunningWarning)
MainWindow::get()->setStatusBarMessage(QY("Running jobs cannot be removed."));
}

void
Expand Down

0 comments on commit c826183

Please sign in to comment.