From e91d9e55f6065e75925524f5c67c61dfbdba1922 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 20 May 2012 17:11:53 -0400 Subject: [PATCH] Fix slow network causing multiple spotify accounts to show up --- src/accounts/spotify/SpotifyAccount.cpp | 16 ++++++++++++---- src/accounts/spotify/SpotifyAccount.h | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/accounts/spotify/SpotifyAccount.cpp b/src/accounts/spotify/SpotifyAccount.cpp index a14fbbb5d..725d1f9e9 100644 --- a/src/accounts/spotify/SpotifyAccount.cpp +++ b/src/accounts/spotify/SpotifyAccount.cpp @@ -97,16 +97,24 @@ SpotifyAccount::init() setAccountFriendlyName( "Spotify" ); setAccountServiceName( "spotify" ); + AtticaManager::instance()->registerCustomAccount( s_resolverId, this ); + qRegisterMetaType< Tomahawk::Accounts::SpotifyPlaylistInfo* >( "Tomahawk::Accounts::SpotifyPlaylist*" ); + if ( !AtticaManager::instance()->resolversLoaded() ) { // If we're still waiting to load, wait for the attica resolvers to come down the pipe - connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( init() ), Qt::UniqueConnection ); - return; + connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( delayedInit() ), Qt::UniqueConnection ); } + else + { + delayedInit(); + } +} - qRegisterMetaType< Tomahawk::Accounts::SpotifyPlaylistInfo* >( "Tomahawk::Accounts::SpotifyPlaylist*" ); - AtticaManager::instance()->registerCustomAccount( s_resolverId, this ); +void +SpotifyAccount::delayedInit() +{ connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( resolverInstalled( QString ) ) ); diff --git a/src/accounts/spotify/SpotifyAccount.h b/src/accounts/spotify/SpotifyAccount.h index af05d0be6..69448b27b 100644 --- a/src/accounts/spotify/SpotifyAccount.h +++ b/src/accounts/spotify/SpotifyAccount.h @@ -118,10 +118,11 @@ private slots: void startPlaylistSyncWithPlaylist( const QString& msgType, const QVariantMap& msg ); void playlistCreated( const QString& msgType, const QVariantMap& msg ); - void init(); + void delayedInit(); void hookupAfterDeletion( bool autoEnable ); private: + void init(); bool checkForResolver(); void hookupResolver();