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;
|
return m_playlistInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSharedPointer<QMutex> Source::acquireLock()
|
||||||
|
{
|
||||||
|
return QSharedPointer<QMutexLocker>( new QMutexLocker( &m_mutex ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Source::onPlaybackStarted( const Tomahawk::track_ptr& track, unsigned int duration )
|
Source::onPlaybackStarted( const Tomahawk::track_ptr& track, unsigned int duration )
|
||||||
|
@@ -102,6 +102,8 @@ public:
|
|||||||
|
|
||||||
Tomahawk::playlistinterface_ptr playlistInterface();
|
Tomahawk::playlistinterface_ptr playlistInterface();
|
||||||
|
|
||||||
|
QSharedPointer<QMutex> acquireLock();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void syncedWithDatabase();
|
void syncedWithDatabase();
|
||||||
void synced();
|
void synced();
|
||||||
@@ -175,6 +177,7 @@ private:
|
|||||||
QString m_lastCmdGuid;
|
QString m_lastCmdGuid;
|
||||||
mutable QMutex m_cmdMutex;
|
mutable QMutex m_cmdMutex;
|
||||||
QMutex m_setControlConnectionMutex;
|
QMutex m_setControlConnectionMutex;
|
||||||
|
QMutex m_mutex;
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||||
};
|
};
|
||||||
|
@@ -100,6 +100,7 @@ ControlConnection::setup()
|
|||||||
|
|
||||||
// setup source and remote collection for this peer
|
// setup source and remote collection for this peer
|
||||||
m_source = SourceList::instance()->get( id(), friendlyName, true );
|
m_source = SourceList::instance()->get( id(), friendlyName, true );
|
||||||
|
QSharedPointer<QMutexLocker> locker = m_source->acquireLock();
|
||||||
if ( m_source->setControlConnection( this ) )
|
if ( m_source->setControlConnection( this ) )
|
||||||
{
|
{
|
||||||
// We are the new ControlConnection for this source
|
// We are the new ControlConnection for this source
|
||||||
@@ -129,13 +130,18 @@ ControlConnection::setup()
|
|||||||
void
|
void
|
||||||
ControlConnection::registerSource()
|
ControlConnection::registerSource()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << m_source->id();
|
QSharedPointer<QMutexLocker> locker = m_source->acquireLock();
|
||||||
Source* source = (Source*) sender();
|
// Only continue if we are still the ControlConnection associated with this source.
|
||||||
Q_UNUSED( source )
|
if ( m_source->controlConnection() == this )
|
||||||
Q_ASSERT( source == m_source.data() );
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << m_source->id();
|
||||||
|
Source* source = (Source*) sender();
|
||||||
|
Q_UNUSED( source )
|
||||||
|
Q_ASSERT( source == m_source.data() );
|
||||||
|
|
||||||
m_registered = true;
|
m_registered = true;
|
||||||
setupDbSyncConnection();
|
setupDbSyncConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user