From 19708ce792e331b4dff9c11ec6e539244054b685 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Wed, 22 Jul 2026 09:46:24 +1000 Subject: [PATCH] fix(cpn): use JSON lookup for CFS (#7579) Co-authored-by: Claude Sonnet 5 --- companion/src/firmwares/rawsource.cpp | 4 ++-- companion/src/firmwares/rawswitch.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/companion/src/firmwares/rawsource.cpp b/companion/src/firmwares/rawsource.cpp index 3b6d087eb..552c5e3a0 100644 --- a/companion/src/firmwares/rawsource.cpp +++ b/companion/src/firmwares/rawsource.cpp @@ -241,7 +241,7 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con dfltName = Boards::getSwitchInfo(index - 1, board).name.c_str(); if (Boards::isSwitchFunc(index - 1, board)) { if (model) { - int fsindex = Boards::getSwitchTagNum(index - 1, board) - 1; + int fsindex = Boards::getCFSIndexForSwitch(index - 1, board); if (fsindex >= 0 && fsindex < CPN_MAX_SWITCHES_FUNCTION) custName = QString(model->customSwitches[fsindex].name).trimmed(); } @@ -375,7 +375,7 @@ bool RawSource::isAvailable(const ModelData * const model, return false; if (type == SOURCE_TYPE_SWITCH && b.isSwitchFunc(abs(index) - 1, board) && - !model->isFunctionSwitchSourceAllowed(b.getSwitchTagNum(abs(index) - 1, board) - 1)) + !model->isFunctionSwitchSourceAllowed(b.getCFSIndexForSwitch(abs(index) - 1, board))) return false; if (type == SOURCE_TYPE_VIRTUAL_INPUT && !model->isInputValid(abs(index) - 1)) diff --git a/companion/src/firmwares/rawswitch.cpp b/companion/src/firmwares/rawswitch.cpp index 57d486cf9..f06abef36 100644 --- a/companion/src/firmwares/rawswitch.cpp +++ b/companion/src/firmwares/rawswitch.cpp @@ -91,8 +91,9 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen swName = Boards::getSwitchInfo(qr.quot, board).name.c_str(); if (Boards::isSwitchFunc(qr.quot, board)) { if (modelData) { - int fsindex = Boards::getSwitchTagNum(qr.quot, board) - 1; - custName = QString(modelData->customSwitches[fsindex].name).trimmed(); + int fsindex = Boards::getCFSIndexForSwitch(qr.quot, board); + if (fsindex >= 0 && fsindex < CPN_MAX_SWITCHES_FUNCTION) + custName = QString(modelData->customSwitches[fsindex].name).trimmed(); } } else {