Core: Fix func expression simplify
This commit is contained in:
@@ -2610,7 +2610,7 @@ Py::Object FunctionExpression::_getPyValue() const {
|
||||
Expression *FunctionExpression::simplify() const
|
||||
{
|
||||
size_t numerics = 0;
|
||||
std::vector<Expression*> a;
|
||||
std::vector<Expression*> simplifiedArgs;
|
||||
|
||||
// Try to simplify each argument to function
|
||||
for (auto it : args) {
|
||||
@@ -2618,20 +2618,21 @@ Expression *FunctionExpression::simplify() const
|
||||
|
||||
if (freecad_cast<NumberExpression*>(v))
|
||||
++numerics;
|
||||
a.push_back(v);
|
||||
simplifiedArgs.push_back(v);
|
||||
}
|
||||
|
||||
if (numerics == args.size()) {
|
||||
// All constants, then evaluation must also be constant
|
||||
|
||||
// Clean-up
|
||||
for (auto it : args)
|
||||
// Clean-up the simplified arguments
|
||||
for (auto it : simplifiedArgs)
|
||||
delete it;
|
||||
|
||||
return eval();
|
||||
}
|
||||
else
|
||||
return new FunctionExpression(owner, f, std::string(fname), std::move(a));
|
||||
return new FunctionExpression(owner, f, std::string(fname),
|
||||
std::move(simplifiedArgs));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user