From 1534efecdc8437490fd73ab91b394c5b0921561d Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Mon, 12 Jul 2021 15:32:18 +0200 Subject: [PATCH] Track: Fix debug assertion for missing/invalid bpm --- src/track/track.cpp | 11 +++++------ src/track/track.h | 7 +++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/track/track.cpp b/src/track/track.cpp index 2402aaf259a..8efd3a53eec 100644 --- a/src/track/track.cpp +++ b/src/track/track.cpp @@ -173,7 +173,7 @@ void Track::replaceMetadataFromSource( // missing or not valid! The BPM value in the metadata might be // imprecise (normalized or rounded), e.g. ID3v2 only supports // integer values. - beatsAndBpmModified = trySetBpmWhileLocked(importedBpm.value()); + beatsAndBpmModified = trySetBpmWhileLocked(importedBpm); } modified |= beatsAndBpmModified; @@ -285,7 +285,7 @@ bool Track::replaceRecord( } else { // Setting the bpm manually may in turn update the beat grid bpmUpdatedFlag = trySetBpmWhileLocked( - newRecord.getMetadata().getTrackInfo().getBpm().value()); + newRecord.getMetadata().getTrackInfo().getBpm()); } // The bpm in m_record has already been updated. Read it and copy it into // the new record to ensure it will be consistent with the new beat grid. @@ -334,8 +334,7 @@ mixxx::Bpm Track::getBpmWhileLocked() const { return m_record.getMetadata().getTrackInfo().getBpm(); } -bool Track::trySetBpmWhileLocked(double bpmValue) { - const auto bpm = mixxx::Bpm(bpmValue); +bool Track::trySetBpmWhileLocked(mixxx::Bpm bpm) { if (!bpm.isValid()) { // If the user sets the BPM to an invalid value, we assume // they want to clear the beatgrid. @@ -367,9 +366,9 @@ double Track::getBpm() const { return bpm.isValid() ? bpm.value() : mixxx::Bpm::kValueUndefined; } -bool Track::trySetBpm(double bpmValue) { +bool Track::trySetBpm(mixxx::Bpm bpm) { auto locked = lockMutex(&m_qMutex); - if (!trySetBpmWhileLocked(bpmValue)) { + if (!trySetBpmWhileLocked(bpm)) { return false; } afterBeatsAndBpmUpdated(&locked); diff --git a/src/track/track.h b/src/track/track.h index 5dab8dd708f..8aa4c33f2b3 100644 --- a/src/track/track.h +++ b/src/track/track.h @@ -128,7 +128,10 @@ class Track : public QObject { } // Sets the BPM if not locked. - bool trySetBpm(double bpm); + bool trySetBpm(double bpmValue) { + return trySetBpm(mixxx::Bpm(bpmValue)); + } + bool trySetBpm(mixxx::Bpm bpm); // Returns BPM double getBpm() const; @@ -466,7 +469,7 @@ class Track : public QObject { bool importPendingCueInfosWhileLocked(); mixxx::Bpm getBpmWhileLocked() const; - bool trySetBpmWhileLocked(double bpmValue); + bool trySetBpmWhileLocked(mixxx::Bpm bpm); bool trySetBeatsWhileLocked( mixxx::BeatsPointer pBeats, bool lockBpmAfterSet = false);