From 72c5373279d4018eebb543ba437855e93ae50854 Mon Sep 17 00:00:00 2001 From: Timothy Schoen Date: Tue, 3 Dec 2024 13:47:44 +0100 Subject: [PATCH] Cancel image downloads when store is closed --- Source/Dialogs/PatchStore.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Dialogs/PatchStore.h b/Source/Dialogs/PatchStore.h index 348b6db40..55be89061 100644 --- a/Source/Dialogs/PatchStore.h +++ b/Source/Dialogs/PatchStore.h @@ -28,6 +28,11 @@ class DownloadPool : public DeletedAtShutdown listeners.erase(listener); } + void cancelImageDownloads() + { + imagePool.removeAllJobs(true, 500); + } + void downloadImage(hash32 hash, URL location) { imagePool.addJob([this, hash, location](){ @@ -815,6 +820,7 @@ struct PatchStore : public Component refreshButton.setEnabled(false); addAndMakeVisible(refreshButton); refreshButton.onClick = [this]() { + DownloadPool::getInstance()->cancelImageDownloads(); spinner.startSpinning(); startThread(); refreshButton.setEnabled(false); @@ -843,6 +849,7 @@ struct PatchStore : public Component ~PatchStore() { + DownloadPool::getInstance()->cancelImageDownloads(); waitForThreadToExit(-1); }