From d7a925d11003bbfbb3d8aafb7dbe86c50c4537e7 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 23 May 2012 12:31:00 -0400 Subject: [PATCH] Make init methods for all infoplugins to solve issues with network traffic before they're in the right thread --- src/accounts/lastfm/LastFmAccount.cpp | 1 - src/accounts/lastfm/LastFmInfoPlugin.h | 2 +- src/accounts/twitter/TwitterAccount.cpp | 1 - src/accounts/twitter/TwitterInfoPlugin.h | 2 +- src/accounts/xmpp/XmppInfoPlugin.h | 2 +- src/accounts/xmpp/sip/XmppSip.cpp | 1 - .../generic/charts/ChartsPlugin.cpp | 35 ++++++++++++------- src/infoplugins/generic/charts/ChartsPlugin.h | 1 + .../generic/echonest/EchonestPlugin.cpp | 8 ++++- .../generic/echonest/EchonestPlugin.h | 2 ++ src/infoplugins/generic/hypem/HypemPlugin.cpp | 9 +++-- src/infoplugins/generic/hypem/HypemPlugin.h | 1 + .../generic/musicbrainz/MusicBrainzPlugin.h | 1 + .../generic/musixmatch/MusixMatchPlugin.h | 1 + .../generic/newreleases/NewReleasesPlugin.cpp | 15 +++++--- .../generic/newreleases/NewReleasesPlugin.h | 1 + src/infoplugins/generic/rovi/RoviPlugin.h | 2 ++ .../generic/spotify/SpotifyPlugin.h | 1 + .../linux/fdonotify/FdoNotifyPlugin.h | 2 ++ src/infoplugins/linux/mpris/MprisPlugin.cpp | 15 +++++--- src/infoplugins/linux/mpris/MprisPlugin.h | 2 ++ src/infoplugins/mac/adium/AdiumPlugin.h | 2 ++ src/libtomahawk/infosystem/InfoSystem.h | 12 +++++++ .../infosystem/InfoSystemWorker.cpp | 2 ++ src/libtomahawk/utils/TomahawkUtils.cpp | 9 ++++- 25 files changed, 97 insertions(+), 33 deletions(-) diff --git a/src/accounts/lastfm/LastFmAccount.cpp b/src/accounts/lastfm/LastFmAccount.cpp index 25364e3e3..7cfbd8924 100644 --- a/src/accounts/lastfm/LastFmAccount.cpp +++ b/src/accounts/lastfm/LastFmAccount.cpp @@ -75,7 +75,6 @@ LastFmAccount::LastFmAccount( const QString& accountId ) { infoPlugin().data()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ); Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() ); - QMetaObject::invokeMethod( infoPlugin().data(), "init", Qt::QueuedConnection ); } } diff --git a/src/accounts/lastfm/LastFmInfoPlugin.h b/src/accounts/lastfm/LastFmInfoPlugin.h index 443192b03..0e5024fee 100644 --- a/src/accounts/lastfm/LastFmInfoPlugin.h +++ b/src/accounts/lastfm/LastFmInfoPlugin.h @@ -51,7 +51,6 @@ public: virtual ~LastFmInfoPlugin(); public slots: - void init(); void settingsChanged(); void onAuthenticated(); @@ -63,6 +62,7 @@ public slots: void similarTracksReturned(); protected slots: + virtual void init(); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); diff --git a/src/accounts/twitter/TwitterAccount.cpp b/src/accounts/twitter/TwitterAccount.cpp index 91dce3ca1..852968c31 100644 --- a/src/accounts/twitter/TwitterAccount.cpp +++ b/src/accounts/twitter/TwitterAccount.cpp @@ -130,7 +130,6 @@ TwitterAccount::authenticateSlot() { infoPlugin().data()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ); Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() ); - QMetaObject::invokeMethod( infoPlugin().data(), "init", Qt::QueuedConnection ); } } diff --git a/src/accounts/twitter/TwitterInfoPlugin.h b/src/accounts/twitter/TwitterInfoPlugin.h index e1b221105..0919515b7 100644 --- a/src/accounts/twitter/TwitterInfoPlugin.h +++ b/src/accounts/twitter/TwitterInfoPlugin.h @@ -44,7 +44,6 @@ namespace Tomahawk { virtual ~TwitterInfoPlugin(); public slots: - void init(); void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) { Q_UNUSED( criteria ); @@ -52,6 +51,7 @@ namespace Tomahawk { } protected slots: + void init(); void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ); void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) { diff --git a/src/accounts/xmpp/XmppInfoPlugin.h b/src/accounts/xmpp/XmppInfoPlugin.h index f553b43d0..cbb248e6d 100644 --- a/src/accounts/xmpp/XmppInfoPlugin.h +++ b/src/accounts/xmpp/XmppInfoPlugin.h @@ -42,10 +42,10 @@ namespace Tomahawk { void publishTune( QUrl url, Tomahawk::InfoSystem::InfoStringHash trackInfo ); public slots: - void init(); void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); protected slots: + void init(); void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ); void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); diff --git a/src/accounts/xmpp/sip/XmppSip.cpp b/src/accounts/xmpp/sip/XmppSip.cpp index 6330d39c8..036d1f1be 100644 --- a/src/accounts/xmpp/sip/XmppSip.cpp +++ b/src/accounts/xmpp/sip/XmppSip.cpp @@ -293,7 +293,6 @@ XmppSipPlugin::onConnect() { infoPlugin().data()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ); Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() ); - QMetaObject::invokeMethod( infoPlugin().data(), "init", Qt::QueuedConnection ); } //FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P diff --git a/src/infoplugins/generic/charts/ChartsPlugin.cpp b/src/infoplugins/generic/charts/ChartsPlugin.cpp index 3a3433fb4..20123c997 100644 --- a/src/infoplugins/generic/charts/ChartsPlugin.cpp +++ b/src/infoplugins/generic/charts/ChartsPlugin.cpp @@ -52,8 +52,23 @@ ChartsPlugin::ChartsPlugin() : InfoPlugin() , m_chartsFetchJobs( 0 ) { + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QThread::currentThread(); /// If you add resource, update version aswell m_chartVersion = "2.3"; + m_supportedGetTypes << InfoChart << InfoChartCapabilities; +} + + +ChartsPlugin::~ChartsPlugin() +{ + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QThread::currentThread(); +} + + +void +ChartsPlugin::init() +{ + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << QThread::currentThread(); QVariantList source_qvarlist = TomahawkUtils::Cache::instance()->getData( "ChartsPlugin", "chart_sources" ).toList(); foreach( const QVariant & source, source_qvarlist ) { m_chartResources.append( source.toString() ); @@ -63,14 +78,6 @@ ChartsPlugin::ChartsPlugin() tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "total sources" << m_chartResources.size() << source_qvarlist.size(); if( m_chartResources.size() == 0 ) fetchChartSourcesList( true ); - m_supportedGetTypes << InfoChart << InfoChartCapabilities; - -} - - -ChartsPlugin::~ChartsPlugin() -{ - tDebug( LOGVERBOSE ) << Q_FUNC_INFO; } @@ -219,7 +226,7 @@ ChartsPlugin::fetchChartSourcesList( bool fetchOnlySourceList ) reply->setProperty( "only_source_list", fetchOnlySourceList ); - tDebug() << "fetching:" << url; + tDebug() << Q_FUNC_INFO << "fetching:" << url; connect( reply, SIGNAL( finished() ), SLOT( chartSourcesList() ) ); } @@ -227,7 +234,7 @@ ChartsPlugin::fetchChartSourcesList( bool fetchOnlySourceList ) void ChartsPlugin::chartSourcesList() { - tDebug( LOGVERBOSE ) << "Got chart sources list"; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Got chart sources list"; QNetworkReply* reply = qobject_cast( sender() ); if ( reply->error() == QNetworkReply::NoError ) @@ -239,7 +246,7 @@ ChartsPlugin::chartSourcesList() if ( !ok ) { - tLog() << "Failed to parse sources" << p.errorString() << "On line" << p.errorLine(); + tLog() << Q_FUNC_INFO << "Failed to parse sources" << p.errorString() << "On line" << p.errorLine(); return; } @@ -253,6 +260,8 @@ ChartsPlugin::chartSourcesList() if( !reply->property("only_source_list" ).toBool() ) fetchAllChartSources(); } + else + tDebug() << Q_FUNC_INFO << "Encountered error fetching chart sources list"; } void ChartsPlugin::fetchAllChartSources() @@ -266,7 +275,7 @@ void ChartsPlugin::fetchAllChartSources() QNetworkReply* reply = TomahawkUtils::nam()->get( QNetworkRequest( url ) ); reply->setProperty( "chart_source", source); - tDebug() << "fetching:" << url; + tDebug() << Q_FUNC_INFO << "fetching:" << url; connect( reply, SIGNAL( finished() ), SLOT( chartsList() ) ); m_chartsFetchJobs++; @@ -291,7 +300,7 @@ void ChartsPlugin::fetchChart( Tomahawk::InfoSystem::InfoRequestData requestData void ChartsPlugin::chartsList() { - tDebug( LOGVERBOSE ) << "Got chart list result"; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Got chart list result"; QNetworkReply* reply = qobject_cast( sender() ); if ( reply->error() == QNetworkReply::NoError ) diff --git a/src/infoplugins/generic/charts/ChartsPlugin.h b/src/infoplugins/generic/charts/ChartsPlugin.h index d521bb19a..bc0fbacfe 100644 --- a/src/infoplugins/generic/charts/ChartsPlugin.h +++ b/src/infoplugins/generic/charts/ChartsPlugin.h @@ -55,6 +55,7 @@ public: ChartType chartType() const { return m_chartType; } protected slots: + virtual void init(); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); diff --git a/src/infoplugins/generic/echonest/EchonestPlugin.cpp b/src/infoplugins/generic/echonest/EchonestPlugin.cpp index f1d28b89a..b0e1ec65c 100644 --- a/src/infoplugins/generic/echonest/EchonestPlugin.cpp +++ b/src/infoplugins/generic/echonest/EchonestPlugin.cpp @@ -39,7 +39,6 @@ EchonestPlugin::EchonestPlugin() { qDebug() << Q_FUNC_INFO; m_supportedGetTypes << Tomahawk::InfoSystem::InfoArtistBiography << Tomahawk::InfoSystem::InfoArtistFamiliarity << Tomahawk::InfoSystem::InfoArtistHotttness << Tomahawk::InfoSystem::InfoArtistTerms << Tomahawk::InfoSystem::InfoMiscTopTerms; - Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() ); } @@ -49,6 +48,13 @@ EchonestPlugin::~EchonestPlugin() } +void +EchonestPlugin::init() +{ + Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() ); +} + + void EchonestPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) { diff --git a/src/infoplugins/generic/echonest/EchonestPlugin.h b/src/infoplugins/generic/echonest/EchonestPlugin.h index 4468c375c..bdd4e6a3a 100644 --- a/src/infoplugins/generic/echonest/EchonestPlugin.h +++ b/src/infoplugins/generic/echonest/EchonestPlugin.h @@ -45,6 +45,8 @@ public: virtual ~EchonestPlugin(); protected slots: + virtual void init(); + virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) diff --git a/src/infoplugins/generic/hypem/HypemPlugin.cpp b/src/infoplugins/generic/hypem/HypemPlugin.cpp index 20d92962b..4827d425c 100644 --- a/src/infoplugins/generic/hypem/HypemPlugin.cpp +++ b/src/infoplugins/generic/hypem/HypemPlugin.cpp @@ -95,8 +95,6 @@ HypemPlugin::HypemPlugin() << "Techno" << "Punk" << "New wave"; - chartTypes(); - } @@ -108,6 +106,13 @@ HypemPlugin::~HypemPlugin() } +void +HypemPlugin::init() +{ + chartTypes(); +} + + void HypemPlugin::dataError( Tomahawk::InfoSystem::InfoRequestData requestData ) { diff --git a/src/infoplugins/generic/hypem/HypemPlugin.h b/src/infoplugins/generic/hypem/HypemPlugin.h index 1848bd99e..63fc2f4c8 100644 --- a/src/infoplugins/generic/hypem/HypemPlugin.h +++ b/src/infoplugins/generic/hypem/HypemPlugin.h @@ -58,6 +58,7 @@ public slots: void chartTypes(); protected slots: + virtual void init(); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) diff --git a/src/infoplugins/generic/musicbrainz/MusicBrainzPlugin.h b/src/infoplugins/generic/musicbrainz/MusicBrainzPlugin.h index 17c57faf9..21043caeb 100644 --- a/src/infoplugins/generic/musicbrainz/MusicBrainzPlugin.h +++ b/src/infoplugins/generic/musicbrainz/MusicBrainzPlugin.h @@ -42,6 +42,7 @@ public: virtual ~MusicBrainzPlugin(); protected slots: + virtual void init() {} virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void notInCacheSlot( InfoStringHash criteria, InfoRequestData requestData ); diff --git a/src/infoplugins/generic/musixmatch/MusixMatchPlugin.h b/src/infoplugins/generic/musixmatch/MusixMatchPlugin.h index 3f3557f8a..5c17c0c75 100644 --- a/src/infoplugins/generic/musixmatch/MusixMatchPlugin.h +++ b/src/infoplugins/generic/musixmatch/MusixMatchPlugin.h @@ -46,6 +46,7 @@ public slots: void trackLyricsSlot(); protected slots: + virtual void init() {} virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) diff --git a/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp b/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp index 9d3c7cece..54910bf49 100644 --- a/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp +++ b/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp @@ -30,6 +30,16 @@ NewReleasesPlugin::NewReleasesPlugin() { m_nrVersion = "0"; m_supportedGetTypes << InfoNewReleaseCapabilities << InfoNewRelease; +} + +NewReleasesPlugin::~NewReleasesPlugin() +{ + tDebug ( LOGVERBOSE ) << Q_FUNC_INFO; +} + +void +NewReleasesPlugin::init() +{ QVariantList source_qvarlist = TomahawkUtils::Cache::instance()->getData( "NewReleasesPlugin", "nr_sources" ).toList(); foreach( const QVariant & source, source_qvarlist ) { m_nrSources.append( source.toString() ); @@ -41,11 +51,6 @@ NewReleasesPlugin::NewReleasesPlugin() fetchNRSourcesList( true ); } -NewReleasesPlugin::~NewReleasesPlugin() -{ - tDebug ( LOGVERBOSE ) << Q_FUNC_INFO; -} - void NewReleasesPlugin::dataError ( InfoRequestData requestData ) { emit info ( requestData, QVariant() ); diff --git a/src/infoplugins/generic/newreleases/NewReleasesPlugin.h b/src/infoplugins/generic/newreleases/NewReleasesPlugin.h index 3c355a577..85b24c31d 100644 --- a/src/infoplugins/generic/newreleases/NewReleasesPlugin.h +++ b/src/infoplugins/generic/newreleases/NewReleasesPlugin.h @@ -44,6 +44,7 @@ public: virtual ~NewReleasesPlugin(); protected slots: + virtual void init(); virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); diff --git a/src/infoplugins/generic/rovi/RoviPlugin.h b/src/infoplugins/generic/rovi/RoviPlugin.h index 5c782edb2..b54c3577a 100644 --- a/src/infoplugins/generic/rovi/RoviPlugin.h +++ b/src/infoplugins/generic/rovi/RoviPlugin.h @@ -43,6 +43,8 @@ public: virtual ~RoviPlugin(); protected: + virtual void init() {} + virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) diff --git a/src/infoplugins/generic/spotify/SpotifyPlugin.h b/src/infoplugins/generic/spotify/SpotifyPlugin.h index e20e69aeb..c21600090 100644 --- a/src/infoplugins/generic/spotify/SpotifyPlugin.h +++ b/src/infoplugins/generic/spotify/SpotifyPlugin.h @@ -59,6 +59,7 @@ public slots: void chartTypes(); protected slots: + virtual void init() {} virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ); virtual void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) diff --git a/src/infoplugins/linux/fdonotify/FdoNotifyPlugin.h b/src/infoplugins/linux/fdonotify/FdoNotifyPlugin.h index fc56e6267..fc672c00a 100644 --- a/src/infoplugins/linux/fdonotify/FdoNotifyPlugin.h +++ b/src/infoplugins/linux/fdonotify/FdoNotifyPlugin.h @@ -39,6 +39,8 @@ public: virtual ~FdoNotifyPlugin(); protected slots: + virtual void init() {} + virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) { Q_UNUSED( requestData ); diff --git a/src/infoplugins/linux/mpris/MprisPlugin.cpp b/src/infoplugins/linux/mpris/MprisPlugin.cpp index 02de7e158..8f8f6610b 100644 --- a/src/infoplugins/linux/mpris/MprisPlugin.cpp +++ b/src/infoplugins/linux/mpris/MprisPlugin.cpp @@ -54,7 +54,17 @@ MprisPlugin::MprisPlugin() // Types of pushInfo we care about m_supportedPushTypes << InfoNowPlaying << InfoNowPaused << InfoNowResumed << InfoNowStopped; +} + +MprisPlugin::~MprisPlugin() +{ +} + + +void +MprisPlugin::init() +{ // DBus connection new MprisPluginRootAdaptor( this ); new MprisPluginPlayerAdaptor( this ); @@ -84,11 +94,6 @@ MprisPlugin::MprisPlugin() } -MprisPlugin::~MprisPlugin() -{ -} - - // org.mpris.MediaPlayer2 bool diff --git a/src/infoplugins/linux/mpris/MprisPlugin.h b/src/infoplugins/linux/mpris/MprisPlugin.h index 9e4d54e04..8a11fc1d4 100644 --- a/src/infoplugins/linux/mpris/MprisPlugin.h +++ b/src/infoplugins/linux/mpris/MprisPlugin.h @@ -142,6 +142,8 @@ public slots: void Stop(); protected slots: + virtual void init(); + virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) { Q_UNUSED( requestData ); diff --git a/src/infoplugins/mac/adium/AdiumPlugin.h b/src/infoplugins/mac/adium/AdiumPlugin.h index a05b0863b..a4d3d50bf 100644 --- a/src/infoplugins/mac/adium/AdiumPlugin.h +++ b/src/infoplugins/mac/adium/AdiumPlugin.h @@ -44,6 +44,8 @@ public: virtual ~AdiumPlugin(); protected slots: + virtual void init() {} + virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) { Q_UNUSED( requestData ); diff --git a/src/libtomahawk/infosystem/InfoSystem.h b/src/libtomahawk/infosystem/InfoSystem.h index 00a316718..324c1e352 100644 --- a/src/libtomahawk/infosystem/InfoSystem.h +++ b/src/libtomahawk/infosystem/InfoSystem.h @@ -101,6 +101,10 @@ class DLLEXPORT InfoPlugin : public QObject Q_OBJECT public: + /** + * @brief Creates the plugin. Do *not* perform any network-based setup tasks here; defer that to init(), which will be called automatically. + * + **/ InfoPlugin(); virtual ~InfoPlugin(); @@ -115,6 +119,14 @@ signals: void updateCache( Tomahawk::InfoSystem::InfoStringHash criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output ); protected slots: + + /** + * @brief Called after the plugin has been moved to the appropriate thread. Do network-based setup tasks here. + * + * @return void + **/ + virtual void init() = 0; + virtual void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ) = 0; virtual void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) = 0; virtual void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) = 0; diff --git a/src/libtomahawk/infosystem/InfoSystemWorker.cpp b/src/libtomahawk/infosystem/InfoSystemWorker.cpp index f84b55bbd..f52ba8729 100644 --- a/src/libtomahawk/infosystem/InfoSystemWorker.cpp +++ b/src/libtomahawk/infosystem/InfoSystemWorker.cpp @@ -122,6 +122,8 @@ InfoSystemWorker::addInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin ) SLOT( updateCacheSlot( Tomahawk::InfoSystem::InfoStringHash, qint64, Tomahawk::InfoSystem::InfoType, QVariant ) ), Qt::QueuedConnection ); + + QMetaObject::invokeMethod( plugin.data(), "init", Qt::QueuedConnection ); } diff --git a/src/libtomahawk/utils/TomahawkUtils.cpp b/src/libtomahawk/utils/TomahawkUtils.cpp index 5adba5422..e6596cfb3 100644 --- a/src/libtomahawk/utils/TomahawkUtils.cpp +++ b/src/libtomahawk/utils/TomahawkUtils.cpp @@ -464,7 +464,10 @@ nam() { QMutexLocker locker( &s_namAccessMutex ); if ( s_threadNamHash.contains( QThread::currentThread() ) ) + { + //tDebug() << Q_FUNC_INFO << "Found current thread in nam hash"; return s_threadNamHash[ QThread::currentThread() ]; + } if ( !s_threadNamHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) ) { @@ -476,6 +479,7 @@ nam() else return 0; } + tDebug() << Q_FUNC_INFO << "Found gui thread in nam hash"; // Create a nam for this thread based on the main thread's settings but with its own proxyfactory QNetworkAccessManager *mainNam = s_threadNamHash[ TOMAHAWK_APPLICATION::instance()->thread() ]; @@ -487,7 +491,9 @@ nam() s_threadNamHash[ QThread::currentThread() ] = newNam; - tDebug( LOGEXTRA ) << "created new nam for thread " << QThread::currentThread(); + tDebug( LOGEXTRA ) << Q_FUNC_INFO << "created new nam for thread " << QThread::currentThread(); + //QNetworkProxy proxy = dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( newNam->proxyFactory() )->proxy(); + //tDebug() << Q_FUNC_INFO << "reply proxy properties: " << proxy.type() << proxy.hostName() << proxy.port(); return newNam; } @@ -524,6 +530,7 @@ setNam( QNetworkAccessManager* nam, bool noMutexLocker ) s_noProxyHostsMutex.unlock(); } + QNetworkProxyFactory::setApplicationProxyFactory( proxyFactory ); nam->setProxyFactory( proxyFactory ); s_threadNamHash[ QThread::currentThread() ] = nam; s_threadProxyFactoryHash[ QThread::currentThread() ] = proxyFactory;