Fix HamLib radio type and Enable checkbox reset on settings open#1002
Merged
Conversation
…sion install
saveSettings() was writing HamLibRigType=0 whenever the HamLib tab had never
been shown (combo unpopulated). rigTypeComboBox->currentText() returns "" on an
empty combo, and getModelIdFromName("") uses QMap::operator[] on a missing key,
which default-constructs to 0. On next run setRigType("0") falls back to
setCurrentIndex(0), silently selecting the first rig alphabetically.
Guard the HamLibRigType write with m_rigsLoaded so the saved value is only
updated when the combo has actually been populated.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two related regressions introduced by the lazy-load showEvent() commit: 1. setRigType() in loadSettings() fired currentTextChanged which called slotRadioComboBoxChanged() -> setTestResult(false), unchecking and disabling the activation checkbox before loadSettings() could restore it. Fix: blockSignals around setRigType() in loadSettings(). 2. setDefaults() (constructor) disables the checkbox via setTestResult(false), but loadSettings() only called setChecked() — not setEnabled() — leaving the checkbox checked-but-grayed-out even when HamLibActive=true. Fix: re-enable the checkbox in loadSettings() when HamLibActive was true. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Two related bugs in the HamLib settings page that cause the saved radio type and the "Enable HamLib" checkbox state to be silently overwritten whenever the user opens the Settings dialog and clicks OK without visiting the HamLib tab.
Bug 1: Radio type overwritten with first list entry
What happens
After opening Settings → OK (without visiting the HamLib tab), the saved radio type (e.g. NET rigctl) is replaced with whichever rig appears first in the alphabetically-sorted list.
Root cause
SetupPageHamLiblazy-loads the rig combo box — it is only populated inshowEvent()the first time the HamLib tab is shown. However,saveSettings()is called unconditionally on every OK click, and writes:```cpp
settings.setValue("HamLibRigType",
hamlib->getModelIdFromName(rigTypeComboBox->currentText()));
```
When the combo is empty,
currentText()is"".getModelIdFromName("")usesQMap::operator[]on a missing key, which default-constructs to0. SoHamLibRigType=0is written to config, overwriting the correct saved value.On the next run,
setRigType("0")looks up model ID 0, finds nothing (hamlib models start at 1), and falls back tosetCurrentIndex(0)— the first rig alphabetically.When it was introduced
The
showEvent()lazy-load guard (m_rigsLoaded) was added to defer the expensiverig_load_all_backends()call until the HamLib tab is actually visited. This created the window wheresaveSettings()could be called before the combo was ever populated.Fix
Guard the
HamLibRigTypewrite withm_rigsLoaded. If the combo was never populated this session, the existing config value is left untouched:```cpp
if (m_rigsLoaded)
settings.setValue("HamLibRigType", ...);
```
Trigger conditions
checkIfNewVersion()forces the Settings dialog open and the user clicks OK after updating their callsign without visiting the HamLib tab.Bug 2: "Enable HamLib" checkbox shown unchecked/disabled
What happens
Opening the Settings → HamLib tab shows the "Enable HamLib" checkbox as unchecked and grayed out, even when HamLib was previously configured and enabled.
Root cause
Two issues working together:
a)
setRigType()inloadSettings()callssetCurrentIndex()on the combo, which firescurrentTextChanged→slotRadioComboBoxChanged()→setTestResult(false).setTestResult(false)unchecks and disables the activation checkbox — beforeloadSettings()has had a chance to restore it from config.b)
setDefaults()(called from the constructor) callssetTestResult(false), which disables the checkbox.loadSettings()callssetChecked()to restore the saved value, but never callssetEnabled(), so the checkbox remains disabled even whenHamLibActive=true.When it was introduced
The
showEvent()lazy-load commit moved rig-list population out ofcreateUI()and intoshowEvent(). Before that change, the combo was populated at construction time, and by the timeloadSettings()was called the signal chain was less disruptive. The lazy-load commit exposed both issues simultaneously.Fix
Two targeted changes to
loadSettings():```cpp
// Block signals so setRigType() cannot trigger setTestResult(false)
rigTypeComboBox->blockSignals(true);
setRigType(settings.value("HamLibRigType").toString());
rigTypeComboBox->blockSignals(false);
// Re-enable the checkbox if it was previously active
const bool wasActive = settings.value("HamLibActive", false).toBool();
activateHamlibCheckBox->setChecked(wasActive);
if (wasActive)
activateHamlibCheckBox->setEnabled(true);
```
Testing
🤖 Generated with Claude Code