Commit 91261702 authored by Maximilian Schiller's avatar Maximilian Schiller Committed by Albert Astals Cid
Browse files

Fix repeat operation caused by memory store

In order to do the store memory operation the stack has to
be evaluated by a EnterEqual() operation which would cause
a repeat of the last operation.

This introduces a argument to inhibit this behavior in undesireable
places.

BUG: 431331
parent 2c3db734
......@@ -948,7 +948,7 @@ void KCalculator::slotMemRecallclicked() {
//------------------------------------------------------------------------------
void KCalculator::slotMemStoreclicked() {
EnterEqual();
EnterEqual(CalcEngine::REPEAT_PREVENT);
memory_num_ = calc_display->getAmount();
calc_display->setStatusText(MemField, QStringLiteral("M"));
......@@ -1424,9 +1424,9 @@ void KCalculator::slotPeriodclicked() {
// Name: EnterEqual
// Desc: calculates and displays the result of the pending operations
//------------------------------------------------------------------------------
void KCalculator::EnterEqual() {
void KCalculator::EnterEqual(CalcEngine::Repeat allow_repeat) {
core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_EQUAL);
core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_EQUAL, allow_repeat);
updateDisplay(UPDATE_FROM_CORE | UPDATE_STORE_RESULT);
}
......
......@@ -114,6 +114,7 @@ public:
UPDATE_FROM_CORE = 1,
UPDATE_STORE_RESULT = 2
};
Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag)
......@@ -153,7 +154,7 @@ protected Q_SLOTS:
void updateSettings();
void setColors();
void setFonts();
void EnterEqual();
void EnterEqual(CalcEngine::Repeat allow_repeat = CalcEngine::REPEAT_ALLOW);
void showSettings();
// Mode
......
......@@ -826,7 +826,7 @@ KNumber CalcEngine::evalOperation(const KNumber &arg1, Operation operation, cons
}
}
void CalcEngine::enterOperation(const KNumber &number, Operation func)
void CalcEngine::enterOperation(const KNumber &number, Operation func, Repeat allow_repeat)
{
Node tmp_node;
......@@ -856,7 +856,7 @@ void CalcEngine::enterOperation(const KNumber &number, Operation func)
if (!repeat_mode_) {
repeat_mode_ = last_operation_ != FUNC_EQUAL;
last_repeat_number_ = number;
} else {
} else if(allow_repeat == REPEAT_ALLOW) {
Node repeat_node;
repeat_node.operation = last_operation_;
repeat_node.number = number;
......
......@@ -49,11 +49,16 @@ public:
FUNC_PWR_ROOT
};
enum Repeat {
REPEAT_ALLOW,
REPEAT_PREVENT
};
CalcEngine();
KNumber lastOutput(bool &error) const;
void enterOperation(const KNumber &num, Operation func);
void enterOperation(const KNumber &num, Operation func, Repeat allow_repeat = REPEAT_ALLOW);
void ArcCosDeg(const KNumber &input);
void ArcCosRad(const KNumber &input);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment