From b6ec55769c2488bc298250e72252d2b6f5a80d26 Mon Sep 17 00:00:00 2001 From: elecpower Date: Mon, 5 Apr 2021 23:28:13 +1000 Subject: [PATCH] Fix upd ref type so clears refs equal to the one selected for deletion --- companion/src/firmwares/modeldata.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/companion/src/firmwares/modeldata.cpp b/companion/src/firmwares/modeldata.cpp index 432a375f7..c90f90bd2 100644 --- a/companion/src/firmwares/modeldata.cpp +++ b/companion/src/firmwares/modeldata.cpp @@ -830,6 +830,7 @@ void ModelData::updateTypeIndexRef(R & curRef, const T type, const int idxAdj, c newRef.index = abs(curRef.index); div_t idx = div(newRef.index, updRefInfo.occurences); + div_t newidx; switch (updRefInfo.action) { @@ -847,9 +848,10 @@ void ModelData::updateTypeIndexRef(R & curRef, const T type, const int idxAdj, c if (idx.quot < (updRefInfo.index1 + idxAdj)) return; - newRef.index += updRefInfo.shift; + newRef.index = ((idx.quot + updRefInfo.shift) * updRefInfo.occurences) + idx.rem; + newidx = div(newRef.index, updRefInfo.occurences); - if (idx.quot < (updRefInfo.index1 + idxAdj) || idx.quot > (updRefInfo.maxindex + idxAdj)) { + if (newidx.quot < (updRefInfo.index1 + idxAdj) || newidx.quot > (updRefInfo.maxindex + idxAdj)) { if (defClear) newRef.clear(); else {