aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Brown <themagnificentmrb@gmail.com>2023-01-24 00:37:20 -0800
committerGarrett Brown <themagnificentmrb@gmail.com>2023-01-29 16:25:10 -0800
commitd993f796b3116b266a46532e783d45d4fbe25bec (patch)
tree29ee421c9677aef2521507f732eda65137d49ed1
parent559a347d59b7c004c3aa0c518bee93f130e9b83c (diff)
Game OSD: Improve error handling for invalid item index
-rw-r--r--xbmc/games/dialogs/osd/DialogGameVideoSelect.cpp13
-rw-r--r--xbmc/games/dialogs/osd/DialogGameVideoSelect.h2
-rw-r--r--xbmc/games/dialogs/osd/DialogInGameSaves.cpp6
-rw-r--r--xbmc/games/dialogs/osd/DialogInGameSaves.h2
4 files changed, 13 insertions, 10 deletions
diff --git a/xbmc/games/dialogs/osd/DialogGameVideoSelect.cpp b/xbmc/games/dialogs/osd/DialogGameVideoSelect.cpp
index 74cc14c1bc..8a23bd50c0 100644
--- a/xbmc/games/dialogs/osd/DialogGameVideoSelect.cpp
+++ b/xbmc/games/dialogs/osd/DialogGameVideoSelect.cpp
@@ -81,14 +81,13 @@ bool CDialogGameVideoSelect::OnMessage(CGUIMessage& message)
const int controlId = message.GetSenderId();
if (m_viewControl->HasControl(controlId))
{
- using namespace MESSAGING;
+ if (OnClickAction())
+ {
+ // Changed from sending ACTION_SHOW_OSD to closing the dialog
+ Close();
- OnClickAction();
-
- // Changed from sending ACTION_SHOW_OSD to closing the dialog
- Close();
-
- return true;
+ return true;
+ }
}
}
break;
diff --git a/xbmc/games/dialogs/osd/DialogGameVideoSelect.h b/xbmc/games/dialogs/osd/DialogGameVideoSelect.h
index 63e2bae4bd..d7d1ccaee2 100644
--- a/xbmc/games/dialogs/osd/DialogGameVideoSelect.h
+++ b/xbmc/games/dialogs/osd/DialogGameVideoSelect.h
@@ -52,7 +52,7 @@ protected:
virtual unsigned int GetFocusedItem() const = 0;
virtual void PostExit() = 0;
// override this to do something when an item is selected
- virtual void OnClickAction() {}
+ virtual bool OnClickAction() { return false; }
void OnDescriptionChange(const std::string& description);
diff --git a/xbmc/games/dialogs/osd/DialogInGameSaves.cpp b/xbmc/games/dialogs/osd/DialogInGameSaves.cpp
index 20a2395583..7383ec9b75 100644
--- a/xbmc/games/dialogs/osd/DialogInGameSaves.cpp
+++ b/xbmc/games/dialogs/osd/DialogInGameSaves.cpp
@@ -80,7 +80,7 @@ void CDialogInGameSaves::PostExit()
m_items.Clear();
}
-void CDialogInGameSaves::OnClickAction()
+bool CDialogInGameSaves::OnClickAction()
{
if (static_cast<int>(m_focusedItemIndex) < m_items.Size())
{
@@ -95,5 +95,9 @@ void CDialogInGameSaves::OnClickAction()
gameSettings->LoadSavestate(savePath);
gameSettings->CloseOSD();
+
+ return true;
}
+
+ return false;
}
diff --git a/xbmc/games/dialogs/osd/DialogInGameSaves.h b/xbmc/games/dialogs/osd/DialogInGameSaves.h
index e154883fbf..6eea69c000 100644
--- a/xbmc/games/dialogs/osd/DialogInGameSaves.h
+++ b/xbmc/games/dialogs/osd/DialogInGameSaves.h
@@ -29,7 +29,7 @@ protected:
void OnItemFocus(unsigned int index) override;
unsigned int GetFocusedItem() const override;
void PostExit() override;
- void OnClickAction() override;
+ bool OnClickAction() override;
private:
void InitSavedGames();