diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2018-03-08 22:39:48 +0100 |
---|---|---|
committer | Daniel Schürmann <daschuer@mixxx.org> | 2018-03-08 22:39:48 +0100 |
commit | 6cddd2c3e6c98f2c06487860c13929c47a3908c8 (patch) | |
tree | 2f71bfc4c28e75b3fc43d1c37cc466179fb10399 /src/library/library.cpp | |
parent | c5fb9914cf8113c72ef0d493c5864ba584019df4 (diff) |
removed the redundant queued invocation in Library::saveCachedTrack()
Diffstat (limited to 'src/library/library.cpp')
-rw-r--r-- | src/library/library.cpp | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/src/library/library.cpp b/src/library/library.cpp index c1b43d2322..91707e051a 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -435,40 +435,10 @@ void Library::saveCachedTrack(TrackPointer pTrack) noexcept { // ensure that we have exclusive (write) access on the file // and not reader or writer is accessing the same file // concurrently. - // Pass the track object via a plain pointer to prevent the - // creation of any new references from the shared pointer - // that will be deleted soon! m_pTrackCollection->exportTrackMetadata(pTrack.get()); - // NOTE(uklotzde, 2018-02-20): - // Database updates must be executed in the context of the - // main thread. When saving is triggered from another - // thread the call needs to be dispatched through a queued - // connection and is deferred until the event loop of the - // receiving thread that handles the event. The actual - // execution might happen when the cache has already been - // unlocked after leaving this function. - // Race conditions between database readers and writers are - // impossible as long as all database actions are executed in - // the main thread and the invocation is submitted through - // a direct connection. - // This method might be invoked from a different thread than - // the main thread. But database updates are currently only - // allowed from the main thread! - QMetaObject::invokeMethod( - this, - "saveTrack", - // Qt will choose either a direct or a queued connection - // depending on the thread from which this method has - // been invoked! - Qt::AutoConnection, - Q_ARG(TrackPointer, pTrack)); -} - -void Library::saveTrack(TrackPointer pTrack) { - // Update the database - // Pass the track object via a plain pointer to prevent the - // creation of any new references from the shared pointer - // that will be deleted soon! + // The track must be saved while the cache is locked to + // prevent that a new track is created from the outdated + // metadata that is is the database before saving is finished. m_pTrackCollection->saveTrack(pTrack.get()); } |