fix(panadapter): TTL sweep on deferred pan-status map (#2228). Principle XI.#3037
Merged
Conversation
…ple XI. The deferred `m_pendingPanStatuses` queue in `RadioModel` holds `display pan` status that arrives without a `client_handle` so ownership can be confirmed later. Existing cleanup paths cover the common cases (disconnect, `removed`, ownership confirmed, non-owned with `client_handle`), but a pan that another client owns and that the radio never re-emits with `client_handle` (and never marks `removed`) leaks an entry indefinitely. Pair each map value with a `QDateTime::currentSecsSinceEpoch()` timestamp captured at insert, and sweep entries older than 30 s each time we insert. Per maintainer note on the issue: dropping a stale pending entry is never observably wrong because consumption only happens on ownership confirm — exactly the missing signal that would otherwise free the entry. The map is small in practice (typically <10 entries), so an O(N) sweep-on-insert is cheaper than a periodic-timer alternative. Three call sites adjusted for the new pair type: the `Defer` branch of the pan-status handler (insert + sweep), the consumer in `ensureOwnedPanadapter` (`pending.second`), and the existing `.clear()`/`.remove()` paths need no change. Blast radius: risk_score=0.476, 17 high-risk callers (top: MainWindow::MainWindow, MainWindow::wirePanadapter, MainWindow::buildMenuBar) — driven by the RadioModel.h include fan-out. The field is private and its type change is contained to three sites inside RadioModel.cpp; no public API, signal, or slot shape changes, so the high-risk callers are not behaviorally affected. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
There was a problem hiding this comment.
Targeted fix with a clear rationale in the comment — thanks for the thorough write-up of why the sweep is observably safe.
Verified all five touch points of m_pendingPanStatuses are consistent with the new QPair<qint64, QMap<QString, QString>> value type:
clear()/remove(panId)are type-agnostic.take()consumer correctly switched topending.second.isEmpty()andpending.second— and a default-constructedQPairstill yields an empty inner map, so the "no pending" path is preserved.- Producer stores
qMakePair(now, kvs).
One minor note (not blocking):
Wall-clock vs. monotonic time. QDateTime::currentSecsSinceEpoch() is wall-clock and can jump (NTP step, manual adjustment, suspend/resume). For a 30 s TTL the practical risk is low, but QElapsedTimer or std::chrono::steady_clock would be immune by construction. Worth considering if you touch this again, but not worth a respin on its own.
LGTM otherwise.
🤖 aethersdr-agent · cost: $2.7968 · model: claude-opus-4-7
G6PWY-Chris
pushed a commit
to G6PWY-Chris/AetherSDR
that referenced
this pull request
Jun 22, 2026
…. Principle XI. (aethersdr#3037) ## Summary Fixes aethersdr#2228 ### What was changed fix(panadapter): TTL sweep on deferred pan-status map (aethersdr#2228). Principle XI. ### Files modified - `src/models/RadioModel.cpp` - `src/models/RadioModel.h` ``` src/models/RadioModel.cpp | 21 ++++++++++++++++++--- src/models/RadioModel.h | 7 ++++++- 2 files changed, 24 insertions(+), 4 deletions(-) ``` --- Generated by AetherClaude (automated agent for AetherSDR) --- <sub>🤖 aethersdr-agent · cost: $13.2543 · model: claude-opus-4-7</sub> Co-authored-by: aethersdr-agent[bot] <273844287+aethersdr-agent[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 <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
Fixes #2228
What was changed
fix(panadapter): TTL sweep on deferred pan-status map (#2228). Principle XI.
Files modified
src/models/RadioModel.cppsrc/models/RadioModel.hGenerated by AetherClaude (automated agent for AetherSDR)
🤖 aethersdr-agent · cost: $13.2543 · model: claude-opus-4-7