New payees bug

Thomas Baumgart thb at net-bembel.de
Mon Jul 24 07:07:26 BST 2023


On Montag, 24. Juli 2023 01:08:03 CEST Jeremy Whiting wrote:

> I think the problem is that when you click Yes on that dialog to add the
> payee it shouldn't reset the ledgerview at all. It doesn't when you click
> No, it just clears the payee box. I think that makes sense, but when you
> click Yes it shouldn't be doing anything to the ledger. Only adding the
> payee as a payee behind the scenes and leaving the ledger completely alone.
> So I can continue to add category, cleared status, etc. Thanks for the
> pointer though, I'll see why it's calling LedgerView::reset in this case
> when it shouldn't be IMO.

The reason is simple to explain: adding the payee to the MyMoneyFile object
creates a MyMoneyFileTransaction. When that is created, the LedgerConcatenate
model is instructed to stop emitting signals to prevent massive sorting
operations when ledger objects change. When the MyMoneyFileTransaction
object is destroyed, signal emission is turned on again and the
LedgerConcatenate model is reset which is propagated to the LedgerView.

See https://invent.kde.org/office/kmymoney/-/blame/master/kmymoney/models/ledgerconcatenatemodel.cpp#L29-L42

In case you answer no to the creation of the payee, that will not happen and
the editor stays in place due to the missing reset.

Thomas


> 
> On Sat, Jul 22, 2023 at 1:58 AM Thomas Baumgart via KMyMoney-devel <
> kmymoney-devel at kde.org> wrote:
> 
> > On Samstag, 22. Juli 2023 03:08:26 CEST Jeremy Whiting via KMyMoney-devel
> > wrote:
> >
> > > Ok, I think I've hit the edge of my code following for the evening.
> > > Everything in NewTransactionEditor looks right. It calls
> > > KMyMoneyUtils::newPayee which works right and finds the index of the new
> > > payee, etc. The only problem is that after it's done the
> > > NewTransactionEditor gets destructed for some reason... It gets
> > destructed
> > > when you click Yes on the Create new payee question dialog. If you click
> > No
> > > instead it leaves the editor, but clears out the value for the payee as
> > > expected. I'm not sure why the editor is getting destructed in the
> > > LedgerView.
> >
> > This is caused by LedgerView::reset() which is called when the underlying
> > engine state (represented by the models) changes. LedgerConcatenateModels
> > suppresses any signals during the update of the engine objects and simply
> > calls beginResetModel() and endResetModel() when the objects in the engine
> > are changed. EndResetModel() calls LedgerView::reset() in the course of
> > action.
> >
> > I added that to reduce the number of sort operations on the ledgers when
> > multiple
> > (as in many) objects get changed as part of an action (e.g. mark
> > transactions
> > as cleared). Maybe, this was not the best choice. I know it's more of a
> > sledge hammer method but works well. It's just not ideal for what we try
> > to solve here.
> >
> > So far, I have no immediate solution to this problem. But I am sure, we
> > will
> > find one.
> >
> > Thomas
> >
> >
> >
> > > On Fri, Jul 21, 2023 at 5:31 PM Jeremy Whiting <jpwhiting at kde.org>
> > wrote:
> > >
> > > > Hello,
> > > >
> > > > I think there's a recent-ish bug in master. I'm not sure when I started
> > > > hitting it since I don't often add new payees. But lately when adding
> > a new
> > > > transaction if you enter a new name for the payee it pops up the
> > dialog "Do
> > > > you want to add <foo> as a new payee?" which is how it always has been.
> > > > However lately, clicking yes seems to add the payee to the payees, but
> > also
> > > > clears out the entered transaction data. It used to just add the payee
> > and
> > > > let you continue to edit the rest of the transaction details.
> > > >
> > > > Clicking No clears everything just like it used to.
> > > >
> > > > With a quick dive into the code I *think* it might be a bug around
> > > > PayeeCreator::createPayee. I think when it calls
> > KMyMoneyUtils::newPayee
> > > > that works so it drops into the else block, but then somehow doesn't
> > get an
> > > > index from m_comboBox->findData (maybe because the combobox didn't get
> > > > notified of the new payee?) so it clears everything out.
> > > >
> > > > I'll dive in and see if that's the cause and see if I can find out how
> > to
> > > > get it added to the combobox maybe, but wanted to point it out in case
> > it's
> > > > already known and maybe in progress somewhere.
> > > >
> > > > thanks,
> > > > Jeremy
> > > >
> > >
> >
> > --
> >
> > Regards
> >
> > Thomas Baumgart
> >
> > -------------------------------------------------------------
> > Did you hear about the guy who got his whole left side cut off?
> > He's all right now.
> > -------------------------------------------------------------
> >
> 

-- 

Regards

Thomas Baumgart

-------------------------------------------------------------
Intelligent people stay up late, are disorderly and swear.
www.businessinsider.de/5-verdammt-gute-argumente-fuers-fluchen-2016-8
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 868 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20230724/8409e96d/attachment.sig>


More information about the KMyMoney-devel mailing list