diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-06-14 20:48:24 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-06-14 20:48:24 +0200 |
| commit | 60e10327715e420f652ed148e72e22ce8ded55a3 (patch) | |
| tree | 8ab3722ac19e31d61e85e7134ebfe4232b1bc540 /src/common | |
| parent | 10713532917591445080bee19159447b683b548a (diff) | |
[qt] fix various crashes due to invalid/corrupted/outdated settings (#4070)
lots of "out of index" errors :)
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4070
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/settings.h | 8 | ||||
| -rw-r--r-- | src/common/settings_enums.h | 4 | ||||
| -rw-r--r-- | src/common/settings_setting.h | 23 |
3 files changed, 26 insertions, 9 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index 3e14a40a09..be9c080bc6 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -336,7 +336,7 @@ struct Values { RendererBackend::Vulkan, #endif "backend", Category::Renderer}; - SwitchableSetting<int> vulkan_device{linkage, 0, "vulkan_device", Category::Renderer, Specialization::RuntimeList}; + SwitchableSetting<u32> vulkan_device{linkage, 0, "vulkan_device", Category::Renderer, Specialization::RuntimeList}; // Graphics Settings ResolutionScalingInfo resolution_info{}; @@ -661,8 +661,8 @@ struct Values { false, true, &custom_rtc_enabled}; SwitchableSetting<s64, true> custom_rtc_offset{linkage, 0, - (std::numeric_limits<int>::min)(), - (std::numeric_limits<int>::max)(), + (std::numeric_limits<s64>::min)(), + (std::numeric_limits<s64>::max)(), "custom_rtc_offset", Category::System, Specialization::Countable, @@ -751,7 +751,7 @@ struct Values { Setting<std::string> touch_device{linkage, "min_x:100,min_y:50,max_x:1800,max_y:850", "touch_device", Category::Controls}; - Setting<int> touch_from_button_map_index{linkage, 0, "touch_from_button_map", + Setting<u32> touch_from_button_map_index{linkage, 0, "touch_from_button_map", Category::Controls}; std::vector<TouchFromButtonMap> touch_from_button_maps; diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index da142e8e1c..a71cf2141c 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -145,8 +145,8 @@ ENUM(ConfirmStop, Ask_Always, Ask_Based_On_Game, Ask_Never); ENUM(FullscreenMode, Borderless, Exclusive); ENUM(NvdecEmulation, Off, Cpu, Gpu); ENUM(ResolutionSetup, Res1_4X, Res1_2X, Res3_4X, Res1X, Res5_4X, Res3_2X, Res2X, Res3X, Res4X, Res5X, Res6X, Res7X, Res8X); -ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, Lanczos, ScaleForce, Fsr, Area, ZeroTangent, BSpline, Mitchell, Spline1, Mmpx, Sgsr, SgsrEdge, MaxEnum); -ENUM(AntiAliasing, None, Fxaa, Smaa, MaxEnum); +ENUM(ScalingFilter, NearestNeighbor, Bilinear, Bicubic, Gaussian, Lanczos, ScaleForce, Fsr, Area, ZeroTangent, BSpline, Mitchell, Spline1, Mmpx, Sgsr, SgsrEdge); +ENUM(AntiAliasing, None, Fxaa, Smaa); ENUM(AspectRatio, R16_9, R4_3, R21_9, R16_10, Stretch); ENUM(ConsoleMode, Handheld, Docked); ENUM(AppletMode, HLE, LLE); diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 076aceef29..9b6ec76d62 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -11,6 +11,7 @@ #include <optional> #include <stdexcept> #include <string> +#include <type_traits> #include <typeindex> #include <typeinfo> #include <fmt/core.h> @@ -101,7 +102,15 @@ public: * @param val The desired value */ virtual void SetValue(const Type& val) { - Type temp{ranged ? std::clamp(val, minimum, maximum) : val}; + // Enums have a maximal range which they're allowed + Type temp{}; + if constexpr (std::is_enum_v<Type>) { + auto const r_min = std::underlying_type_t<Type>(0); + auto const r_max = std::underlying_type_t<Type>(EnumMetadata<Type>::GetLast()); + temp = Type(std::clamp(std::underlying_type_t<Type>(val), r_min, r_max)); + } else { + temp = ranged ? std::clamp(val, this->minimum, this->maximum) : val; + } std::swap(value, temp); } @@ -129,7 +138,7 @@ protected: } else if constexpr (std::is_floating_point_v<Type>) { return fmt::format("{:f}", value_); } else if constexpr (std::is_enum_v<Type>) { - return std::to_string(u32(value_)); + return std::to_string(std::underlying_type_t<Type>(value_)); } else { return std::to_string(value_); } @@ -371,7 +380,15 @@ public: * @param val The new value */ void SetValue(const Type& val) override final { - Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; + // Enums have a maximal range which they're allowed + Type temp{}; + if constexpr (std::is_enum_v<Type>) { + auto const r_min = std::underlying_type_t<Type>(0); + auto const r_max = std::underlying_type_t<Type>(EnumMetadata<Type>::GetLast()); + temp = Type(std::clamp(std::underlying_type_t<Type>(val), r_min, r_max)); + } else { + temp = ranged ? std::clamp(val, this->minimum, this->maximum) : val; + } if (use_global) { std::swap(this->value, temp); } else { |
