1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-08 23:26:40 +02:00

TWK-740: Don't accept the resolver account factory when adding new accounts to list

This commit is contained in:
Leo Franchi
2012-03-16 11:16:40 -04:00
parent e3f5605c4e
commit ad82b81225

View File

@@ -544,16 +544,18 @@ AccountModel::accountAdded( Account* account )
// Find the factory this belongs up, and update // Find the factory this belongs up, and update
qDebug() << "IN ACCOUNT ADDED, new account:" << account->accountFriendlyName(); qDebug() << "IN ACCOUNT ADDED, new account:" << account->accountFriendlyName();
AccountFactory* factory = AccountManager::instance()->factoryForAccount( account ); AccountFactory* factory = AccountManager::instance()->factoryForAccount( account );
ResolverAccount* resolver = qobject_cast< ResolverAccount* >( account );
AtticaResolverAccount* attica = qobject_cast< AtticaResolverAccount* >( account ); AtticaResolverAccount* attica = qobject_cast< AtticaResolverAccount* >( account );
for ( int i = 0; i < m_accounts.size(); i++ ) for ( int i = 0; i < m_accounts.size(); i++ )
{ {
AccountModelNode* n = m_accounts.at( i ); AccountModelNode* n = m_accounts.at( i );
bool thisIsTheOne = false; bool thisIsTheOne = false;
qDebug() << "Checking for added account's related factory or attica:" << n->factory << attica; qDebug() << "Checking for added account's related factory or attica:" << n->factory << attica << resolver;
if ( attica ) if ( attica )
qDebug() << n->atticaContent.id() << n->atticaContent.name() << attica->atticaId(); qDebug() << n->atticaContent.id() << n->atticaContent.name() << attica->atticaId();
if ( n->factory == factory ) if ( n->factory == factory && !(resolver && !attica) ) // Specifically ignore manual resolvers, as the user added them directly
{ {
qDebug() << "Found added account with factory we already havel" << n->factory << factory;
n->accounts << account; n->accounts << account;
thisIsTheOne = true; thisIsTheOne = true;
} }
@@ -582,6 +584,7 @@ AccountModel::accountAdded( Account* account )
// Ok, just a plain resolver. add it at the end // Ok, just a plain resolver. add it at the end
if ( ResolverAccount* resolver = qobject_cast< ResolverAccount* >( 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 Q_ASSERT( qobject_cast< AtticaResolverAccount* >( account ) == 0 ); // should NOT get attica accounts here, should be caught above
const int count = m_accounts.size(); const int count = m_accounts.size();
beginInsertRows( QModelIndex(), count, count ); beginInsertRows( QModelIndex(), count, count );