[Kmymoney-devel] [Bug 309105] Crash after editing security

allan agander93 at gmail.com
Tue Nov 13 17:35:04 UTC 2012


https://bugs.kde.org/show_bug.cgi?id=309105

--- Comment #6 from allan <agander93 at gmail.com> ---
(In reply to comment #5)
> Yes, that does it. The problem is caused during step 4. Within void
> InstitutionsModel::slotObjectModified() the sequence
> 
>     slotObjectRemoved(MyMoneyFile::notifyAccount, oldAccount.id());
>     slotObjectAdded(MyMoneyFile::notifyAccount, obj);
> 
> close to the end of the method is executed. oldAccount and obj reference the
> investment account created in 1. Step 5 operates on the stock created in
> step 2 which is somehow not part of the model anymore. Looks like the
> subordinate equity account gets lost during the call to slotObjectRemoved()
> in the model as it is not found anymore during step 5.

I though I'd have a Iook at this although I have only a very slight idea of
what I am doing here, not having encountered Model/View before.  However, via a
circuitous route, I've come to the conclusion that the reason why the stock
account is not in the model is that it wasn't loaded into it.  When the
institution is first created, the stock account does get loaded, but later,
void InstitutionsModel::slotObjectModified() doesn't reload it.

So, I've copied the code from the end of void
InstitutionsModel::slotObjectAdded() and added that to the end of  void
InstitutionsModel::slotObjectModified(), at line 879.

///  static_cast<InstitutionsPrivate *>(d)->loadInstitution(this, *account);
// create items for all the accounts
  QList<MyMoneyAccount> list;
  d->m_file->accountList(list);
  for (QList<MyMoneyAccount>::ConstIterator it_l = list.constBegin(); it_l !=
list.constEnd(); ++it_l) {
    static_cast<InstitutionsPrivate *>(d)->loadInstitution(this, *it_l);
  }
}

This seems to work, there is no crash, and Instittutions View shows the
investment account and the stock.

Any thoughts?

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the KMyMoney-devel mailing list