Skip to content

Commit

Permalink
Merge branch 'master' into prefDirs
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jun 7, 2020
2 parents 73f086f + 89ddab3 commit 102e9e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/App/Expression.cpp
Expand Up @@ -2301,12 +2301,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
_EXPR_THROW("Unknown function: " << f,expr);
}

Quantity q(scaler * output, unit);
if (!q.isValid()) {
throw Base::ValueError("Not a number");
}

return Py::asObject(new QuantityPy(new Quantity(q)));
return Py::asObject(new QuantityPy(new Quantity(scaler * output, unit)));
}

Py::Object FunctionExpression::_getPyValue() const {
Expand Down
8 changes: 6 additions & 2 deletions src/Gui/DlgExpressionInput.cpp
Expand Up @@ -156,13 +156,17 @@ void DlgExpressionInput::textChanged(const QString &text)
Base::Quantity value = n->getQuantity();
QString msg = value.getUserString();

if(!impliedUnit.isEmpty()) {
if (!value.isValid()) {
throw Base::ValueError("Not a number");
}
else if (!impliedUnit.isEmpty()) {
if (!value.getUnit().isEmpty() && value.getUnit() != impliedUnit)
throw Base::UnitsMismatchError("Unit mismatch between result and required unit");

value.setUnit(impliedUnit);

} else if (!value.getUnit().isEmpty()) {
}
else if (!value.getUnit().isEmpty()) {
msg += QString::fromUtf8(" (Warning: unit discarded)");

QPalette p(ui->msg->palette());
Expand Down

0 comments on commit 102e9e5

Please sign in to comment.