1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +02:00

Proxy the QtConncurrent call to a static function to preserve a strong ref

This commit is contained in:
Uwe L. Korn
2013-06-09 19:24:41 +02:00
committed by Michael Zanetti
parent c3eca392f2
commit d3f32f73c9
2 changed files with 10 additions and 1 deletions

View File

@@ -82,7 +82,7 @@ void
ConnectionManager::handleSipInfo( const Tomahawk::peerinfo_ptr &peerInfo )
{
// Start handling in a separate thread so that we do not block the event loop.
QtConcurrent::run( this, &ConnectionManager::handleSipInfoPrivate, peerInfo );
QtConcurrent::run( &ConnectionManager::handleSipInfoPrivateS, peerInfo, weakRef().toStrongRef() );
}
QWeakPointer<ConnectionManager>
@@ -264,6 +264,12 @@ ConnectionManager::socketError( QAbstractSocket::SocketError error )
tryConnect();
}
void
ConnectionManager::handleSipInfoPrivateS( const Tomahawk::peerinfo_ptr &peerInfo, const QSharedPointer<ConnectionManager> &connectionManager )
{
connectionManager->handleSipInfoPrivate( peerInfo );
}
void
ConnectionManager::activate()
{

View File

@@ -53,6 +53,9 @@ private:
Q_DECLARE_PRIVATE( ConnectionManager )
ConnectionManagerPrivate* d_ptr;
// Proxy to hand over a strong reference to the connectionManager
static void handleSipInfoPrivateS( const Tomahawk::peerinfo_ptr& peerInfo, const QSharedPointer<ConnectionManager>& connectionManager );
void activate();
void deactivate();
void connectToPeer(const Tomahawk::peerinfo_ptr& peerInfo , bool lock);