From 3b083a25350550b853c5465ed38a307b829c5f12 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 3 Aug 2012 11:41:00 -0400 Subject: [PATCH] Handle case where attica load is super slow --- src/libtomahawk/accounts/AccountModel.cpp | 15 +++++++++++++-- src/libtomahawk/accounts/AccountModel.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/accounts/AccountModel.cpp b/src/libtomahawk/accounts/AccountModel.cpp index 41a1963c1..01b2687f6 100644 --- a/src/libtomahawk/accounts/AccountModel.cpp +++ b/src/libtomahawk/accounts/AccountModel.cpp @@ -38,8 +38,9 @@ using namespace Accounts; AccountModel::AccountModel( QObject* parent ) : QAbstractListModel( parent ) + , m_waitingForAtticaLoaded( true ) { - connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( loadData() ) ); + connect( AtticaManager::instance(), SIGNAL( resolversLoaded( Attica::Content::List ) ), this, SLOT( atticaLoaded() ) ); connect( AtticaManager::instance(), SIGNAL( startedInstalling( QString ) ), this, SLOT( onStartedInstalling( QString ) ) ); connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( onFinishedInstalling( QString ) ) ); connect( AtticaManager::instance(), SIGNAL( resolverInstallationFailed( QString ) ), this, SLOT( resolverInstallFailed( QString ) ) ); @@ -51,6 +52,15 @@ AccountModel::AccountModel( QObject* parent ) loadData(); } + +void +AccountModel::atticaLoaded() +{ + m_waitingForAtticaLoaded = false; + loadData(); +} + + void AccountModel::loadData() { @@ -644,7 +654,8 @@ AccountModel::accountAdded( Account* account ) if ( ResolverAccount* resolver = qobject_cast< ResolverAccount* >( account ) ) { qDebug() << "Plain old manual resolver added, appending at end"; - Q_ASSERT( qobject_cast< AtticaResolverAccount* >( account ) == 0 ); // should NOT get attica accounts here, should be caught above + if ( !m_waitingForAtticaLoaded ) + Q_ASSERT( qobject_cast< AtticaResolverAccount* >( account ) == 0 ); // should NOT get attica accounts here, should be caught above const int count = m_accounts.size(); beginInsertRows( QModelIndex(), count, count ); m_accounts << new AccountModelNode( resolver ); diff --git a/src/libtomahawk/accounts/AccountModel.h b/src/libtomahawk/accounts/AccountModel.h index 13de779f1..09be15187 100644 --- a/src/libtomahawk/accounts/AccountModel.h +++ b/src/libtomahawk/accounts/AccountModel.h @@ -100,6 +100,7 @@ signals: void errorInstalling( const QPersistentModelIndex& idx ); private slots: + void atticaLoaded(); void loadData(); void accountAdded( Tomahawk::Accounts::Account* ); @@ -112,6 +113,7 @@ private slots: private: QModelIndex indexForAtticaId( const QString& resolverId ) const; + bool m_waitingForAtticaLoaded; QList< AccountModelNode* > m_accounts; QSet< QString > m_waitingForAtticaInstall; };