From b4cdf11f6af14c5b25a2a3323dd88ded9d85927e Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 20 Feb 2020 15:20:20 +0100 Subject: [PATCH] Remove titles from the GuiIconGrid which were removed from the GameList --- src/gui/GuiIconGrid.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/gui/GuiIconGrid.cpp b/src/gui/GuiIconGrid.cpp index bfcc482..1df15a7 100644 --- a/src/gui/GuiIconGrid.cpp +++ b/src/gui/GuiIconGrid.cpp @@ -75,6 +75,28 @@ uint64_t GuiIconGrid::getSelectedGame(void) { void GuiIconGrid::OnGameTitleListUpdated(GameList * gameList) { containerMutex.lock(); gameList->lock(); + // At first delete the ones that were deleted; + auto it = gameInfoContainers.begin(); + while (it != gameInfoContainers.end()) { + bool wasFound = false; + for(int32_t i = 0; i < gameList->size(); i++) { + gameInfo * info = gameList->at(i); + if(info != NULL && info->titleId == it->first) { + wasFound = true; + break; + } + } + + if (!wasFound) { + DEBUG_FUNCTION_LINE("Removing %016llX\n", it->first); + remove(it->second->button); + delete it->second; + it = gameInfoContainers.erase(it); + } else { + ++it; + } + } + for(int32_t i = 0; i < gameList->size(); i++) { gameInfo * info = gameList->at(i); GameInfoContainer * container = NULL;