From 25fba84b32f72cb7cdfff176e6a950fab1e9bf6b Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Mon, 9 Apr 2012 23:52:06 -0400 Subject: [PATCH] This should hopefully get rid of the messages about parent being in the wrong thread --- src/accounts/lastfm/LastFmAccount.cpp | 1 + src/accounts/lastfm/lastfmplugin.cpp | 10 ++++++++++ src/accounts/lastfm/lastfmplugin.h | 1 + src/accounts/twitter/twitteraccount.cpp | 1 + src/accounts/twitter/twitterinfoplugin.cpp | 11 +++++++++++ src/accounts/twitter/twitterinfoplugin.h | 1 + 6 files changed, 25 insertions(+) diff --git a/src/accounts/lastfm/LastFmAccount.cpp b/src/accounts/lastfm/LastFmAccount.cpp index f302fb8bf..a7f566850 100644 --- a/src/accounts/lastfm/LastFmAccount.cpp +++ b/src/accounts/lastfm/LastFmAccount.cpp @@ -76,6 +76,7 @@ LastFmAccount::LastFmAccount( const QString& accountId ) { infoPlugin()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ); Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() ); + QMetaObject::invokeMethod( infoPlugin(), "init", Qt::QueuedConnection ); } } diff --git a/src/accounts/lastfm/lastfmplugin.cpp b/src/accounts/lastfm/lastfmplugin.cpp index cbec482ca..3a9275323 100644 --- a/src/accounts/lastfm/lastfmplugin.cpp +++ b/src/accounts/lastfm/lastfmplugin.cpp @@ -46,7 +46,17 @@ LastFmPlugin::LastFmPlugin( LastFmAccount* account ) { m_supportedGetTypes << InfoAlbumCoverArt << InfoArtistImages << InfoArtistSimilars << InfoArtistSongs << InfoChart << InfoChartCapabilities; m_supportedPushTypes << InfoSubmitScrobble << InfoSubmitNowPlaying << InfoLove << InfoUnLove; +} + +void +LastFmPlugin::init() +{ + if ( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() && thread() != Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ) + { + tDebug() << "Failure: move to the worker thread before running init"; + return; + } // Flush session key cache // TODO WHY FLUSH // m_account->setSessionKey( QByteArray() ); diff --git a/src/accounts/lastfm/lastfmplugin.h b/src/accounts/lastfm/lastfmplugin.h index c071ed7d5..088bf4199 100644 --- a/src/accounts/lastfm/lastfmplugin.h +++ b/src/accounts/lastfm/lastfmplugin.h @@ -49,6 +49,7 @@ public: virtual ~LastFmPlugin(); public slots: + void init(); void settingsChanged(); void onAuthenticated(); diff --git a/src/accounts/twitter/twitteraccount.cpp b/src/accounts/twitter/twitteraccount.cpp index ced1cccfc..ed183db9a 100644 --- a/src/accounts/twitter/twitteraccount.cpp +++ b/src/accounts/twitter/twitteraccount.cpp @@ -192,6 +192,7 @@ TwitterAccount::connectAuthVerifyReply( const QTweetUser &user ) { infoPlugin()->moveToThread( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ); Tomahawk::InfoSystem::InfoSystem::instance()->addInfoPlugin( infoPlugin() ); + QMetaObject::invokeMethod( infoPlugin(), "init", Qt::QueuedConnection ); } m_isAuthenticated = true; diff --git a/src/accounts/twitter/twitterinfoplugin.cpp b/src/accounts/twitter/twitterinfoplugin.cpp index ba12660e5..22a47a25f 100644 --- a/src/accounts/twitter/twitterinfoplugin.cpp +++ b/src/accounts/twitter/twitterinfoplugin.cpp @@ -38,7 +38,18 @@ TwitterInfoPlugin::TwitterInfoPlugin( Tomahawk::Accounts::TwitterAccount* accoun : m_account( account ) { m_supportedPushTypes << InfoLove; +} + +void +TwitterInfoPlugin::init() +{ + if ( Tomahawk::InfoSystem::InfoSystem::instance()->workerThread() && thread() != Tomahawk::InfoSystem::InfoSystem::instance()->workerThread().data() ) + { + tDebug() << "Failure: move to the worker thread before running init"; + return; + } + QVariantHash credentials = m_account->credentials(); if ( credentials[ "oauthtoken" ].toString().isEmpty() || credentials[ "oauthtokensecret" ].toString().isEmpty() ) { diff --git a/src/accounts/twitter/twitterinfoplugin.h b/src/accounts/twitter/twitterinfoplugin.h index e3da557a0..77242754d 100644 --- a/src/accounts/twitter/twitterinfoplugin.h +++ b/src/accounts/twitter/twitterinfoplugin.h @@ -44,6 +44,7 @@ namespace Tomahawk { virtual ~TwitterInfoPlugin(); public slots: + void init(); void notInCacheSlot( const Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) { Q_UNUSED( criteria );