solve DSI due to async update of usedSizeTxt after the menu was deleted

This commit is contained in:
w3irDv 2024-06-09 23:53:54 +02:00
parent 92a412ffd5
commit d507ba5ed1

View File

@ -40,6 +40,7 @@
#include "sys.h" #include "sys.h"
struct discHdr *dvdheader = NULL; struct discHdr *dvdheader = NULL;
bool allowUsedSpaceTxtUpdate;
GameBrowseMenu::GameBrowseMenu() GameBrowseMenu::GameBrowseMenu()
: GuiWindow(screenwidth, screenheight) : GuiWindow(screenwidth, screenheight)
@ -525,6 +526,7 @@ int GameBrowseMenu::Execute()
GameBrowseMenu * Menu = new GameBrowseMenu(); GameBrowseMenu * Menu = new GameBrowseMenu();
mainWindow->Append(Menu); mainWindow->Append(Menu);
allowUsedSpaceTxtUpdate = true;
if(Settings.ShowFreeSpace) if(Settings.ShowFreeSpace)
{ {
ThreadedTask::Instance()->AddCallback(&Menu->HDDSizeCallback); ThreadedTask::Instance()->AddCallback(&Menu->HDDSizeCallback);
@ -543,6 +545,8 @@ int GameBrowseMenu::Execute()
retMenu = Menu->MainLoop(); retMenu = Menu->MainLoop();
} }
// to avoid that the async thread updates usedSpaceText after menu deletion
allowUsedSpaceTxtUpdate = false;
delete Menu; delete Menu;
return retMenu; return retMenu;
@ -1689,10 +1693,13 @@ void GameBrowseMenu::UpdateCallback(void * e)
void GameBrowseMenu::SetFreeSpace(float freespace, float used) void GameBrowseMenu::SetFreeSpace(float freespace, float used)
{ {
if (strcmp(Settings.db_language, "JA") == 0) if (strcmp(Settings.db_language, "JA") == 0) {
usedSpaceTxt->SetText(fmt("%.2fGB %s %.2fGB %s", freespace + used, tr( "of" ), freespace, tr( "free" ))); if ( allowUsedSpaceTxtUpdate == true )
usedSpaceTxt->SetText(fmt("%.2fGB %s %.2fGB %s", freespace + used, tr( "of" ), freespace, tr( "free" )));
}
else else
usedSpaceTxt->SetText(fmt("%.2fGB %s %.2fGB %s", freespace, tr( "of" ), freespace + used, tr( "free" ))); if ( allowUsedSpaceTxtUpdate == true )
usedSpaceTxt->SetText(fmt("%.2fGB %s %.2fGB %s", freespace, tr( "of" ), freespace + used, tr( "free" )));
} }
void GameBrowseMenu::UpdateFreeSpace(void * arg) void GameBrowseMenu::UpdateFreeSpace(void * arg)
@ -1700,7 +1707,8 @@ void GameBrowseMenu::UpdateFreeSpace(void * arg)
if (Settings.ShowFreeSpace) if (Settings.ShowFreeSpace)
{ {
float freespace = 0.0, used = 0.0; float freespace = 0.0, used = 0.0;
usedSpaceTxt->SetVisible(true); if ( allowUsedSpaceTxtUpdate == true )
usedSpaceTxt->SetVisible(true);
int ret = WBFS_DiskSpace(&used, &freespace); int ret = WBFS_DiskSpace(&used, &freespace);
if (ret >= 0) if (ret >= 0)
SetFreeSpace(freespace, used); SetFreeSpace(freespace, used);