Skip to content

Fix chained operations involving inserted numbers

Oleg Popkov requested to merge ovp/kcalc:fix-chained-operations into master

The bug description is here.

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 %.

Merge request reports

Loading