From e134bbccd13b163bcf9514e4dbb315173c8ad2d4 Mon Sep 17 00:00:00 2001 From: Adrian <78108584+AdrianCassar@users.noreply.github.com> Date: Sun, 12 Jan 2025 14:37:18 +0000 Subject: [PATCH] [App] Fixed RunTitle crash via hotkey --- src/xenia/app/emulator_window.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/xenia/app/emulator_window.cc b/src/xenia/app/emulator_window.cc index cf4f3118d..075497bee 100644 --- a/src/xenia/app/emulator_window.cc +++ b/src/xenia/app/emulator_window.cc @@ -1662,11 +1662,16 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey( xe::threading::Sleep(delay); break; case ButtonFunctions::RunTitle: { - if (selected_title_index == -1) selected_title_index++; + if (selected_title_index == -1) { + selected_title_index++; + } - app_context().CallInUIThread([this]() { - RunTitle(recently_launched_titles_[selected_title_index].path_to_file); - }); + if (selected_title_index < recently_launched_titles_.size()) { + app_context().CallInUIThread([this]() { + RunTitle( + recently_launched_titles_[selected_title_index].path_to_file); + }); + } } break; case ButtonFunctions::ClearMemoryPageState: ToggleGPUSetting(gpu_cvar::ClearMemoryPageState); @@ -1759,8 +1764,9 @@ EmulatorWindow::ControllerHotKey EmulatorWindow::ProcessControllerHotkey( if ((button_combination.function == ButtonFunctions::IncTitleSelect || button_combination.function == ButtonFunctions::DecTitleSelect) && recently_launched_titles_.size() > 0) { - selected_title_index = std::clamp( - selected_title_index, 0, (int)recently_launched_titles_.size() - 1); + selected_title_index = + std::clamp(selected_title_index, 0, + static_cast(recently_launched_titles_.size() - 1)); // Must clear dialogs to prevent stacking ClearDialogs();