From 85236c5c629a6318761c3313640f2b01c49d96d6 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Fri, 10 May 2013 10:02:35 +0200 Subject: [PATCH] Avoid crash in SuperCollection. --- src/libtomahawk/playlist/TreeProxyModel.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/playlist/TreeProxyModel.cpp b/src/libtomahawk/playlist/TreeProxyModel.cpp index d96afb879..4827a8377 100644 --- a/src/libtomahawk/playlist/TreeProxyModel.cpp +++ b/src/libtomahawk/playlist/TreeProxyModel.cpp @@ -27,6 +27,7 @@ #include "database/DatabaseImpl.h" #include "collection/AlbumsRequest.h" #include "collection/ArtistsRequest.h" +#include "database/DatabaseCommand_AllAlbums.h" #include "PlayableItem.h" #include "utils/Logger.h" @@ -73,7 +74,11 @@ TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int if ( pi->artist().isNull() ) return; - Tomahawk::AlbumsRequest* cmd = m_model->collection()->requestAlbums( pi->artist() ); + Tomahawk::AlbumsRequest* cmd = 0; + if ( !m_model->collection().isNull() ) + cmd = m_model->collection()->requestAlbums( pi->artist() ); + else + cmd = new DatabaseCommand_AllAlbums( Tomahawk::collection_ptr(), pi->artist() ); cmd->setFilter( m_filter ); @@ -115,7 +120,11 @@ TreeProxyModel::setFilter( const QString& pattern ) } else { - Tomahawk::ArtistsRequest* cmd = m_model->collection()->requestArtists(); + Tomahawk::ArtistsRequest* cmd = 0; + if ( !m_model->collection().isNull() ) + cmd = m_model->collection()->requestArtists(); + else + cmd = new DatabaseCommand_AllArtists(); //for SuperCollection, TODO: replace with a proper proxy-ArtistsRequest cmd->setFilter( pattern ); m_artistsFilterCmd = cmd;