diff --git a/src/duckstation-qt/gamesummarywidget.cpp b/src/duckstation-qt/gamesummarywidget.cpp index 063d8de71..549f06112 100644 --- a/src/duckstation-qt/gamesummarywidget.cpp +++ b/src/duckstation-qt/gamesummarywidget.cpp @@ -403,6 +403,7 @@ void GameSummaryWidget::onComputeHashClicked() } QtModalProgressCallback progress_callback(this); + progress_callback.SetCancellable(true); progress_callback.SetProgressRange(image->GetTrackCount()); std::vector track_hashes; @@ -419,6 +420,10 @@ void GameSummaryWidget::onComputeHashClicked() if (!CDImageHasher::GetTrackHash(image.get(), track, &hash, &progress_callback)) { progress_callback.PopState(); + + if (progress_callback.IsCancelled()) + return; + calculate_hash_success = false; break; } diff --git a/src/util/cd_image_hasher.cpp b/src/util/cd_image_hasher.cpp index e3f641859..3d9a6544e 100644 --- a/src/util/cd_image_hasher.cpp +++ b/src/util/cd_image_hasher.cpp @@ -40,6 +40,9 @@ bool CDImageHasher::ReadIndex(CDImage* image, u8 track, u8 index, MD5Digest* dig if ((lba % update_interval) == 0) progress_callback->SetProgressValue(lba); + if (progress_callback->IsCancelled()) + return false; + if (!image->ReadRawSector(sector.data(), nullptr)) { progress_callback->FormatModalError("Failed to read sector {} from image", image->GetPositionOnDisc()); @@ -112,6 +115,7 @@ bool CDImageHasher::GetImageHash(CDImage* image, Hash* out_hash, { MD5Digest digest; + progress_callback->SetCancellable(true); progress_callback->SetProgressRange(image->GetTrackCount()); progress_callback->SetProgressValue(0); progress_callback->PushState();