Blob Blame History Raw
From ff5ec06b2eee8b367a2bbd2a50f5c04de7fa45ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cristian=20One=C8=9B?= <onet.cristian@gmail.com>
Date: Fri, 16 Nov 2012 08:49:18 +0200
Subject: [PATCH 03/22] Only load the child accounts if there are any,
 otherwise MyMoneyFile::accountList will return all accounts.

BUG: 309105
(cherry picked from commit e492b20918f569e218b65925b7f758aeef01d865)
---
 kmymoney/models/accountsmodel.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kmymoney/models/accountsmodel.cpp b/kmymoney/models/accountsmodel.cpp
index 37816f5..3679314 100644
--- a/kmymoney/models/accountsmodel.cpp
+++ b/kmymoney/models/accountsmodel.cpp
@@ -884,11 +884,13 @@ void InstitutionsModel::slotObjectAdded(MyMoneyFile::notificationObjectT objType
 
   // load the investment sub-accounts if there are any - there could be sub-accounts if this is an add operation
   // that was triggered in slotObjectModified on an already existing account which went trough a hierarchy change
-  QList<MyMoneyAccount> subAccounts;
-  d->m_file->accountList(subAccounts, account->accountList(), true);
-  for (QList<MyMoneyAccount>::ConstIterator it_a = subAccounts.constBegin(); it_a != subAccounts.constEnd(); ++it_a) {
-    if ((*it_a).isInvest()) {
-      static_cast<InstitutionsPrivate *>(d)->loadInstitution(this, *it_a);
+  if (!account->accountList().isEmpty()) {
+    QList<MyMoneyAccount> subAccounts;
+    d->m_file->accountList(subAccounts, account->accountList());
+    for (QList<MyMoneyAccount>::ConstIterator it_a = subAccounts.constBegin(); it_a != subAccounts.constEnd(); ++it_a) {
+      if ((*it_a).isInvest()) {
+        static_cast<InstitutionsPrivate *>(d)->loadInstitution(this, *it_a);
+      }
     }
   }
 }
-- 
1.8.1.4