Merge pull request #8357 from opentx/elecpower/cpn-inp-del-fix-8354
Companion fix delete input corruption
This commit is contained in:
@@ -351,7 +351,7 @@ void InputsPanel::expoOpen(QListWidgetItem *item)
|
||||
if (!item)
|
||||
item = ExposlistWidget->currentItem();
|
||||
|
||||
if (item == nullptr)
|
||||
if (item == nullptr)
|
||||
return;
|
||||
|
||||
int idx = item->data(Qt::UserRole).toByteArray().at(0);
|
||||
@@ -372,7 +372,7 @@ void InputsPanel::expoOpen(QListWidgetItem *item)
|
||||
void InputsPanel::expoAdd()
|
||||
{
|
||||
QListWidgetItem *item = ExposlistWidget->currentItem();
|
||||
if (item == nullptr)
|
||||
if (item == nullptr)
|
||||
return;
|
||||
|
||||
int index = item->data(Qt::UserRole).toByteArray().at(0);
|
||||
@@ -580,13 +580,15 @@ bool InputsPanel::cmInputMoveUpAllowed() const
|
||||
|
||||
void InputsPanel::cmInputClear()
|
||||
{
|
||||
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all lines for the selected Inputs. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Clear all lines for the selected Input. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
for (int i = CPN_MAX_EXPOS - 1; i >= 0; i--) {
|
||||
ExpoData *ed = &model->expoData[i];
|
||||
if ((int)ed->chn == inputIdx)
|
||||
model->removeInput(i);
|
||||
if (!ed->isEmpty()) {
|
||||
if ((int)ed->chn == inputIdx)
|
||||
model->removeInput(i);
|
||||
}
|
||||
}
|
||||
model->updateAllReferences(ModelData::REF_UPD_TYPE_INPUT, ModelData::REF_UPD_ACT_CLEAR, inputIdx);
|
||||
update();
|
||||
@@ -596,15 +598,17 @@ void InputsPanel::cmInputClear()
|
||||
|
||||
void InputsPanel::cmInputDelete()
|
||||
{
|
||||
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete all lines for the selected Inputs. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Delete all lines for the selected Input. Are you sure?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < CPN_MAX_EXPOS; i++) {
|
||||
for (int i = CPN_MAX_EXPOS - 1; i >= 0; i--) {
|
||||
ExpoData *ed = &model->expoData[i];
|
||||
if ((int)ed->chn == inputIdx)
|
||||
model->removeInput(i);
|
||||
else if ((int)ed->chn > inputIdx)
|
||||
ed->chn--;
|
||||
if (!ed->isEmpty()) {
|
||||
if ((int)ed->chn == inputIdx)
|
||||
model->removeInput(i);
|
||||
else if ((int)ed->chn > inputIdx)
|
||||
ed->chn--;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = inputIdx; i < inputsCount; i++) {
|
||||
|
||||
Reference in New Issue
Block a user