From d20512216052f049ac76311a9c825852daf712e5 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 14 Sep 2020 10:37:46 +0200 Subject: [PATCH] Gui: [skip ci] fixes #0004422: PartDesign value input does not accept trailing slash --- src/Gui/QuantitySpinBox.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 5bade8721e4d..6cd4287c01de 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -227,7 +227,20 @@ class QuantitySpinBoxPrivate state = QValidator::Intermediate; } else if (res.getUnit() != this->unit) { - state = QValidator::Invalid; + // If the user input is of the form "number * unit", "number + unit" + // or "number - unit" it's rejected by the quantity parser and it's + // assumed that the user input is not complete yet (Intermediate). + // However, if the user input is of the form "number / unit" it's accepted + // by the parser but because the units mismatch it's considered as invalid + // and the last valid input will be restored. + // See #0004422: PartDesign value input does not accept trailing slash + // To work around this issue of the quantity parser it's checked if the + // inversed unit matches and if yes the input is also considered as not + // complete. + if (res.getUnit().pow(-1) == this->unit) + state = QValidator::Intermediate; + else + state = QValidator::Invalid; } else { state = QValidator::Acceptable;