From 4d2f1aea3e1e4d36360268f6606c6a0f6d404c74 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 22 Feb 2020 22:50:56 +0100 Subject: [PATCH] Use existing free slots before adding them to the back --- src/gui/GuiIconGrid.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/GuiIconGrid.cpp b/src/gui/GuiIconGrid.cpp index ff3fd3b..9e35cf7 100644 --- a/src/gui/GuiIconGrid.cpp +++ b/src/gui/GuiIconGrid.cpp @@ -476,7 +476,17 @@ void GuiIconGrid::OnGameTitleAdded(gameInfo * info) { this->append(button); positionMutex.lock(); + bool foundFreePlace = false; + for(uint32_t i = 0; i < position.size(); i++) { + if(position[i] == 0) { + position[i] = info->titleId; + foundFreePlace = true; + break; + } + } + if(!foundFreePlace) { position.push_back(info->titleId); + } positionMutex.unlock(); bUpdatePositions = true;