diff --git a/src/libtomahawk/Source.cpp b/src/libtomahawk/Source.cpp index 7ce012cf4..5c4de0e1a 100644 --- a/src/libtomahawk/Source.cpp +++ b/src/libtomahawk/Source.cpp @@ -408,14 +408,18 @@ Source::trackTimerFired() } +QString +Source::lastCmdGuid() const +{ + QMutexLocker lock( &m_cmdMutex ); + return m_lastCmdGuid; +} + + void Source::addCommand( const QSharedPointer& command ) { - if ( QThread::currentThread() != thread() ) - { - QMetaObject::invokeMethod( this, "addCommand", Qt::QueuedConnection, Q_ARG( const QSharedPointer, command ) ); - return; - } + QMutexLocker lock( &m_cmdMutex ); m_cmds << command; if ( !command->singletonCmd() ) @@ -434,6 +438,8 @@ Source::executeCommands() return; } + QMutexLocker lock( &m_cmdMutex ); + if ( !m_cmds.isEmpty() ) { QList< QSharedPointer > cmdGroup; diff --git a/src/libtomahawk/Source.h b/src/libtomahawk/Source.h index bd463ae2a..3f7547586 100644 --- a/src/libtomahawk/Source.h +++ b/src/libtomahawk/Source.h @@ -117,7 +117,7 @@ public slots: private slots: void dbLoaded( unsigned int id, const QString& fname ); - QString lastCmdGuid() const { return m_lastCmdGuid; } + QString lastCmdGuid() const; void updateIndexWhenSynced(); void setOffline(); @@ -138,7 +138,6 @@ private: QList< QSharedPointer > m_collections; QVariantMap m_stats; - QString m_lastCmdGuid; bool m_isLocal; bool m_online; @@ -157,6 +156,8 @@ private: ControlConnection* m_cc; QList< QSharedPointer > m_cmds; int m_commandCount; + QString m_lastCmdGuid; + mutable QMutex m_cmdMutex; mutable QPixmap* m_avatar; mutable QPixmap* m_fancyAvatar;