Skip to content

CMRT 31: Fixups addCmrtMember + stem canonical pref + Clear MusicBrainz Data + CMRT/MBQueue refresh fix + MBQueue status text/rendering fix - #46

Open
Swarnadip-Kar wants to merge 9 commits into
cmrt-library-table-columnfrom
cmrt-fixups-stem-mbclear-refresh
Open

CMRT 31: Fixups addCmrtMember + stem canonical pref + Clear MusicBrainz Data + CMRT/MBQueue refresh fix + MBQueue status text/rendering fix#46
Swarnadip-Kar wants to merge 9 commits into
cmrt-library-table-columnfrom
cmrt-fixups-stem-mbclear-refresh

Conversation

@Swarnadip-Kar

Copy link
Copy Markdown
Owner

Five items bundled into one PR -- two flagged
fixups, one new preference, one new track-menu action,
one refresh bug fix.

A — Fixups

addCmrtMember()'s null-or-value binding restructured into temp
variables (mentor-suggested pattern).

B — Stem-aware canonical scoring

New preference (off by default): "Allow stem files to become the
canonical track (CMRT)." QualityScorer's format table doesn't recognize
"stem" as a filetype and was defaulting stems to the mp3-tier
score (50.0) -- letting a stem win or tie a canonical
election. Off, a stem's score is clamped to 0.0, so any real-format
competitor always outscores it, and two competing stems tie at 0.0 (the
existing ">" comparison already keeps whichever got there first -- no new
branching needed). The first track fingerprinted for any mastering still
always becomes canonical regardless of stem-ness; this only changes what
happens when a second track later matches into its group.
but the clamp is now comparison-only.

A stem's real QualityScorer score is always written to
cmrt_members/fingerprint_metadata -- the 0.0 clamp only ever decides who
wins a canonical election, it is never what gets stored for either
track. This was a correctness bug in the original draft: as written, a
stem's true score would have been overwritten with 0.0 in the database
itself.

C — Clear > MusicBrainz Data

New TrackDAO::clearMusicBrainzData() nulls every MBID/AcoustID column
(including acoustid_lookup_at, which updateAcoustIdResult() can't null --
it stamps that column with the current time unconditionally). Recovers
tracks whose lookup status is stuck at 'completed' with partially-correct
MBIDs, which were previously invisible to both the MBQueue view and the
worker's polling query. New WTrackMenu action mirrors Clear > Fingerprint;
standalone use re-queues for a fresh lookup, Clear > All does not (the
fingerprint is already gone by that point in the same action).

D — CMRT column refresh fix

The CMRT column comes from library_view's own joined SQL, cached once per
BaseSqlTableModel::select() -- unlike key/bpm (BaseTrackCache-backed),
it doesn't refresh on a plain dataChanged() signal, which is why it only
ever updated after an action that happens to trigger a full re-select
(sorting, switching sidebar tabs, toggling a column). Added
AcoustIdWorker::cmrtDataChanged(), emitted after each
CmrtGroupingService::processTrack() call, forwarded (signal-to-signal)
through a matching TrackCollectionManager::cmrtDataChanged() signal into
Library's existing slotRefreshLibraryModels() -- the same slot already
used for libraryScanFinished(), not a new refresh mechanism.
DlgPrefFingerprint::slotClearAllFingerprints() and
WTrackMenu::clearFingerprintDataForSelection() (Clear > Fingerprint /
Clear > All) had the identical stale-column problem and are fixed the
same way. The MBQueue panel had the same class of bug for a different
table (musicbrainz_queue_view, not the CMRT column) -- forwarded the
worker's existing queueDrained() through a new
TrackCollectionManager::acoustIdQueueDrained() signal so
DlgMusicBrainzQueue can re-select its own table model once per finished
batch instead of only on button clicks.

E — MBQueue Status column text fix

Separate, non-refresh bug found while reviewing the MBQueue files:
MusicBrainzQueueTableModel::rawValue() only mapped the NULL status case
to "pending" and passed every other status ("queued"/"failed"/
"unmatched") straight through as raw DB tokens, even though the comment
in AcoustIdWorker::processJob() explicitly says the view is supposed to
show "no match" vs "lookup failed" as distinct, readable text. Added the
missing mapping.

E-followup — MBQueue Status column rendering fix

The Status cell was rendering inside a boxed/bordered shape with a
leading gap before the text, unlike other columns. Root cause:
BaseTrackTableModel::roleValue() returned rawValue unconditionally for
columns mapping to COLUMN_LIBRARYTABLE_INVALID (i.e. columns whose name
isn't in ColumnCache::kColumnPropertiesByEnum, like "status"). For
Qt::DecorationRole, this caused Qt to interpret the status text string
as a decoration icon, rendering an empty black rectangle with reserved
space. Fixed in basetracktablemodel.cpp by guarding the early return to
only pass rawValue for display/tooltip/edit/export roles.

Depends on: cmrt-fixup-per-field-toggles-quality-score (#41)

@Swarnadip-Kar
Swarnadip-Kar force-pushed the cmrt-fixups-stem-mbclear-refresh branch from 73d396c to 9b719c8 Compare July 9, 2026 17:42
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 29038011575

Coverage decreased (-0.02%) to 30.227%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: 94 uncovered changes across 10 files (1 of 95 lines covered, 1.05%).
  • 12 coverage regressions across 7 files.

Uncovered Changes

File Changed Covered %
src/musicbrainz/cmrtgroupingservice.cpp 22 0 0.0%
src/widget/wtrackmenu.cpp 19 0 0.0%
src/library/dao/trackdao.cpp 13 0 0.0%
src/library/dao/trackfingerprintdao.cpp 10 0 0.0%
src/library/musicbrainzqueue/musicbrainzqueuetablemodel.cpp 9 0 0.0%
src/preferences/dialog/dlgpreffingerprint.cpp 7 0 0.0%
src/library/basetracktablemodel.cpp 5 0 0.0%
src/library/musicbrainzqueue/dlgmusicbrainzqueue.cpp 4 0 0.0%
src/musicbrainz/acoustidworker.cpp 3 0 0.0%
src/library/trackcollectionmanager.cpp 2 0 0.0%
Total (11 files) 95 1 1.05%

Coverage Regressions

12 previously-covered lines in 7 files lost coverage.

File Lines Losing Coverage Coverage
src/musicbrainz/cmrtgroupingservice.cpp 4 0.0%
src/preferences/dialog/dlgpreffingerprint.cpp 2 0.0%
src/widget/wtrackmenu.cpp 2 0.0%
src/library/dao/trackfingerprintdao.cpp 1 0.75%
src/library/musicbrainzqueue/dlgmusicbrainzqueue.cpp 1 0.0%
src/library/musicbrainzqueue/musicbrainzqueuetablemodel.cpp 1 0.0%
src/library/trackcollectionmanager.cpp 1 25.15%

Coverage Stats

Coverage Status
Relevant Lines: 117108
Covered Lines: 35398
Line Coverage: 30.23%
Coverage Strength: 58785.87 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants