1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

Don't always emit a new nam for plugins when it hasn't actually changed

This commit is contained in:
Jeff Mitchell 2011-11-03 16:43:53 -04:00
parent 663752010c
commit 3523609cad
3 changed files with 25 additions and 6 deletions

View File

@ -361,18 +361,26 @@ InfoSystemWorker::nam() const
void
InfoSystemWorker::newNam()
{
// qDebug() << Q_FUNC_INFO << " begin";
QNetworkAccessManager *oldNam = TomahawkUtils::nam();
if ( oldNam && oldNam->thread() == thread() )
{
// qDebug() << Q_FUNC_INFO << "Using old nam as it's the same thread (GUI) as me";
m_nam = QWeakPointer< QNetworkAccessManager >( oldNam );
emit namChanged( m_nam.data() );
if ( m_nam.data() != oldNam )
{
m_nam = QWeakPointer< QNetworkAccessManager >( oldNam );
emit namChanged( m_nam.data() );
}
return;
}
// qDebug() << Q_FUNC_INFO << "No nam exists, or it's a different thread, creating a new one";
if (
oldNam &&
!m_nam.isNull() &&
oldNam->configuration() == m_nam.data()->configuration() &&
oldNam->networkAccessible() == m_nam.data()->networkAccessible() &&
oldNam->proxyFactory() == m_nam.data()->proxyFactory()
)
return;
QNetworkAccessManager* newNam;
#ifdef LIBLASTFM_FOUND
newNam = new lastfm::NetworkAccessManager( this );

View File

@ -513,6 +513,15 @@ NetworkProxyFactory::setProxy( const QNetworkProxy& proxy )
}
bool NetworkProxyFactory::operator==( const NetworkProxyFactory& other )
{
if ( m_noProxyHosts != other.m_noProxyHosts or m_proxy != other.m_proxy )
return false;
return true;
}
NetworkProxyFactory*
proxyFactory()
{

View File

@ -65,6 +65,8 @@ namespace TomahawkUtils
void setProxy( const QNetworkProxy &proxy );
QNetworkProxy proxy() { return m_proxy; }
bool operator==( const NetworkProxyFactory &other );
private:
QStringList m_noProxyHosts;
QNetworkProxy m_proxy;