From 66e67fdd4e966d37542b325f869c147f02e52fb0 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 9 Mar 2012 22:37:39 -0500 Subject: [PATCH] Fix crash when accounts were loaded before attica was fetched --- src/libtomahawk/accounts/LastFmAccount.cpp | 15 +++++++++++++++ src/libtomahawk/accounts/LastFmAccount.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/libtomahawk/accounts/LastFmAccount.cpp b/src/libtomahawk/accounts/LastFmAccount.cpp index fb4c97ec4..6de62718c 100644 --- a/src/libtomahawk/accounts/LastFmAccount.cpp +++ b/src/libtomahawk/accounts/LastFmAccount.cpp @@ -83,6 +83,13 @@ LastFmAccount::~LastFmAccount() void LastFmAccount::authenticate() { + 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( atticaLoaded( Attica::Content::List ) ), Qt::UniqueConnection ); + return; + } + const Attica::Content res = AtticaManager::instance()->resolverForId( "lastfm" ); const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res ); @@ -104,6 +111,14 @@ LastFmAccount::authenticate() } +void +LastFmAccount::atticaLoaded( Attica::Content::List ) +{ + disconnect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( atticaLoaded( Attica::Content::List ) ) ); + authenticate(); +} + + void LastFmAccount::deauthenticate() { diff --git a/src/libtomahawk/accounts/LastFmAccount.h b/src/libtomahawk/accounts/LastFmAccount.h index 3e7aaf651..7988c37d6 100644 --- a/src/libtomahawk/accounts/LastFmAccount.h +++ b/src/libtomahawk/accounts/LastFmAccount.h @@ -94,6 +94,8 @@ public: Attica::Content atticaContent() const; private slots: + void atticaLoaded( Attica::Content::List ); + void resolverInstalled( const QString& resolverId ); void resolverChanged();