qt: Prevent interacting with empty grid cells. (#2243)

This commit is contained in:
squidbus 2025-01-26 04:32:14 -08:00 committed by GitHub
parent 3960283a67
commit 461148c227
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View file

@ -38,17 +38,18 @@ GameGridFrame::GameGridFrame(std::shared_ptr<GameInfoClass> game_info_get,
void GameGridFrame::onCurrentCellChanged(int currentRow, int currentColumn, int previousRow,
int previousColumn) {
cellClicked = true;
crtRow = currentRow;
crtColumn = currentColumn;
columnCnt = this->columnCount();
auto itemID = (crtRow * columnCnt) + currentColumn;
if (itemID > m_game_info->m_games.count() - 1) {
cellClicked = false;
validCellSelected = false;
BackgroundMusicPlayer::getInstance().stopMusic();
return;
}
cellClicked = true;
validCellSelected = true;
SetGridBackgroundImage(crtRow, crtColumn);
auto snd0Path = QString::fromStdString(m_game_info->m_games[itemID].snd0_path.string());

View file

@ -41,8 +41,8 @@ public:
itemID = widget->currentRow() * widget->columnCount() + widget->currentColumn();
}
// Do not show the menu if an item is selected
if (itemID == -1) {
// Do not show the menu if no item is selected
if (itemID < 0 || itemID >= m_games.size()) {
return;
}