From 9411e40c20536697198a58e05ba0072c169a06c0 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 23 Mar 2025 16:43:57 +1000 Subject: [PATCH] FullscreenUI: Fix assert when booting+loading state --- src/core/fullscreen_ui.cpp | 58 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 0e2752f87..beef150a5 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -5033,10 +5033,9 @@ void FullscreenUI::DrawGraphicsSettingsPage() if (is_hardware) { - DrawIntListSetting( - bsi, FSUI_ICONSTR(ICON_FA_EXPAND_ALT, "Internal Resolution"), - FSUI_CSTR("Upscales the game's rendering by the specified multiplier."), - "GPU", "ResolutionScale", 1, resolution_scales); + DrawIntListSetting(bsi, FSUI_ICONSTR(ICON_FA_EXPAND_ALT, "Internal Resolution"), + FSUI_CSTR("Upscales the game's rendering by the specified multiplier."), "GPU", + "ResolutionScale", 1, resolution_scales); DrawEnumSetting(bsi, FSUI_ICONSTR(ICON_FA_COMPRESS_ALT, "Downsampling"), FSUI_CSTR("Downsamples the rendered image prior to displaying it. Can improve " @@ -7339,34 +7338,37 @@ void FullscreenUI::DoLoadState(std::string path) std::string boot_path = std::move(s_state.save_state_selector_game_path); CloseSaveStateSelector(); - Host::RunOnCPUThread([boot_path = std::move(boot_path), path = std::move(path)]() mutable { - if (System::IsValid()) - { - if (path.empty()) + if (GPUThread::HasGPUBackend()) + { + Host::RunOnCPUThread([boot_path = std::move(boot_path), path = std::move(path)]() mutable { + if (System::IsValid()) { - // Loading undo state. - if (!System::UndoLoadState()) + if (path.empty()) { - GPUThread::RunOnThread( - []() { ShowToast(std::string(), TRANSLATE_STR("System", "Failed to undo load state.")); }); + // Loading undo state. + if (!System::UndoLoadState()) + { + GPUThread::RunOnThread( + []() { ShowToast(std::string(), TRANSLATE_STR("System", "Failed to undo load state.")); }); + } + } + else + { + Error error; + if (!System::LoadState(path.c_str(), &error, true, false)) + { + GPUThread::RunOnThread([error_desc = error.TakeDescription()]() { + ShowToast(std::string(), fmt::format(TRANSLATE_FS("System", "Failed to load state: {}"), error_desc)); + }); + } } } - else - { - Error error; - if (!System::LoadState(path.c_str(), &error, true, false)) - { - GPUThread::RunOnThread([error_desc = error.TakeDescription()]() { - ShowToast(std::string(), fmt::format(TRANSLATE_FS("System", "Failed to load state: {}"), error_desc)); - }); - } - } - } - else - { - DoStartPath(std::move(boot_path), std::move(path)); - } - }); + }); + } + else + { + DoStartPath(std::move(boot_path), std::move(path)); + } } void FullscreenUI::DoSaveState(s32 slot, bool global)