Skip to content

Enable debug logging and fix shared prefix entity resolution#985

Merged
ea4k merged 4 commits intomasterfrom
claude/refactor-code-review-9Z3ew
Apr 12, 2026
Merged

Enable debug logging and fix shared prefix entity resolution#985
ea4k merged 4 commits intomasterfrom
claude/refactor-code-review-9Z3ew

Conversation

@ea4k
Copy link
Copy Markdown
Owner

@ea4k ea4k commented Apr 12, 2026

Summary

This PR enables comprehensive debug logging throughout the entity and prefix resolution logic and fixes a critical bug where shared prefixes between entities were resolved to the wrong entity.

Key Changes

Debug Logging Enhancements

  • Uncommented and enabled all qDebug() statements in setEntityAndPrefix() method to provide detailed tracing of entity resolution logic
  • Added new debug checkpoints (e.g., "16", "17", "21") to track execution flow through conditional branches
  • Enabled debug output in slotEntityNameComboBoxChanged() to log entity lookups
  • Improved debug message formatting and consistency throughout the method

Bug Fixes

  • Fixed shared prefix resolution: Added condition hostFullPrefix != hostPrefix when checking if primarySubdivisions is empty, preventing incorrect fallback to main prefix when a valid full prefix exists
  • Changed primarySubdivisions.append() calls to direct assignment (=) to avoid accumulating duplicate results
  • Removed redundant primarySubdivisions.clear() call
  • Updated error message from "hostPrefix" to "hostFullPrefix" for accuracy in debug output
  • Improved TODO comment formatting for "ea4k IT9" issue

Test Coverage

  • Added regression test test_SharedPrefixEntityIdentification() to verify that shared prefixes resolve to the correct entity
  • Test specifically validates that CE9 (shared between Antarctica and South Shetland Islands) resolves to Antarctica (entity 13), not South Shetland Islands (entity 241)
  • Includes verification that South Shetland Islands remains accessible via its own main prefix (VP8/h)

Implementation Details

The root cause of the shared prefix bug was in the prefix lookup logic where multiple entities could claim the same prefix. The fix ensures that when a full prefix match is found, the code doesn't incorrectly fall back to the main prefix lookup, which could return a different entity that also uses that prefix.

https://claude.ai/code/session_01LWBgDGA4opzSHSYpq8sxnH

claude and others added 4 commits April 12, 2026 08:35
- Remove unused Callsign entityCall and QString prefixForSubdivision
- Remove redundant primarySubdivisions.clear() after fresh declaration
- Skip second getPrimarySubDivisions query when hostFullPrefix == hostPrefix
- Use int directly in qDebug instead of QString::number()
- Fix debug message label at fallback step 50

https://claude.ai/code/session_01LWBgDGA4opzSHSYpq8sxnH
…ad of Antarctica

CE9 is Antarctica's main prefix but also appears in South Shetland Islands'
sub-prefix list. The prefixesofentity table allows both (UNIQUE on prefix+dxcc,
not prefix alone), and getWorldData() has no ORDER BY so QHash::insert() lets
the last-loaded row win — South Shetland Islands (241) appears after Antarctica
(13) in cty.csv and silently overwrites CE9 in the hash.

The new test_SharedPrefixEntityIdentification() pinpoints this regression and
also guards KC4 (exclusive Antarctica prefix) and VP8/S (South Shetland Islands
main prefix) to prevent related regressions.

https://claude.ai/code/session_01LWBgDGA4opzSHSYpq8sxnH
getWorldData(): two-phase load so canonical main prefixes always win.
Previously, when a prefix appeared in multiple entities' sub-prefix lists
(e.g. CE9 in both Antarctica and South Shetland Islands), the last row
loaded silently overwrote earlier ones in the QHash. Phase 2 now overwrites
all sub-prefix entries with each entity's mainprefix from the entity table,
making the canonical mapping deterministic regardless of cty.csv row order.

readZones(): fix Qt5→Qt6 migration bug in both zone-override blocks.
sliced(pos, 1) took only the bracket character itself, causing ITUz/CQz
overrides like EA8[28] or KH8(32) to always produce zone 0. Changed to
sliced(pos + 1) to capture the number after the bracket.

https://claude.ai/code/session_01LWBgDGA4opzSHSYpq8sxnH
@sonarqubecloud
Copy link
Copy Markdown

@ea4k ea4k merged commit a96edbd into master Apr 12, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants