Skip to content

Commit

Permalink
Cancel image downloads when store is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyschoen committed Dec 3, 2024
1 parent 5946e9d commit 72c5373
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/Dialogs/PatchStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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](){
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -843,6 +849,7 @@ struct PatchStore : public Component

~PatchStore()
{
DownloadPool::getInstance()->cancelImageDownloads();
waitForThreadToExit(-1);
}

Expand Down

0 comments on commit 72c5373

Please sign in to comment.