|
3 | 3 |
|
4 | 4 | import ast |
5 | 5 | import math # Imported here so it can be used easily by the setting functions. |
6 | | -from typing import Any, Dict, Callable, Set, FrozenSet, NamedTuple |
| 6 | +from typing import Any, Dict, Callable, Set, FrozenSet, NamedTuple, Optional |
7 | 7 |
|
8 | 8 | from UM.Settings.Interfaces import ContainerInterface |
| 9 | +from UM.Settings.PropertyEvaluationContext import PropertyEvaluationContext |
9 | 10 | from UM.Logger import Logger |
10 | 11 |
|
11 | 12 | MYPY = False |
@@ -54,16 +55,19 @@ def __init__(self, code: str) -> None: |
54 | 55 | Logger.log("e", "Exception in function ({0}) for setting: {1}".format(str(e), self._code)) |
55 | 56 |
|
56 | 57 | ## Call the actual function to calculate the value. |
57 | | - def __call__(self, value_provider: ContainerInterface) -> Any: |
| 58 | + def __call__(self, value_provider: ContainerInterface, context: Optional[PropertyEvaluationContext] = None) -> Any: |
58 | 59 | if not value_provider: |
59 | 60 | return None |
60 | 61 |
|
61 | 62 | if not self._valid: |
62 | 63 | return None |
63 | 64 |
|
64 | 65 | locals = {} # type: Dict[str, Any] |
| 66 | + # if there is a context, evaluate the values from the perspective of the original caller |
| 67 | + if context is not None: |
| 68 | + value_provider = context.rootStack() |
65 | 69 | for name in self._used_values: |
66 | | - value = value_provider.getProperty(name, "value") |
| 70 | + value = value_provider.getProperty(name, "value", context) |
67 | 71 | if value is None: |
68 | 72 | continue |
69 | 73 |
|
|
0 commit comments