SettingsActivity: render non-string setting values as text (fixes "app threw an exception" on settings pages) - #302
Conversation
Since 62e1a09 the settings list passes the stored pref value through _row_value_text() straight into lv.label.set_text(). Prefs are JSON, so a value written as a number (an older app version, or a numeric ui_options value) arrives as an int and set_text raises "can't convert 'int' object to str implicitly", which the user sees as the "App threw an exception. It might be glitchy" dialog every time that settings page opens. Seen with ClipTV's buttons_per_screen on the Waveshare ESP32-S3-Touch-LCD-3.5. Stringify the (label-mapped) value in _row_value_text so any stored type renders. Defaults were already safe via the f-string. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Nice catch! And great that you added a test for this because clearly the current tests missed it! Question: is this an urgent fix for the conference? Or is it only showing up in ClipTV which can probably work around it until the next release...? |
|
Sorry for the slow reply — not urgent from our side. It's a regression since 62e1a09 that hits any app whose settings page lists a pref stored as a number; ClipTV's |
Problem
Since 62e1a09 (
settings: dont_persist rows with default_value show (defaults to X)) the settings list hands the stored pref value from_row_value_text()straight tolv.label.set_text(). Prefs are JSON, so a value that was written as a number, by an older app version or through numericui_optionsvalues, comes back as anint, andset_textraises:The user sees the "App threw an exception. It might be glitchy. Maybe there's an update that fixes it?" dialog every time that app's settings page opens. Reproduced with ClipTV's
buttons_per_screen(stored as6) on a Waveshare ESP32-S3-Touch-LCD-3.5 running current main.Fix
_row_value_text()now returnsstr(...)of the label-mapped value, so any stored type renders as text; the(defaults to X)paths were already safe through their f-strings. One line, plus four unit tests intests/test_settings_activity_label_mapping.py(int value, int value mapped to aui_optionslabel, int default, strings unchanged) and a changelog entry.Verification
tests/test_settings_activity_label_mapping.py: 27 tests pass on the desktop build.🤖 Generated with Claude Code
With thanks to the scientists and engineers who did the hard, unglamorous work that got us here.