From 6047a85f4086145597936a6898fb3f734b2b54f0 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 15 Aug 2012 22:39:36 +0200 Subject: [PATCH] Banish ghost accounts from lingering around. --- src/widgets/AccountListWidget.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/widgets/AccountListWidget.cpp b/src/widgets/AccountListWidget.cpp index 0de405580..ef788b05e 100644 --- a/src/widgets/AccountListWidget.cpp +++ b/src/widgets/AccountListWidget.cpp @@ -123,6 +123,18 @@ AccountListWidget::removeEntries( const QModelIndex& parent, int start, int end for ( int i = start; i <= end; ++i ) { QPersistentModelIndex idx( m_model->index( i, 0, parent ) ); + if ( !idx.isValid() ) //means we just removed the last account for a factory + { + for ( QHash< QPersistentModelIndex, QList< AccountWidget* > >::iterator it = m_entries.begin(); + it != m_entries.end(); ++it ) + { + if ( !it.key().isValid() ) + { + idx = it.key(); + } + } + } + QList< AccountWidget* > &entryAccounts = m_entries[ idx ]; for ( int j = 0; j < entryAccounts.count(); ++j ) {