From 628f7b2b0cb6d7f1177bae3f2846047dae9b510c Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Wed, 7 Oct 2026 20:53:16 +0200 Subject: [PATCH] Fixes --- Modules/lvgl-module/source/insets_math.cpp | 5 ++++- Tactility/Source/settings/AppearanceSettings.cpp | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Modules/lvgl-module/source/insets_math.cpp b/Modules/lvgl-module/source/insets_math.cpp index a72092e99..14fcb2e7c 100644 --- a/Modules/lvgl-module/source/insets_math.cpp +++ b/Modules/lvgl-module/source/insets_math.cpp @@ -3,10 +3,13 @@ #include #include +#include + +constexpr double INV_SQRT2 = 1.0 / std::numbers::sqrt2; // The part of a corner's square that a circle with the given radius cuts off along its diagonal static int32_t corner_inset(int32_t radius) { - return static_cast(std::ceil(radius * (1.0 - M_SQRT1_2))); + return static_cast(std::ceil(radius * (1.0 - INV_SQRT2))); } // The horizontal distance between a circle's edge and its bounding box at the given distance from the circle's center row diff --git a/Tactility/Source/settings/AppearanceSettings.cpp b/Tactility/Source/settings/AppearanceSettings.cpp index a35d69f9e..0f751a275 100644 --- a/Tactility/Source/settings/AppearanceSettings.cpp +++ b/Tactility/Source/settings/AppearanceSettings.cpp @@ -5,6 +5,7 @@ #include +#include #include #include #include @@ -27,7 +28,14 @@ static std::optional parseColor(const std::mapsecond.empty()) { return std::nullopt; } - return static_cast(std::strtoul(entry->second.c_str(), nullptr, 16)) & 0xFFFFFF; + // An invalid value (e.g. from a hand-edited file) counts as unset, rather than as black + const std::string& text = entry->second; + uint32_t color = 0; + const auto [end, error] = std::from_chars(text.data(), text.data() + text.size(), color, 16); + if (error != std::errc {} || end != text.data() + text.size() || color > 0xFFFFFF) { + return std::nullopt; + } + return color; } // Saving only updates the keys that are written, so an unset colour is written as an empty value