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

* Further cleanups and fixed QPixmap warning: We need to store Source's QPixmaps as pointers, since a Source is being constructed in a thread.

This commit is contained in:
Christian Muehlhaeuser 2011-08-14 04:13:38 +02:00
parent 9ec9901e14
commit 37367bc5da
7 changed files with 22 additions and 17 deletions

View File

@ -78,8 +78,6 @@ PipelineStatusView::PipelineStatusView( AnimatedSplitter* parent )
void
PipelineStatusView::onPipelineUpdate( const query_ptr& query )
{
tDebug() << Q_FUNC_INFO << query.isNull();
QTreeWidgetItem* ti = m_tree->invisibleRootItem()->child( 0 );
if ( Pipeline::instance()->activeQueryCount() && !query.isNull() )

View File

@ -42,6 +42,8 @@ Source::Source( int id, const QString& username )
, m_username( username )
, m_id( id )
, m_cc( 0 )
, m_avatar( 0 )
, m_fancyAvatar( 0 )
{
qDebug() << Q_FUNC_INFO << id << username;
@ -62,6 +64,8 @@ Source::Source( int id, const QString& username )
Source::~Source()
{
qDebug() << Q_FUNC_INFO << friendlyName();
delete m_avatar;
delete m_fancyAvatar;
}
@ -122,22 +126,21 @@ Source::friendlyName() const
void
Source::setAvatar( const QPixmap& avatar )
{
m_avatar = avatar;
delete m_avatar;
m_avatar = new QPixmap( avatar );
}
QPixmap
Source::avatar( AvatarStyle style ) const
{
if ( style == FancyStyle &&
!m_avatar.isNull() &&
m_fancyAvatar.isNull() )
m_fancyAvatar = TomahawkUtils::createAvatarFrame( m_avatar );
if ( style == FancyStyle && m_avatar && !m_fancyAvatar )
m_fancyAvatar = new QPixmap( TomahawkUtils::createAvatarFrame( QPixmap( *m_avatar ) ) );
if ( style == Original && !m_avatar.isNull() )
return m_avatar;
else if ( style == FancyStyle && !m_fancyAvatar.isNull() )
return m_fancyAvatar;
if ( style == Original && m_avatar )
return QPixmap( *m_avatar );
else if ( style == FancyStyle && m_fancyAvatar )
return QPixmap( *m_fancyAvatar );
else
return QPixmap();
}

View File

@ -133,8 +133,8 @@ private:
ControlConnection* m_cc;
QPixmap m_avatar;
mutable QPixmap m_fancyAvatar;
QPixmap* m_avatar;
mutable QPixmap* m_fancyAvatar;
Tomahawk::playlistinterface_ptr m_playlistInterface;
};

View File

@ -85,6 +85,9 @@ TomahawkLogHandler( QtMsgType type, const char *msg )
{
static QMutex s_mutex;
if ( strstr( msg, "Pixmap" ) )
Q_ASSERT( false );
QMutexLocker locker( &s_mutex );
switch( type )
{

View File

@ -505,13 +505,15 @@ setNam( QNetworkAccessManager* nam )
s_nam = QWeakPointer< QNetworkAccessManager >( nam );
}
#ifndef Q_OS_MAC
void
bringToFront() {
bringToFront()
{
}
#endif
QPixmap
createAvatarFrame( const QPixmap &avatar )
{

View File

@ -89,7 +89,7 @@ namespace TomahawkUtils
/// Platform-specific bringing tomahawk mainwindow to front, b/c qt's activate() and such don't seem to work well enough for us
DLLEXPORT void bringToFront();
DLLEXPORT QPixmap createAvatarFrame(const QPixmap &avatar);
DLLEXPORT QPixmap createAvatarFrame( const QPixmap &avatar );
}
#endif // TOMAHAWKUTILS_H

View File

@ -46,7 +46,6 @@ CollectionItem::CollectionItem( SourcesModel* mdl, SourceTreeItem* parent, cons
, m_coolPlaylistsPage( 0 )
, m_lovedTracksPage( 0 )
{
m_lovedTracksItem = new GenericPageItem( model(), this, ( m_source.isNull() ? tr( "Top Loved Tracks" ) : tr( "Loved Tracks" ) ), QIcon( RESPATH "images/loved_playlist.png" ),
boost::bind( &CollectionItem::lovedTracksClicked, this ),
boost::bind( &CollectionItem::getLovedTracksPage, this )