use stop token to manage object lifetime across async callbacks, such as download async

This commit is contained in:
ITotalJustice
2025-01-14 15:35:09 +00:00
parent 4e5e1a801b
commit 64a40ae672
7 changed files with 96 additions and 37 deletions

View File

@@ -647,6 +647,7 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
curl::Url{url},
curl::Path{path},
curl::Flags{curl::Flag_Cache},
curl::StopToken{this->GetToken()},
curl::OnComplete{[this, &image](auto& result) {
if (result.success) {
image.state = ImageDownloadState::Done;
@@ -733,6 +734,7 @@ void Menu::PackListDownload() {
curl::Url{packList_url},
curl::Path{packlist_path},
curl::Flags{curl::Flag_Cache},
curl::StopToken{this->GetToken()},
curl::OnComplete{[this, page_index](auto& result){
log_write("got themezer data\n");
if (!result.success) {