mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 07:07:05 +02:00
* Use a QWeakPointer to guard Connection pointers.
This commit is contained in:
@@ -241,7 +241,7 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
|
|||||||
void
|
void
|
||||||
Servent::registerOffer( const QString& key, Connection* conn )
|
Servent::registerOffer( const QString& key, Connection* conn )
|
||||||
{
|
{
|
||||||
m_offers[key] = QPointer<Connection>(conn);
|
m_offers[key] = QWeakPointer<Connection>(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
|
|||||||
|
|
||||||
if( m_offers.contains( key ) )
|
if( m_offers.contains( key ) )
|
||||||
{
|
{
|
||||||
QPointer<Connection> conn = m_offers.value( key );
|
QWeakPointer<Connection> conn = m_offers.value( key );
|
||||||
if( conn.isNull() )
|
if( conn.isNull() )
|
||||||
{
|
{
|
||||||
// This can happen if it's a streamconnection, but the audioengine has
|
// This can happen if it's a streamconnection, but the audioengine has
|
||||||
@@ -642,21 +642,21 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
|
|||||||
if( !nodeid.isEmpty() )
|
if( !nodeid.isEmpty() )
|
||||||
{
|
{
|
||||||
// If there isn't a nodeid it's not the first connection and will already have been stopped
|
// If there isn't a nodeid it's not the first connection and will already have been stopped
|
||||||
if( !checkACL( conn, nodeid, true ) )
|
if( !checkACL( conn.data(), nodeid, true ) )
|
||||||
{
|
{
|
||||||
tLog() << "Connection not allowed due to ACL";
|
tLog() << "Connection not allowed due to ACL";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( conn->onceOnly() )
|
if( conn.data()->onceOnly() )
|
||||||
{
|
{
|
||||||
m_offers.remove( key );
|
m_offers.remove( key );
|
||||||
return conn.data();
|
return conn.data();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return conn->clone();
|
return conn.data()->clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( noauth )
|
else if ( noauth )
|
||||||
|
@@ -158,7 +158,7 @@ private:
|
|||||||
|
|
||||||
QJson::Parser parser;
|
QJson::Parser parser;
|
||||||
QList< ControlConnection* > m_controlconnections; // canonical list of authed peers
|
QList< ControlConnection* > m_controlconnections; // canonical list of authed peers
|
||||||
QMap< QString, QPointer<Connection> > m_offers;
|
QMap< QString, QWeakPointer<Connection> > m_offers;
|
||||||
int m_port, m_externalPort;
|
int m_port, m_externalPort;
|
||||||
QHostAddress m_externalAddress;
|
QHostAddress m_externalAddress;
|
||||||
QString m_externalHostname;
|
QString m_externalHostname;
|
||||||
|
Reference in New Issue
Block a user