Skip to content

Commit

Permalink
TrackDAO: Fix semantics of marking a track clean after update
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Nov 20, 2021
1 parent c99d3c4 commit 04210b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
26 changes: 12 additions & 14 deletions src/library/dao/trackdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ void TrackDAO::saveTrack(Track* pTrack) const {
qDebug() << "TrackDAO: Saving track"
<< trackId
<< pTrack->getFileInfo();
if (updateTrack(pTrack)) {
if (updateTrack(*pTrack)) {
// BaseTrackCache must be informed separately, because the
// track has already been disconnected and TrackDAO does
// not receive any signals that are usually forwarded to
// BaseTrackCache.
DEBUG_ASSERT(!pTrack->isDirty());
pTrack->markClean();
emit mixxx::thisAsNonConst(this)->trackClean(trackId);
}
}
Expand Down Expand Up @@ -1598,14 +1598,14 @@ TrackPointer TrackDAO::getTrackByRef(
}

// Saves a track's info back to the database
bool TrackDAO::updateTrack(Track* pTrack) const {
const TrackId trackId = pTrack->getId();
bool TrackDAO::updateTrack(const Track& track) const {
const TrackId trackId = track.getId();
DEBUG_ASSERT(trackId.isValid());

qDebug() << "TrackDAO:"
<< "Updating track in database"
<< trackId
<< pTrack->getFileInfo();
<< "Updating track in database"
<< trackId
<< track.getFileInfo();

SqlTransaction transaction(m_database);
// PerformanceTimer time;
Expand Down Expand Up @@ -1664,11 +1664,11 @@ bool TrackDAO::updateTrack(Track* pTrack) const {

query.bindValue(":track_id", trackId.toVariant());

const auto trackRecord = pTrack->getRecord();
const auto trackRecord = track.getRecord();
bindTrackLibraryValues(
&query,
trackRecord,
pTrack->getBeats());
track.getBeats());

VERIFY_OR_DEBUG_ASSERT(query.exec()) {
LOG_FAILED_QUERY(query);
Expand All @@ -1684,16 +1684,14 @@ bool TrackDAO::updateTrack(Track* pTrack) const {
//time.start();
m_analysisDao.saveTrackAnalyses(
trackId,
pTrack->getWaveform(),
pTrack->getWaveformSummary());
track.getWaveform(),
track.getWaveformSummary());
m_cueDao.saveTrackCues(
trackId, pTrack->getCuePoints());
trackId, track.getCuePoints());
transaction.commit();

//qDebug() << "Update track in database took: " << time.elapsed().formatMillisWithUnit();
//time.start();
pTrack->markClean();
//qDebug() << "Dirtying track took: " << time.elapsed().formatMillisWithUnit();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/library/dao/trackdao.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class TrackDAO : public QObject, public virtual DAO, public virtual GlobalTrackC
}
void addTracksFinish(bool rollback = false);

bool updateTrack(Track* pTrack) const;
bool updateTrack(const Track& track) const;

void hideAllTracks(const QDir& rootDir) const;

Expand Down

0 comments on commit 04210b9

Please sign in to comment.