summaryrefslogtreecommitdiffstats
path: root/src/track
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-07-13 01:17:57 +0200
committerUwe Klotz <uklotz@mixxx.org>2020-07-13 01:17:57 +0200
commit7d71d75d753a98d9d2abec37818f440470a4248d (patch)
treec3749e50b9b34a57e0d18a48e265b47cadb1383a /src/track
parent4d11c82f6e3ba780b1db037dfce92cb48f7668ad (diff)
parentf6210f4d84c13792fdbe022feb5a4d586bf0fa9d (diff)
Merge branch '2.3' of git@github.com:mixxxdj/mixxx.git
Diffstat (limited to 'src/track')
-rw-r--r--src/track/track.cpp27
-rw-r--r--src/track/track.h5
2 files changed, 22 insertions, 10 deletions
diff --git a/src/track/track.cpp b/src/track/track.cpp
index 506359209b..16c1459759 100644
--- a/src/track/track.cpp
+++ b/src/track/track.cpp
@@ -681,21 +681,31 @@ TrackId Track::getId() const {
void Track::initId(TrackId id) {
QMutexLocker lock(&m_qMutex);
+ DEBUG_ASSERT(id.isValid());
+ if (m_record.getId() == id) {
+ return;
+ }
// The track's id must be set only once and immediately after
// the object has been created.
- VERIFY_OR_DEBUG_ASSERT(!m_record.getId().isValid() || (m_record.getId() == id)) {
+ VERIFY_OR_DEBUG_ASSERT(!m_record.getId().isValid()) {
kLogger.warning() << "Cannot change id from"
<< m_record.getId() << "to" << id;
return; // abort
}
- m_record.setId(std::move(id));
+ m_record.setId(id);
+ for (const auto pCue : qAsConst(m_cuePoints)) {
+ pCue->setTrackId(id);
+ }
// Changing the Id does not make the track dirty because the Id is always
- // generated by the Database itself.
+ // generated by the database itself.
}
void Track::resetId() {
QMutexLocker lock(&m_qMutex);
m_record.setId(TrackId());
+ for (const auto pCue : qAsConst(m_cuePoints)) {
+ pCue->setTrackId(TrackId());
+ }
}
void Track::setURL(const QString& url) {
@@ -838,16 +848,18 @@ CuePointer Track::findCueById(int id) const {
}
void Track::removeCue(const CuePointer& pCue) {
- if (pCue == nullptr) {
+ if (!pCue) {
return;
}
QMutexLocker lock(&m_qMutex);
+ DEBUG_ASSERT(pCue->getTrackId() == m_record.getId());
disconnect(pCue.get(), 0, this, 0);
m_cuePoints.removeOne(pCue);
if (pCue->getType() == mixxx::CueType::MainCue) {
m_record.setCuePoint(CuePosition());
}
+ pCue->setTrackId(TrackId());
markDirtyAndUnlock(&lock);
emit cuesUpdated();
}
@@ -861,6 +873,7 @@ void Track::removeCuesOfType(mixxx::CueType type) {
// FIXME: Why does this only work for the Hotcue Type?
if (pCue->getType() == type) {
disconnect(pCue.get(), 0, this, 0);
+ pCue->setTrackId(TrackId());
it.remove();
dirty = true;
}
@@ -874,11 +887,6 @@ void Track::removeCuesOfType(mixxx::CueType type) {
}
}
-QList<CuePointer> Track::getCuePoints() const {
- QMutexLocker lock(&m_qMutex);
- return m_cuePoints;
-}
-
void Track::setCuePoints(const QList<CuePointer>& cuePoints) {
// While this method could be called from any thread,
// associated Cue objects should always live on the
@@ -951,6 +959,7 @@ void Track::setCuePointsMarkDirtyAndUnlock(
// disconnect existing cue points
for (const auto& pCue: m_cuePoints) {
disconnect(pCue.get(), 0, this, 0);
+ pCue->setTrackId(TrackId());
}
m_cuePoints = cuePoints;
// connect new cue points
diff --git a/src/track/track.h b/src/track/track.h
index 97d2b95066..56b920fedb 100644
--- a/src/track/track.h
+++ b/src/track/track.h
@@ -268,7 +268,10 @@ class Track : public QObject {
CuePointer findCueById(int id) const;
void removeCue(const CuePointer& pCue);
void removeCuesOfType(mixxx::CueType);
- QList<CuePointer> getCuePoints() const;
+ QList<CuePointer> getCuePoints() const {
+ // Copying implicitly shared collections is thread-safe
+ return m_cuePoints;
+ }
void setCuePoints(const QList<CuePointer>& cuePoints);