From 1ebcae0c0b01df1eaae4c976b4b56076d8389ec8 Mon Sep 17 00:00:00 2001 From: Pieter Hijma Date: Mon, 28 Jul 2025 13:51:49 +0200 Subject: [PATCH] Core: Fix func expression simplify --- src/App/Expression.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index db5862f1c1..c2d0f4f2d5 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -2610,7 +2610,7 @@ Py::Object FunctionExpression::_getPyValue() const { Expression *FunctionExpression::simplify() const { size_t numerics = 0; - std::vector a; + std::vector simplifiedArgs; // Try to simplify each argument to function for (auto it : args) { @@ -2618,20 +2618,21 @@ Expression *FunctionExpression::simplify() const if (freecad_cast(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)); } /**