From 2142a04fda382e3580ea68e0c292d58c2b4a2a2c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 10 Jul 2012 23:27:14 -0400 Subject: [PATCH] Increased pointer safety (oops 19336) --- src/libtomahawk/DropJob.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/DropJob.cpp b/src/libtomahawk/DropJob.cpp index 5f1cea4bd..ee8b5f791 100644 --- a/src/libtomahawk/DropJob.cpp +++ b/src/libtomahawk/DropJob.cpp @@ -699,8 +699,21 @@ DropJob::removeDuplicates() foreach ( const Tomahawk::query_ptr& item, m_resultList ) { bool contains = false; + Q_ASSERT( !item.isNull() ); + if ( item.isNull() ) + { + m_resultList.removeOne( item ); + continue; + } + foreach( const Tomahawk::query_ptr &tmpItem, list ) { + if ( tmpItem.isNull() ) + { + list.removeOne( tmpItem ); + continue; + } + if ( item->album() == tmpItem->album() && item->artist() == tmpItem->artist() && item->track() == tmpItem->track() ) @@ -726,10 +739,18 @@ DropJob::removeRemoteSources() QList< Tomahawk::query_ptr > list; foreach ( const Tomahawk::query_ptr& item, m_resultList ) { + Q_ASSERT( !item.isNull() ); + if ( item.isNull() ) + { + m_resultList.removeOne( item ); + continue; + } + bool hasLocalSource = false; foreach ( const Tomahawk::result_ptr& result, item->results() ) { - if ( !result->collection()->source().isNull() && result->collection()->source()->isLocal() ) + if ( !result->collection().isNull() && !result->collection()->source().isNull() && + !result->collection()->source().isNull() && result->collection()->source()->isLocal() ) hasLocalSource = true; } if ( hasLocalSource )