Bug 313848 - Ledger view misbehaves after editing a transaction
Summary: Ledger view misbehaves after editing a transaction
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: git (master)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-24 20:35 UTC by allan
Modified: 2018-03-28 08:00 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description allan 2013-01-24 20:35:56 UTC
After entering an edited transaction, it appears to be accepted, but the transaction does not close.  Switching then to another view seems to work, but it is not possible to switch back to Ledger view.  Then I noticed that the ledger account selection box is still visible. If I then select a different account, Ledger view is now working.  I can return to the original account and the edited transaction appears normal.

Now, it is working correctly after an edit.  Oh, I see.  If I edit the quantity
of shares and then click within the body of the transaction, but not in an
editable field, the transaction does not close correctly.  If instead I click
OK, then all is well.

Similar to Bug 308017 - UI doesn't update/freeze

Reproducible: Always

Steps to Reproduce:
1.Select an investment transaction.
2.Edit the quantity of shares.
3.Do not click OK.
4.Click in the body of the transaction, outside of an edit field, to close the amount box.
5.Now click OK.
6.The transaction appears to remain open.
7.Try clicking on another view and then try to return to Ledger view.
8.The other view still shows, but the Ledger account selector still shows.
9.Select another account and then the original one.
10.The edit has been accepted.

Actual Results:  
see above.

Expected Results:  
The transaction should close correctly when OK is clicked.

Similar to Bug 308017 - UI doesn't update/freeze
Comment 1 Cristian Oneț 2013-01-25 05:32:48 UTC
Could this be caused by https://projects.kde.org/projects/extragear/office/kmymoney/repository/revisions/a8fa09f5ba1e6eb2a019089c7071a4ccef0cb356 or was the bug present before that?
Comment 2 allan 2013-01-25 11:59:27 UTC
(In reply to comment #1)
> Could this be caused by
> https://projects.kde.org/projects/extragear/office/kmymoney/repository/
> revisions/a8fa09f5ba1e6eb2a019089c7071a4ccef0cb356 or was the bug present
> before that?

No, without those changes, the problem remains as reported.  The OK button gets enabled when it should, but after clicking it, the transaction remains open.  Edit and Enter do not get re-enabled.  Trying to recover by changing view does not work, as after, the ledger does not re-open.  The Ledger title reappears as does the selector, but hits main window does not, until a new account is selected.
Comment 3 allan 2013-01-25 17:24:54 UTC
Another little quirk that might, or might not, shed some light.
After making an edit, clicking within the transaction body, then
clicking enter, when the transaction remains open, but not responding,
it isn't actually there!  If I click on the 'Buy shares' box, nothing happens.
If I click on the Asset Account box, however, a new transaction opens.

So, it's like the transaction has closed and isn't there, so clicking on that
line opens a new transaction, as would happen if it wasn't there.

So, perhaps the refresh didn't happen, but the UI thinks it has.

I think this is a long-standing problem that I've caught glimpses of from 
time to time, but not been able to reproduce.  Perhaps slightly different details,
but very similar.

I tried using the transaction form, and I suspect it's OK, but the symptoms
aren't so obvious.
Comment 4 allan 2013-01-26 00:30:13 UTC
What seems to be happening is that in the 'fault' condition, when Register::selectItem() is entered, m_mouseButton is QFlags(0x1) , (Qt::LeftButton).  Otherwise, it is QFlags() .

Temporarily setting it there to Qt::NoButton appears to avoid the trouble.  I've not gone any further, regarding any repercussions.
Comment 5 allan 2013-01-26 00:32:20 UTC
Changed heading as non-investment transactions also show this.
Comment 6 allan 2013-01-26 17:09:03 UTC
I would appreciate comments as to whether this patch is the right approach.

The initial fix was diagnostic, as it was getting late.

I needed to go further back in the code.  What I found was that after an edit, a click in the body of the transaction, outside of the editable fields, resulted in a call to 
Register::selectItem(int row, int col), whereas clicking in the edit fields did not.  The click was reflected in m_mouseButton - QFlags(0x1), and it was that which later was causing the problem.

So, I needed to clear m_mouseButton, in this use case :- 
Register::selectItem(int row, int col), line 1420

     // don't support selecting when the item has an editor
     // or the item itself is not selectable
-    if (item->hasEditorOpen() || !item->isSelectable())
+    if (item->hasEditorOpen() || !item->isSelectable()) {
+      m_mouseButton = Qt::NoButton;
       return;
-
+    }

This fixes the problem, and no side-effects so far.
Comment 7 Cristian Oneț 2013-01-26 17:57:54 UTC
Sorry, but I couldn't follow this... couldn't reproduce it either... is it happening only without the transaction form?
Comment 8 allan 2013-01-26 18:52:40 UTC
Oh, OK.
1) Let's start by un-selecting the transaction form.
2) Select a checking transaction.
3) Only edit the amount - do nothing else.
4) Mouse click just below the amount.
5) Now click Enter.
6) For me, the transaction appears to stay open.
7) Enter and Edit and Cancel are disabled.

