From b2605206b17be0e1760d2dd945c0eb714547cb88 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 5 Oct 2017 17:39:54 +0200 Subject: [PATCH] Qt: fix gamegrid regression: mismatch between entry count and grid size --- rpcs3/rpcs3qt/game_list_frame.cpp | 46 +++++++++++++------------------ 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index e2af1e3d08..f3425b9f16 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -1043,20 +1043,19 @@ void game_list_frame::PopulateGameGrid(uint maxCols, const QSize& image_size, co m_xgrid = new game_list_grid(image_size, image_color, m_Margin_Factor, m_Text_Factor, showText); } - // Get number of things that'll be in grid and precompute grid size. - uint entries = 0; - for (const GUI_GameInfo& game : m_game_data) + // Get list of matching apps and their index + QList> matching_apps; + + for (uint i = 0; i < m_game_data.size(); i++) { - if (qstr(game.info.category) == category::disc_Game || qstr(game.info.category) == category::hdd_Game) + if (category::CategoryInMap(m_game_data[i].info.category, category::cat_boot) && SearchMatchesApp(m_game_data[i].info.name, m_game_data[i].info.serial)) { - if (SearchMatchesApp(game.info.name, game.info.serial) == false) - { - continue; - } - ++entries; + matching_apps.append(QPair(&m_game_data[i], i)); } } + int entries = matching_apps.count(); + // Edge cases! if (entries == 0) { // For whatever reason, 0%x is division by zero. Absolute nonsense by definition of modulus. But, I'll acquiesce. @@ -1076,28 +1075,21 @@ void game_list_frame::PopulateGameGrid(uint maxCols, const QSize& image_size, co m_xgrid->setRowCount(maxRows); m_xgrid->setColumnCount(maxCols); - for (uint i = 0; i < m_game_data.size(); i++) + for (const auto& app : matching_apps) { - if (SearchMatchesApp(m_game_data[i].info.name, m_game_data[i].info.serial) == false) + QString title = GUI::get_Single_Line(qstr(app.first->info.name)); + + m_xgrid->addItem(app.first->pxmap, title, app.second, r, c); + + if (selected_item == app.first->info.icon_path) { - continue; + m_xgrid->setCurrentItem(m_xgrid->item(r, c)); } - if (category::CategoryInMap(m_game_data[i].info.category, category::cat_boot)) + + if (++c >= maxCols) { - QString title = GUI::get_Single_Line(qstr(m_game_data[i].info.name)); - - m_xgrid->addItem(m_game_data[i].pxmap, title, i, r, c); - - if (selected_item == m_game_data[i].info.icon_path) - { - m_xgrid->setCurrentItem(m_xgrid->item(r, c)); - } - - if (++c >= maxCols) - { - c = 0; - r++; - } + c = 0; + r++; } }