fix: Fixed memory leak

Signed-off-by: timoreo <contact@timoreo.fr>
This commit is contained in:
timoreo 2022-09-26 11:50:55 +02:00
parent 9ff364b0d3
commit dd6f670dec
No known key found for this signature in database
GPG Key ID: 121A72C3512BA288

View File

@ -238,11 +238,12 @@ bool ModrinthCreationTask::createInstance()
if (!file.downloads.empty()) {
// FIXME: This really needs to be put into a ConcurrentTask of
// MultipleOptionsTask's , once those exist :)
connect(dl.get(), &NetAction::failed, [this, &file, path, dl] {
auto dl = Net::Download::makeFile(file.downloads.dequeue(), path);
dl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
m_files_job->addNetAction(dl);
dl->succeeded();
auto param = dl.toWeakRef();
connect(dl.get(), &NetAction::failed, [this, &file, path, param] {
auto ndl = Net::Download::makeFile(file.downloads.dequeue(), path);
ndl->addValidator(new Net::ChecksumValidator(file.hashAlgorithm, file.hash));
m_files_job->addNetAction(ndl);
if (auto shared = param.lock()) shared->succeeded();
});
}
}