Now, since I've updated from Git, there's a change in the situation.  
Originally, it was more difficult to recover, so I next did..
8) Select Payees view.
9) Try to select Ledger view.
10) The body of Payees still shows, but Ledger account selector also shows.
11) Select same ledger account - no change.
12) Select another account - back in ledger view.
13) OK now.
Comment 9 allan 2013-01-26 20:41:14 UTC
Incidentally, I've just tried on ~/kmymoney-4.6.2.

The first time, it seemed to work correctly.  The next four or five times, after the edit and clicking Enter, the whole ledger's worth of transaction disappeared.

Clicking Payees view then Ledger didn't restore them, until a new account was selected then the original.
Comment 10 Cristian Oneț 2013-01-28 14:36:29 UTC
(In reply to comment #8)
> Oh, OK.
> 1) Let's start by un-selecting the transaction form.
> 2) Select a checking transaction.
> 3) Only edit the amount - do nothing else.
> 4) Mouse click just below the amount.
> 5) Now click Enter.
> 6) For me, the transaction appears to stay open.
> 7) Enter and Edit and Cancel are disabled.
I couldn't get into this state.
Comment 11 allan 2013-01-28 16:30:09 UTC
Weird, I can get it and can 'fix' it.

The problem doesn't happen with the transaction form.

It doesn't fail when creating a transaction, it has to be an edit.
At step 3, after clicking edit,  move the cursor to the payment or 
deposit field or in fact any of the editable widgets and
leave it there.
At step 4, don't click on the account line as that is the line below
our transaction and creates a new item.  Click to the right of the 
memo, near the bottom.
Then Enter.

Also, if you can get the transaction to stay open, try again in an account
with just a single transaction.  With more transactions it's possible to
recover more easily, by clicking one of them.  If there's just a single item
it's more obvious.

Can anybody else try this please.  It is real, here at least!
Comment 12 allan 2013-02-10 23:29:02 UTC
From the mailing lists -

I have a problem [Bug 313848] which I can reproduce every time,
but Cristian doesn't see it.  I've now reproduced the problem on
another, dissimilar, PC.

It would be good if another user would help by trying to reproduce
the problem, too.  The problem doesn't happen with the transaction
form.

It doesn't fail when creating a transaction, it has to be an edit.
It's best to start with a checking account containing just a single 
transaction.

1) Let's start by un-selecting the transaction form.
    (Settings/Configure KMM/Ledger)
2) Select a checking transaction, ideally the only one in the account.
3) Click Edit.
4) Move the cursor into the payment or deposit field or in fact any
    of the editable widgets and leave it there.  It's not actually
    necessary to make an edit.
5) Mouse click below the amount, to the right of the memo, near
    the bottom.  (In the body of the transaction, but not in a field.)
    Don't click anywhere on the account line as that is really the line
    below our transaction and will create a new item.
5) Now click Enter.
6) For me, the transaction appears to stay open.
7) Enter and Edit and Cancel are disabled.

> I (Cristian) couldn't get into this state.  

Clicking on Payees view works normally, but then clicking on Ledgers
still shows the payees.  However, the Leger Accounts drop-down still 
shows.  Selecting a different account then returning to the one being 
used restores the transaction to normal.  Opening a new transaction also 
clears the condition.

Thanks for your help.

Allan


On Sun, 10 Feb 2013 21:48:43 +0000
David Houlden <djhoulden@gmail.com> wrote:

> Hi Allan,
> 
> Yes, I can reproduce this problem by following your instructions. In
> fact, I just selected a transaction from my normal checking account
> which contains hundreds of transactions. 

Yes, the quantity of transactions is not a factor in causing the fault.  However,
clicking on any other transaction clears the condition, so I wanted to reduce the possibility of that happening by accident.
> 
> Let me know if I can help further to track this down.
> 
> Dave.

Thanks, Dave, that's reassuring!

Allan
Comment 13 allan 2013-03-09 00:14:00 UTC
> I tried using the transaction form, and I suspect it's OK, but the symptoms
> aren't so obvious.

Just for completeness, there is an effect also when using the transaction form, and I have seen this from time to time, but without previously isolating the cause.

1) With the transaction form in use, double click an existing transaction to it open for editing.
2) Click within the body of the actual transaction.
3) Click Enter.
4) All fields and labels, everything in the transaction form, except the three tabs, is blank.
5) To clear, click another transaction or tab.
6) This issue is fixed by the same fix already described, in comment 6.
Comment 14 Thomas Baumgart 2017-09-12 12:06:16 UTC
Git commit 391363e5e53a2494cdb07d54b1ee1c69619fa748 by Thomas Baumgart.
Committed on 12/09/2017 at 12:04.
Pushed by tbaumgart into branch 'master'.

Close editor when changing views

When editing a transaction and changing to a different view, the editor
remained open. This will return the old behavior in that the user is
asked what to do (cancel or save the edit) before the view is switched.
FIXED-IN: 5.0

M  +1    -2    kmymoney/views/kgloballedgerview.cpp

https://commits.kde.org/kmymoney/391363e5e53a2494cdb07d54b1ee1c69619fa748