Skip to content

fix(color): modifying model labels may corrupt model yaml files - #7709

Merged
pfeerick merged 4 commits into
mainfrom
philmoz/fix-label-management
Aug 26, 2026
Merged

fix(color): modifying model labels may corrupt model yaml files#7709
pfeerick merged 4 commits into
mainfrom
philmoz/fix-label-management

Conversation

@philmoz

@philmoz philmoz commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

The change to make the model screens and widget data dynamic missed the fact that changing model labels causes reading and writing of model YAML files other than the currently loaded model.

Introduced in #6782

This is handled by dynamically allocating a ModelData buffer to read into and write from.
However the model screen and widget data no longer lives in the ModelData structure; but in global variables.

When reading other model files to update the labels, this would overwrite the screen and widget data for the currently active model. This data could then be written back to the active model file overwriting the correct settings.

It is currently not possible to store the screen and widget data in the ModelData structure as the system that generates the firmware YAML parser can only handle simple data types.

To avoid creating and managing even more temporary buffers this PR changes the logic for updating labels.

Changes:

  • when reading labels from a model file, only the header section (PartialModel) is loaded into a temporary buffer.
  • when a model (other than the active model) needs label changes the code reads the header from the model file into a PartialModel structure, updates the labels and then creates a temporary yaml file with this new header. It then reads the original model yaml file, skips the old header and block copies the rest of the original file to the temporary file. Once done the original is deleted and the temporary file is renamed.

This removes the need for dynamically allocated ModelData buffers (the PartialModel buffers are very small and live on the stack).
It reduces the overhead by not reading the entire model yaml just to get the labels from the header section.
It no longer touches any of the active model data structures.

@philmoz philmoz added this to the 3.0 milestone Aug 26, 2026
@philmoz philmoz added bug 🪲 Something isn't working color Related generally to color LCD radios firmware (fw) General radio firmware issue, not colorlcd or B&W specific backport/2.12 To be backported to a 2.12 release also. labels Aug 26, 2026
@pfeerick pfeerick added bug/regression ↩️ A new version of EdgeTX broke something and removed bug 🪲 Something isn't working labels Aug 26, 2026
Comment thread radio/src/storage/modelslist.cpp Outdated
philmoz and others added 3 commits August 26, 2026 19:01
Covers the moduleData/header YAML node layout introduced for
PartialModel, cross-checks PartialModel and ModelData parse the same
header YAML identically, and locks in the header.labels CSV-capacity
contract that LABELS_LENGTH-1 (not LABEL_LENGTH-1) is meant to
guarantee.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
header.labels only exists on color targets that define
STORAGE_MODELSLIST; guard the label-related assertions accordingly.
Didn't check black & white targets before the previous push, which
broke CI across the board.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@pfeerick pfeerick modified the milestones: 3.0, 2.12.3 Aug 26, 2026
@pfeerick
pfeerick merged commit 35662d0 into main Aug 26, 2026
50 checks passed
@pfeerick
pfeerick deleted the philmoz/fix-label-management branch August 26, 2026 09:39
pfeerick added a commit that referenced this pull request Aug 26, 2026
Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 35662d0)
pfeerick added a commit that referenced this pull request Aug 26, 2026
- Move clearUserData() out of the #if COLORLCD guard in
  applyDefaultTemplate() - the userData feature and Lua API are not
  COLORLCD-only, so B&W radios were never getting a clean model reset.
- Fix getAllUserData(app)'s arg-count check: >= 2 meant the documented
  one-argument form silently returned every entry instead of filtering
  by app.

The cross-model corruption fix (guarding the userdata YAML callbacks
and clearUserData() on the buffer being &g_model) that was here
earlier is no longer needed: PR #7709 removed the only call sites that
read a full ModelData buffer for a model other than g_model
(storage/modelslist.cpp's label scans now use the header-only
PartialModel, which has no userData node), so the corruption path is
now structurally unreachable.
pfeerick added a commit that referenced this pull request Aug 28, 2026
Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 35662d0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. bug/regression ↩️ A new version of EdgeTX broke something color Related generally to color LCD radios firmware (fw) General radio firmware issue, not colorlcd or B&W specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants