fix(rade): fully restore slice state when RADE engine fails to start#2898
Open
NF0T wants to merge 1 commit into
Open
fix(rade): fully restore slice state when RADE engine fails to start#2898NF0T wants to merge 1 commit into
NF0T wants to merge 1 commit into
Conversation
When RADEEngine::start() fails, activateRADE() left the slice in a partially mutated state: mode stuck at DIGU/DIGL with RADE-shaped filter edges, and the TX badge potentially moved to the wrong slice. Capture prevMode, prevFilterLow/High, and prevTxSliceId before any mutations. On failure: call deactivateRADE() (handles mute, engine teardown, m_radeSliceId), then restore mode, filter width, and TX badge. TX badge restore: if prevTxSliceId differs from sliceId, either call setTxSlice(true) on the original owner (radio echoes tx=0 on the RADE slice automatically), or setTxSlice(false) if no slice owned TX before. Also promotes the failure log from qWarning to qCWarning(lcRade) so it appears in the aether.rade support-bundle category. Closes the two residual gaps flagged in review of aethersdr#2861. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
Contributor
There was a problem hiding this comment.
Reviewed end-to-end against MainWindow.cpp around activateRADE() / deactivateRADE() and SliceModel's API — the rollback is well-formed.
Correctness checks
prevTxSliceId,prevMode,prevFilterLow,prevFilterHighare all captured after the!snull guard and before any mutation. ✔- TX-badge restore tri-state matches the radio's invariant that at most one slice owns TX:
prevTxSliceId == sliceId→ no-op (RADE slice already owned TX before activation), ✔prevTxSliceId >= 0 && != sliceId→ previous owner restored viasetTxSlice(true); radio will echotx=0on the RADE slice, ✔prevTxSliceId == -1→setTxSlice(false)on the RADE slice to clear the badge, ✔
- The
deactivateRADE()call inside the!okbranch is safe at this point:m_radeSliceIdandm_radePrevMuteare already set (lines 13802–13803), so the audio-mute rollback works.m_digitalVoiceTxSliceis not yet set;setDigitalVoiceTxSlice(-1)from its current-1is a no-op.- The DAX/audio
connect()calls all happen after the!okblock, so the correspondingdisconnect()s indeactivateRADE()are harmless no-ops (Qt returns false, no warning). RADEEngine::stop()invoked on a never-started engine is safe perRADEEngine.cpp.
- Re-fetching
m_radioModel.slice(sliceId)afterdeactivateRADE()is defensive but appropriate — deactivateRADE doesn't delete slices, but the pattern is consistent with the rest of the file. ✔ qWarning()→qCWarning(lcRade)matches the category declared inLogManager.h/.cpp. ✔
Scope — single file, ~28 lines, all in the one function. No drive-by changes.
No issues found. The rollback closes the three gaps cleanly (mode, filter, TX badge) and the re-entry path will see a clean slice state. Nice incremental on top of #2861.
Thanks for the careful capture-before-mutate ordering and the explicit tri-state for the TX badge — that's the part that would have been easy to get subtly wrong.
73, AetherClaude
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
When
RADEEngine::start()fails,activateRADE()left the slice in apartially mutated state. Three radio-visible items were set before
start()but never rolled back on failure:
mode reverts (e.g. USB slice with 3.5 kHz edges)
before activation — left on the wrong slice after failure
These gaps were identified in review of #2861, which fixes the stranded
audio_mute/engine state. This PR closes the remaining two items flagged
there. It can land before or after #2861; if both are open it supersedes
#2861 entirely.
Changes —
src/gui/MainWindow.cpponlyCapture four values before any mutations, all after the
!snull guard:prevTxSliceId— the slice ID that currently owns TX (or -1 if none).Captured by iterating
m_radioModel.slices()beforesetTxSlice(true).prevMode— the slice's current mode string, beforesetMode(DIGU/DIGL).prevFilterLow/prevFilterHigh— current filter edges (Hz), beforesetFilterWidth(±3500, 0/0, 3500).In the
!okfailure block:deactivateRADE()— handlesm_radeSliceId,m_radePrevMute→audioMute, engine thread teardown, and themodeChangeddisconnect.This is already correct and idempotent for fields not yet set at this
point (
m_digitalVoiceTxSlice, DAX/audio connections).setMode(prevMode).setFilterWidth(prevFilterLow, prevFilterHigh).prevTxSliceId == sliceId: RADE slice already owned TX — nothing to undo.prevTxSliceId >= 0 && != sliceId: callsetTxSlice(true)on the previousowner; the radio echoes
tx=0on the RADE slice automatically.prevTxSliceId == -1: no TX slice before activation — callsetTxSlice(false)on the RADE slice to remove the badge.
Also promotes
qWarning()→qCWarning(lcRade)so the failure appears in theaether.radesupport-bundle category.Test plan
DIGU/DIGL, TX badge stays on RADE slice, filter correct
return falsefromRADEEngine::start(),with the test slice not the current TX slice:
- Slice mode reverts to pre-RADE mode
- Filter width reverts to pre-RADE values
- TX badge returns to original slice
-
aether.radelog shows "RADE engine failed to start — restoring slice state"cleanly with no leftover state
Closes the two residual gaps flagged in reviews of #2861.