| Summary: | Sometimes chained operations cause 'forgetting' of inserted constants or pasted numbers | ||
|---|---|---|---|
| Product: | [Applications] kcalc | Reporter: | oleg.popkov |
| Component: | general | Assignee: | Evan Teran <evan.teran> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | schiwed, Wolfram.Klaus |
| Priority: | NOR | ||
| Version First Reported In: | 19.12 | ||
| Target Milestone: | --- | ||
| Platform: | Manjaro | ||
| OS: | Linux | ||
| Latest Commit: | https://invent.kde.org/utilities/kcalc/commit/cf39d29d737f7787350b04216c64a22a0b936af6 | Version Fixed/Implemented In: | |
| Sentry Crash Report: | |||
|
Description
oleg.popkov
2019-09-27 18:13:10 UTC
Still present in 19.12.3 on Manjaro. STEPS TO REPRODUCE 1. CLICK 2*[constant]*3: Result is 5 2. CLICK 2*3*[constant]: Result is correct 3. CLICK [constant}*2*3: Result is correct As there has been no reaction from the developers for a long time, I submitted a naive solution to the Phabricator. Perhaps, it will be noticed there. https://phabricator.kde.org/D29816 Git commit cf39d29d737f7787350b04216c64a22a0b936af6 by Maximilian Schiller, on behalf of Oleg Popkov. Committed on 07/06/2020 at 08:00. Pushed by mschiller into branch 'master'. Fix chained operations involving inserted numbers In brief, KCalc uses a stack in `CalcEngine` for both numbers and operations in order to ensure the correct operation evaluation order (such that `2 + 2 * 2 = 6`) and support parentheses. Operations are pushed along with currently displayed numerical values. KCalc also checks whether it should push the operation onto the stack or just replace a pushed one with the new one without changing the associated number (so that `5 + - 3 = 2`), and for this it uses a flag changed by calling the `CalcEngine::setOnlyUpdateOperation` method. Obviously, this flag must be cleared after a number is entered by any method, but it only happens if a number is entered manually. As a result, inserting a number as a whole, whether as a constant or by pasting from the clipboard, results in replacing the preceding operation with the succeeding one without storing the number in question, unless the succeeding operation is `=` or `%`. M +19 -1 kcalc.cpp M +2 -0 kcalc.h https://invent.kde.org/utilities/kcalc/commit/cf39d29d737f7787350b04216c64a22a0b936af6 |