Own the download factory until commit

A malformed data uri threw before commit, and nothing deleted it.
This commit is contained in:
noctuum
2026-09-18 13:41:46 +05:00
committed by Jari Sundell
parent b857acd081
commit b34eb1e895
+5 -2
View File
@@ -195,14 +195,14 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li
return;
// Adding download.
DownloadFactory* f = new DownloadFactory(this);
auto f = std::make_unique<DownloadFactory>(this);
f->variables()["tied_to_file"] = (int64_t)(bool)(flags & create_tied);
f->commands().insert(f->commands().end(), commands.begin(), commands.end());
f->set_start(flags & create_start);
f->set_print_log(!(flags & create_quiet));
f->slot_finished([f]() { delete f; });
f->slot_finished([factory = f.get()]() { delete factory; });
if (is_data_uri(uri)) {
// Allow the use of data URIs, primarily for JSON-RPC which
@@ -216,6 +216,9 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li
}
f->commit();
// From here the finished slot deletes it.
f.release();
}
void