From f4f37e5dfc4802fd7e97b7e55c1434d6fd857e8f Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Thu, 22 May 2014 01:33:58 +0100 Subject: [PATCH] Return QPointer instead of casting around --- src/libtomahawk-playdarapi/Api_v1_5.cpp | 2 +- src/libtomahawk/Pipeline.cpp | 2 +- src/libtomahawk/Result.cpp | 7 ++----- src/libtomahawk/Result.h | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libtomahawk-playdarapi/Api_v1_5.cpp b/src/libtomahawk-playdarapi/Api_v1_5.cpp index d23d45eea..c99f2dcf2 100644 --- a/src/libtomahawk-playdarapi/Api_v1_5.cpp +++ b/src/libtomahawk-playdarapi/Api_v1_5.cpp @@ -97,7 +97,7 @@ Api_v1_5::playback( QxtWebRequestEvent* event, const QString& command ) QVariantMap trackInfo; trackInfo.insert( "playing", true ); trackInfo.insert( "bitrate", currentTrack->bitrate() ); - if ( currentTrack->resolvedBy() != NULL ) { + if ( !currentTrack->resolvedBy().isNull() ) { QString resolverName = currentTrack->resolvedBy()->name(); trackInfo.insert( "resolvedBy", resolverName ); } else { diff --git a/src/libtomahawk/Pipeline.cpp b/src/libtomahawk/Pipeline.cpp index 44af7ee9e..17c6a6cf3 100644 --- a/src/libtomahawk/Pipeline.cpp +++ b/src/libtomahawk/Pipeline.cpp @@ -334,7 +334,7 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results ) return; if ( !d->qids.contains( qid ) ) { - if ( results.length() > 0 && results[0]->resolvedBy() != NULL ) + if ( results.length() > 0 && !results[0]->resolvedBy().isNull() ) { tDebug() << "Result arrived too late for:" << qid << "by" << results[0]->resolvedBy()->name(); } diff --git a/src/libtomahawk/Result.cpp b/src/libtomahawk/Result.cpp index 0ad7688c2..d9712d2ed 100644 --- a/src/libtomahawk/Result.cpp +++ b/src/libtomahawk/Result.cpp @@ -464,13 +464,10 @@ Result::setFileId( unsigned int id ) } -Tomahawk::Resolver* +QPointer Result::resolvedBy() const { - if ( m_resolvedBy.isNull() ) - return 0; - - return m_resolvedBy.data(); + return m_resolvedBy; } diff --git a/src/libtomahawk/Result.h b/src/libtomahawk/Result.h index dff8be0f3..acaedbc14 100644 --- a/src/libtomahawk/Result.h +++ b/src/libtomahawk/Result.h @@ -62,7 +62,7 @@ public: QString toString() const; Tomahawk::query_ptr toQuery(); - Tomahawk::Resolver* resolvedBy() const; + QPointer resolvedBy() const; void setResolvedBy( Tomahawk::Resolver* resolver ); float score() const;