1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01:00

* Fixed creating QPixmaps in the wrong thread.

This commit is contained in:
Christian Muehlhaeuser 2013-06-07 11:27:58 +02:00
parent b291788a2e
commit 21d4f2b83a
2 changed files with 12 additions and 4 deletions

View File

@ -57,6 +57,7 @@ Source::Source( int id, const QString& nodeId )
, m_id( id )
, m_updateIndexWhenSynced( false )
, m_state( DBSyncConnection::UNKNOWN )
, m_avatar( 0 )
, m_avatarLoaded( false )
, m_cc( 0 )
, m_commandCount( 0 )
@ -261,7 +262,12 @@ Source::avatar( TomahawkUtils::ImageMode style, const QSize& size )
}
if ( m_avatarLoaded )
return m_avatar;
{
if ( m_avatar )
return *m_avatar;
else
return QPixmap();
}
// Try to get the avatar from the cache
// Hint: We store the avatar for each xmpp peer using its contactId, the dbFriendlyName is a contactId of a peer
@ -269,14 +275,16 @@ Source::avatar( TomahawkUtils::ImageMode style, const QSize& size )
QByteArray avatarBuffer = TomahawkUtils::Cache::instance()->getData( "Sources", dbFriendlyName() ).toByteArray();
if ( !avatarBuffer.isNull() )
{
tDebug() << Q_FUNC_INFO << QThread::currentThread();
QPixmap avatar;
avatar.loadFromData( avatarBuffer );
avatarBuffer.clear();
m_avatar = QPixmap( TomahawkUtils::createRoundedImage( avatar, QSize( 0, 0 ) ) );
m_avatar = new QPixmap( TomahawkUtils::createRoundedImage( avatar, QSize( 0, 0 ) ) );
return *m_avatar;
}
return m_avatar;
return QPixmap();
}
#endif

View File

@ -171,7 +171,7 @@ private:
DBSyncConnection::State m_state;
QTimer m_currentTrackTimer;
QPixmap m_avatar;
QPixmap* m_avatar;
bool m_avatarLoaded;
QPointer<ControlConnection> m_cc;