1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 14:28:24 +01:00

Store Result's own weakref, so it can convert back to the existing sharedptr from itself.

This commit is contained in:
Christian Muehlhaeuser 2014-11-06 06:05:21 +01:00
parent bb1e856955
commit 5f393ebc3d
2 changed files with 21 additions and 2 deletions

View File

@ -69,6 +69,7 @@ Result::get( const QString& url, const track_ptr& track )
}
result_ptr r = result_ptr( new Result( url, track ), &Result::deleteLater );
r->setWeakRef( r.toWeakRef() );
s_results.insert( url, r );
return r;
@ -271,8 +272,7 @@ Result::toQuery()
m_query = query->weakRef();
QList<Tomahawk::result_ptr> rl;
rl << Result::get( m_url, m_track );
rl << weakRef().toStrongRef();
query->addResults( rl );
query->setResolveFinished( true );
return query;
@ -518,3 +518,18 @@ Result::track() const
{
return m_track;
}
QWeakPointer<Result>
Result::weakRef()
{
return m_ownRef;
}
void
Result::setWeakRef( QWeakPointer<Result> weakRef )
{
m_ownRef = weakRef;
}

View File

@ -64,6 +64,9 @@ public:
virtual ~Result();
QWeakPointer< Tomahawk::Result > weakRef();
void setWeakRef( QWeakPointer< Tomahawk::Result > weakRef );
QVariant toVariant() const;
QString toString() const;
Tomahawk::query_ptr toQuery();
@ -159,6 +162,7 @@ private:
track_ptr m_track;
query_wptr m_query;
QWeakPointer< Tomahawk::Result > m_ownRef;
};
} //ns