Skip to content

Commit

Permalink
Add more safety checks
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenAlex committed Feb 25, 2025
1 parent 8578bcb commit 0094180
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/UI/ViewControllers/DownloadHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,13 @@ void ViewControllers::DownloadHistoryViewController::ProcessDownloads(bool force
currentEntry->lastUpdate = now;

currentEntry->downloadProgress = downloadProgress;
if (currentEntry->UpdateProgressHandler != nullptr) {
BSML::MainThreadScheduler::Schedule([currentEntry] {

BSML::MainThreadScheduler::Schedule([currentEntry] {
if (currentEntry->UpdateProgressHandler != nullptr) {
currentEntry->UpdateProgressHandler();
});
}
}
});

DEBUG("DownloadProgress: {}", downloadProgress);
};
DEBUG("Hash {}", currentEntry->hash);
Expand Down
3 changes: 3 additions & 0 deletions src/UI/ViewControllers/DownloadHistoryCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ namespace BetterSongSearch::UI::ViewControllers {
}

void CustomDownloadListTableCell::WasPreparedForReuse() {
if (!entry) {
return;
}
entry->UpdateProgressHandler = nullptr;
}
} // namespace BetterSongSearch::UI::ViewControllers
2 changes: 1 addition & 1 deletion src/UI/ViewControllers/SongList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void ViewControllers::SongListController::SelectSong(UnityW<HMUI::TableView> tab
return;
}
DEBUG("Cell clicked {}", id);
if (dataHolder.displayedSongList.size() <= id) {
if (dataHolder.displayedSongList.size() <= id || id < 0) {
// Return if the id is invalid
return;
}
Expand Down

0 comments on commit 0094180

Please sign in to comment.