Commit d38ca481 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Fix canceling of import command

We need to iterate over a copy of the jobs because canceling a job
removes it from d->jobs which invalidates iterators working directly
on d->jobs.

GnuPG-bug-id: 5805
parent db2bd79d
......@@ -846,13 +846,14 @@ void ImportCertificatesCommand::Private::importGroupsFromFile(const QString &fil
void ImportCertificatesCommand::doCancel()
std::for_each(std::cbegin(d->jobs), std::cend(d->jobs),
const auto jobsToCancel = d->jobs;
std::for_each(std::begin(jobsToCancel), std::end(jobsToCancel),
[this](const auto &job) {
std::for_each(std::cbegin(job.connections), std::cend(job.connections),
[this](const auto &connection) { QObject::disconnect(connection); });
d->importResult(ImportResult{Error::fromCode(GPG_ERR_CANCELED)}, job.job);
#undef d
Supports Markdown
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