1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

* Make Source::addCommand synchronous again, so we can rely on m_lastCmdGuid being set.

This commit is contained in:
Christian Muehlhaeuser
2012-06-20 19:34:51 +02:00
parent faf6374967
commit 056213bc27
2 changed files with 14 additions and 7 deletions

View File

@@ -408,14 +408,18 @@ Source::trackTimerFired()
} }
QString
Source::lastCmdGuid() const
{
QMutexLocker lock( &m_cmdMutex );
return m_lastCmdGuid;
}
void void
Source::addCommand( const QSharedPointer<DatabaseCommand>& command ) Source::addCommand( const QSharedPointer<DatabaseCommand>& command )
{ {
if ( QThread::currentThread() != thread() ) QMutexLocker lock( &m_cmdMutex );
{
QMetaObject::invokeMethod( this, "addCommand", Qt::QueuedConnection, Q_ARG( const QSharedPointer<DatabaseCommand>, command ) );
return;
}
m_cmds << command; m_cmds << command;
if ( !command->singletonCmd() ) if ( !command->singletonCmd() )
@@ -434,6 +438,8 @@ Source::executeCommands()
return; return;
} }
QMutexLocker lock( &m_cmdMutex );
if ( !m_cmds.isEmpty() ) if ( !m_cmds.isEmpty() )
{ {
QList< QSharedPointer<DatabaseCommand> > cmdGroup; QList< QSharedPointer<DatabaseCommand> > cmdGroup;

View File

@@ -117,7 +117,7 @@ public slots:
private slots: private slots:
void dbLoaded( unsigned int id, const QString& fname ); void dbLoaded( unsigned int id, const QString& fname );
QString lastCmdGuid() const { return m_lastCmdGuid; } QString lastCmdGuid() const;
void updateIndexWhenSynced(); void updateIndexWhenSynced();
void setOffline(); void setOffline();
@@ -138,7 +138,6 @@ private:
QList< QSharedPointer<Collection> > m_collections; QList< QSharedPointer<Collection> > m_collections;
QVariantMap m_stats; QVariantMap m_stats;
QString m_lastCmdGuid;
bool m_isLocal; bool m_isLocal;
bool m_online; bool m_online;
@@ -157,6 +156,8 @@ private:
ControlConnection* m_cc; ControlConnection* m_cc;
QList< QSharedPointer<DatabaseCommand> > m_cmds; QList< QSharedPointer<DatabaseCommand> > m_cmds;
int m_commandCount; int m_commandCount;
QString m_lastCmdGuid;
mutable QMutex m_cmdMutex;
mutable QPixmap* m_avatar; mutable QPixmap* m_avatar;
mutable QPixmap* m_fancyAvatar; mutable QPixmap* m_fancyAvatar;