From 539f2eb7005a6e35b7b38d7175404aae1730d258 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell <tomahawk@jefferai.org> Date: Tue, 8 Nov 2011 04:52:06 -0500 Subject: [PATCH] Proxies are all we really set on nams, so reset proxy data on all threads when the main thread's nam changes --- src/libtomahawk/utils/tomahawkutils.cpp | 9 +++++++-- src/libtomahawk/utils/tomahawkutils.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp index 43b698e6d..c62a7d8e3 100644 --- a/src/libtomahawk/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -575,10 +575,12 @@ proxyFactory( bool noMutexLocker ) void -setProxyFactory( NetworkProxyFactory* factory ) +setProxyFactory( NetworkProxyFactory* factory, bool noMutexLocker ) { Q_ASSERT( factory ); - QMutexLocker locker( &s_namAccessMutex ); + // Don't lock if being called from setNam() + QMutex otherMutex; + QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex ); if ( !s_threadProxyFactoryHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) ) return; @@ -662,6 +664,9 @@ setNam( QNetworkAccessManager* nam ) } s_threadNamHash[ QThread::currentThread() ] = nam; + + if ( QThread::currentThread() == TOMAHAWK_APPLICATION::instance()->thread() ) + setProxyFactory( dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( nam->proxyFactory() ), true ); } diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h index d8b034adf..028e55f27 100644 --- a/src/libtomahawk/utils/tomahawkutils.h +++ b/src/libtomahawk/utils/tomahawkutils.h @@ -97,7 +97,7 @@ namespace TomahawkUtils DLLEXPORT NetworkProxyFactory* proxyFactory( bool noMutexLocker = false ); DLLEXPORT QNetworkAccessManager* nam(); - DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory ); + DLLEXPORT void setProxyFactory( TomahawkUtils::NetworkProxyFactory* factory, bool noMutexLocker = false ); DLLEXPORT void setNam( QNetworkAccessManager* nam ); DLLEXPORT QWidget* tomahawkWindow();