Skip to content

Commit 0450ceb

Browse files
committed
[ui][node] ExpressionTextField : fix lossing focus reset
1 parent fab5f18 commit 0450ceb

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

meshroom/core/evaluation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ class MathEvaluator:
1313
print(mev.evaluate("pow(2, 8)"))
1414
print(mev.evaluate("round(sin(pi), 3)"))
1515
"""
16-
16+
1717
# Allowed math symbols
1818
allowed_symbols = {
1919
"e": math.e, "pi": math.pi,
2020
"cos": math.cos, "sin": math.sin, "tan": math.tan, "exp": math.exp,
2121
"pow": pow, "round": round, "abs": abs, "min": min, "max": max,
2222
"sqrt": math.sqrt, "log": math.log
2323
}
24+
2425
# Allowed AST node types
2526
allowed_nodes = (
2627
ast.Expression, ast.BinOp, ast.UnaryOp, ast.Call, ast.Name, ast.Load,
@@ -29,6 +30,7 @@ class MathEvaluator:
2930
ast.LShift, ast.RShift, ast.Invert,
3031
ast.Constant
3132
)
33+
3234
def _validate_ast(self, node):
3335
for child in ast.walk(node):
3436
if not isinstance(child, self.allowed_nodes):
@@ -37,6 +39,7 @@ def _validate_ast(self, node):
3739
if isinstance(child, ast.Name):
3840
if child.id not in self.allowed_symbols:
3941
raise ValueError(f"Unknown symbol: {child.id}")
42+
4043
def evaluate(self, expr: str):
4144
if any(bad in expr for bad in ('\n', '#')):
4245
raise ValueError(f"Invalid expression: {expr}")

meshroom/ui/qml/Utils/ExpressionTextField.qml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ TextField {
106106
}
107107
}
108108

109-
Component.onCompleted: {
110-
refreshStatus()
109+
Component.onDestruction: {
110+
if (textChanged) {
111+
root.accepted()
112+
}
111113
}
112114
}

meshroom/ui/reconstruction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ def evaluateMathExpression(self, expr):
11791179
res = mev.evaluate(expr)
11801180
return [res, False]
11811181
except Exception as err:
1182+
self.parent().showMessage(f"Invalid field expression : {expr}", "error")
11821183
return [None, True]
11831184

11841185
selectedViewIdChanged = Signal()

0 commit comments

Comments
 (0)