mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
Even more race precautions
* It did not break yet, but I could not sleep without this commit.
This commit is contained in:
parent
6189326430
commit
839f1b720e
@ -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
|
||||
@ -129,13 +130,18 @@ ControlConnection::setup()
|
||||
void
|
||||
ControlConnection::registerSource()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << m_source->id();
|
||||
Source* source = (Source*) sender();
|
||||
Q_UNUSED( source )
|
||||
Q_ASSERT( source == m_source.data() );
|
||||
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();
|
||||
Q_UNUSED( source )
|
||||
Q_ASSERT( source == m_source.data() );
|
||||
|
||||
m_registered = true;
|
||||
setupDbSyncConnection();
|
||||
m_registered = true;
|
||||
setupDbSyncConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user