Skip to content

Commit

Permalink
Discard garbage cues that have been introduced by issue mixxxdj#11283
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Apr 10, 2023
1 parent be7c91a commit dc6afec
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/library/dao/cuedao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inline QString labelFromQVariant(const QVariant& value) {
CuePointer cueFromRow(const QSqlRecord& row) {
const auto id = DbId(row.value(row.indexOf("id")));
TrackId trackId(row.value(row.indexOf("track_id")));
int type = row.value(row.indexOf("type")).toInt();
auto type = static_cast<mixxx::CueType>(row.value(row.indexOf("type")).toInt());
double position = row.value(row.indexOf("position")).toDouble();
int length = row.value(row.indexOf("length")).toInt();
int hotcue = row.value(row.indexOf("hotcue")).toInt();
Expand All @@ -48,9 +48,19 @@ CuePointer cueFromRow(const QSqlRecord& row) {
VERIFY_OR_DEBUG_ASSERT(color) {
return CuePointer();
}
if (type == mixxx::CueType::Loop && length == 0) {
// These entries are likely added via issue #11283
qWarning() << "Discard loop cue" << hotcue << "found in database with length of 0";
return CuePointer();
}
if (type == mixxx::CueType::HotCue && position == 0 && *color == mixxx::RgbColor(0)) {
// These entries are likely added via issue #11283
qWarning() << "Discard black hot cue" << hotcue << "found in database at position 0";
return CuePointer();
}
CuePointer pCue(new Cue(id,
trackId,
static_cast<mixxx::CueType>(type),
type,
position,
length,
hotcue,
Expand Down Expand Up @@ -81,7 +91,7 @@ QList<CuePointer> CueDAO::getCuesForTrack(TrackId trackId) const {
QMap<int, CuePointer> hotCuesByNumber;
while (query.next()) {
CuePointer pCue = cueFromRow(query.record());
VERIFY_OR_DEBUG_ASSERT(pCue) {
if (!pCue) {
continue;
}
int hotCueNumber = pCue->getHotCue();
Expand Down
33 changes: 32 additions & 1 deletion src/track/serato/tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,22 @@ QList<CueInfo> SeratoTags::getCueInfos() const {
if (!index) {
continue;
}

if (cueInfo.getType() == mixxx::CueType::Loop &&
(!cueInfo.getEndPositionMillis() ||
*cueInfo.getEndPositionMillis() == 0)) {
// These entries are likely added via issue #11283
qWarning() << "Discard loop cue" << index << "found in markers2 with length of 0";
continue;
}
if (cueInfo.getType() == mixxx::CueType::HotCue &&
(!cueInfo.getStartPositionMillis() ||
*cueInfo.getStartPositionMillis() == 0) &&
(!cueInfo.getColor() ||
*cueInfo.getColor() == mixxx::RgbColor(0))) {
// These entries are likely added via issue #11283
qWarning() << "Discard black hot cue" << index << "found in markers2 at position 0";
continue;
}
CueInfo newCueInfo(cueInfo);
newCueInfo.setHotCueIndex(index);
cueMap.insert(*index, newCueInfo);
Expand Down Expand Up @@ -237,6 +252,22 @@ QList<CueInfo> SeratoTags::getCueInfos() const {
if (!index) {
continue;
}
if (cueInfo.getType() == mixxx::CueType::Loop &&
(!cueInfo.getEndPositionMillis() ||
*cueInfo.getEndPositionMillis() == 0)) {
// These entries are likely added via issue #11283
qWarning() << "Discard loop cue" << index << "found in markers with length of 0";
continue;
}
if (cueInfo.getType() == mixxx::CueType::HotCue &&
(!cueInfo.getStartPositionMillis() ||
*cueInfo.getStartPositionMillis() == 0) &&
(!cueInfo.getColor() ||
*cueInfo.getColor() == mixxx::RgbColor(0))) {
// These entries are likely added via issue #11283
qWarning() << "Discard black hot cue" << index << "found in markers at position 0";
continue;
}

// Take a pre-existing CueInfo object that was read from
// "SeratoMarkers2" from the CueMap (or a default constructed CueInfo
Expand Down

0 comments on commit dc6afec

Please sign in to comment.