diff --git a/src/libtomahawk/playlist/GridItemDelegate.cpp b/src/libtomahawk/playlist/GridItemDelegate.cpp index 66472f2d6..24850f7cf 100644 --- a/src/libtomahawk/playlist/GridItemDelegate.cpp +++ b/src/libtomahawk/playlist/GridItemDelegate.cpp @@ -122,8 +122,8 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), r.size(), TomahawkUtils::Grid ) ) ); } - _detail::Closure* closure = NewClosure( m_covers[ index ], SIGNAL( repaintRequest() ), const_cast(this), SLOT( doUpdateIndex( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); - closure->setAutoDelete( false ); + NewClosure( m_covers[ index ], SIGNAL( repaintRequest() ), + const_cast(this), SLOT( doUpdateIndex( QPersistentModelIndex ) ), QPersistentModelIndex( index ) )->setAutoDelete( false ); } QSharedPointer< Tomahawk::PixmapDelegateFader > fader = m_covers[ index ]; @@ -243,17 +243,18 @@ GridItemDelegate::onPlayClicked( const QPersistentModelIndex& index ) PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) ); if ( item ) { - _detail::Closure* closure; + NewClosure( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), + const_cast(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); - closure = NewClosure( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), - const_cast(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); + m_closures.remove( index ); - closure = NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), - const_cast(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); - closure = NewClosure( AudioEngine::instance(), SIGNAL( stopped() ), - const_cast(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ); + m_closures.insertMulti( index, NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), + const_cast(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ) ); + m_closures.insertMulti( index, NewClosure( AudioEngine::instance(), SIGNAL( stopped() ), + const_cast(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ) ); - closure->setAutoDelete( false ); + foreach ( _detail::Closure* closure, m_closures.values( index ) ) + closure->setAutoDelete( false ); connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackFinished() ) ); @@ -485,6 +486,9 @@ GridItemDelegate::onPlaylistChanged( const QPersistentModelIndex& index ) if ( finished ) { + foreach ( _detail::Closure* closure, m_closures.values( index ) ) + closure->deleteLater(); + if ( m_pauseButton.contains( index ) ) { m_pauseButton[ index ]->deleteLater(); diff --git a/src/libtomahawk/playlist/GridItemDelegate.h b/src/libtomahawk/playlist/GridItemDelegate.h index 7409f0fdd..b05b171a3 100644 --- a/src/libtomahawk/playlist/GridItemDelegate.h +++ b/src/libtomahawk/playlist/GridItemDelegate.h @@ -29,6 +29,10 @@ namespace Tomahawk { class PixmapDelegateFader; } +namespace _detail { + class Closure; +} + class QEvent; class QTimeLine; class PlayableProxyModel; @@ -86,8 +90,8 @@ private: mutable QHash< QPersistentModelIndex, QWidget* > m_spinner; mutable QHash< QPersistentModelIndex, ImageButton* > m_playButton; mutable QHash< QPersistentModelIndex, ImageButton* > m_pauseButton; - mutable QHash< QPersistentModelIndex, QTimeLine* > m_hoverFaders; + mutable QHash< QPersistentModelIndex, _detail::Closure* > m_closures; }; #endif // GRIDITEMDELEGATE_H