diff --git a/src/libtomahawk/MetaPlaylistInterface.cpp b/src/libtomahawk/MetaPlaylistInterface.cpp index 98dc5626e..7d8940219 100644 --- a/src/libtomahawk/MetaPlaylistInterface.cpp +++ b/src/libtomahawk/MetaPlaylistInterface.cpp @@ -75,7 +75,7 @@ MetaPlaylistInterface::trackCount() const result_ptr MetaPlaylistInterface::currentItem() const { - if ( m_childInterfaces.count() ) + if ( m_childInterfaces.count() && m_childInterfaces.first() ) return m_childInterfaces.first()->currentItem(); else return Tomahawk::result_ptr(); diff --git a/src/libtomahawk/playlist/PlayableProxyModel.cpp b/src/libtomahawk/playlist/PlayableProxyModel.cpp index 542401b1a..453875577 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModel.cpp @@ -91,6 +91,15 @@ PlayableProxyModel::isLoading() const return false; } +QPersistentModelIndex +PlayableProxyModel::currentIndex() const +{ + if ( !m_model ) + return QPersistentModelIndex(); + + return mapFromSource( m_model->currentItem() ); +} + void PlayableProxyModel::setSourceModel( QAbstractItemModel* model ) diff --git a/src/libtomahawk/playlist/PlayableProxyModel.h b/src/libtomahawk/playlist/PlayableProxyModel.h index 121ad8f63..43154271b 100644 --- a/src/libtomahawk/playlist/PlayableProxyModel.h +++ b/src/libtomahawk/playlist/PlayableProxyModel.h @@ -52,7 +52,7 @@ public: PlayableProxyModel::PlayableItemStyle style() const { return m_style; } void setStyle( PlayableProxyModel::PlayableItemStyle style ) { m_style = style; } - virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); } + virtual QPersistentModelIndex currentIndex() const; virtual void setCurrentIndex( const QModelIndex& index ); virtual void removeIndex( const QModelIndex& index ); diff --git a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp index ae44b0356..e70f64eb8 100644 --- a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp @@ -262,7 +262,7 @@ PlayableProxyModelPlaylistInterface::currentItem() const PlayableProxyModel* proxyModel = m_proxyModel.data(); PlayableItem* item = proxyModel->itemFromIndex( proxyModel->mapToSource( proxyModel->currentIndex() ) ); - if ( item && !item->query().isNull() && item->query()->playable() ) + if ( item && item->query() && item->query()->playable() ) return item->query()->results().at( 0 ); return result_ptr();