mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Even more race precautions
* It did not break yet, but I could not sleep without this commit.
This commit is contained in:
@@ -477,6 +477,11 @@ Source::playlistInterface()
|
||||
return m_playlistInterface;
|
||||
}
|
||||
|
||||
QSharedPointer<QMutex> Source::acquireLock()
|
||||
{
|
||||
return QSharedPointer<QMutexLocker>( new QMutexLocker( &m_mutex ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Source::onPlaybackStarted( const Tomahawk::track_ptr& track, unsigned int duration )
|
||||
|
@@ -102,6 +102,8 @@ public:
|
||||
|
||||
Tomahawk::playlistinterface_ptr playlistInterface();
|
||||
|
||||
QSharedPointer<QMutex> acquireLock();
|
||||
|
||||
signals:
|
||||
void syncedWithDatabase();
|
||||
void synced();
|
||||
@@ -175,6 +177,7 @@ private:
|
||||
QString m_lastCmdGuid;
|
||||
mutable QMutex m_cmdMutex;
|
||||
QMutex m_setControlConnectionMutex;
|
||||
QMutex m_mutex;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
@@ -100,6 +100,7 @@ ControlConnection::setup()
|
||||
|
||||
// setup source and remote collection for this peer
|
||||
m_source = SourceList::instance()->get( id(), friendlyName, true );
|
||||
QSharedPointer<QMutexLocker> locker = m_source->acquireLock();
|
||||
if ( m_source->setControlConnection( this ) )
|
||||
{
|
||||
// We are the new ControlConnection for this source
|
||||
@@ -128,6 +129,10 @@ ControlConnection::setup()
|
||||
// source was synced to DB, set it up properly:
|
||||
void
|
||||
ControlConnection::registerSource()
|
||||
{
|
||||
QSharedPointer<QMutexLocker> locker = m_source->acquireLock();
|
||||
// Only continue if we are still the ControlConnection associated with this source.
|
||||
if ( m_source->controlConnection() == this )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << m_source->id();
|
||||
Source* source = (Source*) sender();
|
||||
@@ -137,6 +142,7 @@ ControlConnection::registerSource()
|
||||
m_registered = true;
|
||||
setupDbSyncConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user