From 9af38c3309d959baa4499bdeed18cff6ce92ad50 Mon Sep 17 00:00:00 2001 From: Jonah Date: Sun, 31 Mar 2024 12:24:08 -0600 Subject: [PATCH] - Removed unnecessary std::future from game_grid_frame(populate/resize) Thanks SachinVin! --- src/qt_gui/game_grid_frame.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/qt_gui/game_grid_frame.cpp b/src/qt_gui/game_grid_frame.cpp index bb464031..0b57a162 100644 --- a/src/qt_gui/game_grid_frame.cpp +++ b/src/qt_gui/game_grid_frame.cpp @@ -54,22 +54,7 @@ void GameGridFrame::PopulateGameGrid(QVector m_games_search, bool from if (m_games_.size() % gamesPerRow != 0) { rowCount += 1; // Add an extra row for the remainder } - std::vector indices; - for (int i = 0; i < m_games_.size(); i++) { - indices.push_back(i); - } - std::vector> futures; - for (int index : indices) { - futures.push_back(std::async(std::launch::async, [=, this]() { - return m_games_[index].icon.scaled(QSize(icon_size, icon_size), Qt::IgnoreAspectRatio, - Qt::SmoothTransformation); - })); - } - std::vector scaledPixmaps; - for (auto& future : futures) { - scaledPixmaps.push_back(future.get()); - } int column = 0; this->setColumnCount(gamesPerRow); this->setRowCount(rowCount); @@ -77,9 +62,10 @@ void GameGridFrame::PopulateGameGrid(QVector m_games_search, bool from QWidget* widget = new QWidget(); QVBoxLayout* layout = new QVBoxLayout(); QLabel* image_label = new QLabel(); - image_label->setFixedSize(scaledPixmaps[gameCounter].width(), - scaledPixmaps[gameCounter].height()); - image_label->setPixmap(scaledPixmaps[gameCounter]); + QPixmap icon = m_games_[gameCounter].icon.scaled( + QSize(icon_size, icon_size), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + image_label->setFixedSize(icon.width(), icon.height()); + image_label->setPixmap(icon); QLabel* name_label = new QLabel(QString::fromStdString(m_games_[gameCounter].serial)); name_label->setAlignment(Qt::AlignHCenter); layout->addWidget(image_label);