From 12d8d1118fd49abe9ede5fa398585ca4623d3477 Mon Sep 17 00:00:00 2001 From: elecpower Date: Tue, 22 Sep 2020 22:56:14 +1000 Subject: [PATCH] Inputs signal changes and LS try to solve timing crash --- companion/src/modeledit/inputs.cpp | 18 ++++++-- companion/src/modeledit/logicalswitches.cpp | 51 ++++++++++----------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index a79a3d28f..53b016610 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -197,9 +197,9 @@ void InputsPanel::gm_openExpo(int index) model->expoData[index] = ed; if (firmware->getCapability(VirtualInputs)) strncpy(model->inputNames[ed.chn], inputName.toLatin1().data(), INPUT_NAME_LEN); + update(); emit updateDataModels(); emit modified(); - update(); } else { if (expoInserted) { @@ -252,8 +252,9 @@ void InputsPanel::exposDelete(bool prompt) } exposDeleteList(list, prompt); - emit modified(); update(); + emit updateDataModels(); + emit modified(); } void InputsPanel::exposCut() @@ -326,8 +327,9 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx) i += sizeof(ExpoData); } - emit modified(); update(); + emit updateDataModels(); + emit modified(); } } @@ -494,8 +496,9 @@ void InputsPanel::moveExpoList(bool down) } } if (mod) { - emit modified(); update(); + emit updateDataModels(); + emit modified(); } setSelectedByExpoList(highlightList); } @@ -533,8 +536,9 @@ void InputsPanel::clearExpos() for (int i = 0; i < inputsCount; i++) { model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, i); } - emit modified(); update(); + emit updateDataModels(); + emit modified(); } } @@ -582,6 +586,7 @@ void InputsPanel::cmInputClear() } model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, inputIdx); update(); + emit updateDataModels(); emit modified(); } @@ -605,6 +610,7 @@ void InputsPanel::cmInputDelete() model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SHIFT, inputIdx, 0, -1); update(); + emit updateDataModels(); emit modified(); } @@ -623,6 +629,7 @@ void InputsPanel::cmInputInsert() model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SHIFT, inputIdx, 0, 1); update(); + emit updateDataModels(); emit modified(); } @@ -684,6 +691,7 @@ void InputsPanel::cmInputSwapData(int idx1, int idx2) model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_SWAP, idx1, idx2); update(); + emit updateDataModels(); emit modified(); } diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 8c5fe63d1..d3111a1ed 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -169,36 +169,33 @@ LogicalSwitchesPanel::~LogicalSwitchesPanel() void LogicalSwitchesPanel::onFunctionChanged() { - int i = sender()->property("index").toInt(); - unsigned newFunc = cbFunction[i]->currentData().toUInt(); + if (!lock) { + int i = sender()->property("index").toInt(); + unsigned newFunc = cbFunction[i]->currentData().toUInt(); - if (model->logicalSw[i].func == newFunc) - return; + if (model->logicalSw[i].func == newFunc) + return; - const unsigned oldFunc = model->logicalSw[i].func; - CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily(); - model->logicalSw[i].func = newFunc; - CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily(); - - if (oldFuncFamily != newFuncFamily) { - model->logicalSw[i].clear(); + const unsigned oldFunc = model->logicalSw[i].func; + CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily(); model->logicalSw[i].func = newFunc; - if (newFuncFamily == LS_FAMILY_TIMER) { - model->logicalSw[i].val1 = -119; - model->logicalSw[i].val2 = -119; - } - else if (newFuncFamily == LS_FAMILY_EDGE) { - model->logicalSw[i].val2 = -129; - } - } - if (bool(oldFunc) != bool(newFunc)) { - emit updateDataModels(); - update(); - } - else - updateLine(i); + CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily(); - emit modified(); + if (oldFuncFamily != newFuncFamily) { + model->logicalSw[i].clear(); + model->logicalSw[i].func = newFunc; + if (newFuncFamily == LS_FAMILY_TIMER) { + model->logicalSw[i].val1 = -119; + model->logicalSw[i].val2 = -119; + } + else if (newFuncFamily == LS_FAMILY_EDGE) { + model->logicalSw[i].val2 = -129; + } + } + + updateLine(i); + emit modified(); + } } void LogicalSwitchesPanel::onV1Changed(int value) @@ -353,7 +350,7 @@ void LogicalSwitchesPanel::updateLine(int i) cbFunction[i]->setCurrentIndex(cbFunction[i]->findData(model->logicalSw[i].func)); cbAndSwitch[i]->setCurrentIndex(cbAndSwitch[i]->findData(RawSwitch(model->logicalSw[i].andsw).toValue())); - if (!model->logicalSw[i].func) { + if (model->logicalSw[i].isEmpty()) { mask = 0; } else {