From 6560c99445250049131074e7d1b66f75b4128719 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sat, 8 Feb 2014 18:22:06 +0100 Subject: [PATCH] Avoids the crash in Companion --- companion/src/modeledit/setup.cpp | 32 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index c11f54018..1ac5130ff 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -668,18 +668,18 @@ void Setup::startupSwitchToggled(bool checked) void Setup::updatePotWarnings() { lock = true; - int mode = model.nPotsToWarn >> 6; - ui->potWarningMode->setCurrentIndex(mode); - - if (mode == 0) - model.nPotsToWarn = 0x3F; + int mode = model.nPotsToWarn >> 6; + ui->potWarningMode->setCurrentIndex(mode); - for (int i=0; igetCapability(Pots); i++) { - bool enabled = !(model.nPotsToWarn & (1 << i)); + if (mode == 0) + model.nPotsToWarn = 0x3F; - potWarningCheckboxes[i]->setChecked(enabled); - potWarningCheckboxes[i]->setDisabled(mode == 0); - } + for (int i=0; isetChecked(enabled); + potWarningCheckboxes[i]->setDisabled(mode == 0); + } lock = false; } @@ -700,12 +700,14 @@ void Setup::potWarningToggled(bool checked) void Setup::on_potWarningMode_currentIndexChanged(int index) { - int mask = 0xC0; - model.nPotsToWarn = model.nPotsToWarn & ~mask; - model.nPotsToWarn = model.nPotsToWarn | ((index << 6) & mask); + if (!lock) { + int mask = 0xC0; + model.nPotsToWarn = model.nPotsToWarn & ~mask; + model.nPotsToWarn = model.nPotsToWarn | ((index << 6) & mask); - updatePotWarnings(); - emit modified(); + updatePotWarnings(); + emit modified(); + } } void Setup::on_displayText_toggled(bool checked)