Skip to content

Commit 82c7bf2

Browse files
authored
Merge pull request #2681 from ControlSystemStudio/CSSTUDIO-1919-branch2
CSSTUDIO-1911 Bug-fix: macros should be expanded in the context of the widget they are defined in
2 parents 03c93d8 + b98da12 commit 82c7bf2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

app/display/model/src/main/java/org/csstudio/display/builder/model/macros/DisplayMacroExpander.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ public class DisplayMacroExpander
2828
*/
2929
public static void expandDisplayMacros(final DisplayModel model) throws Exception
3030
{
31-
expand(model.runtimeChildren(), model.getMacrosOrProperties());
31+
expand(model.runtimeChildren());
3232
}
3333

34-
private static void expand(final ChildrenProperty widgets, MacroValueProvider input) throws Exception
34+
private static void expand(final ChildrenProperty widgets) throws Exception
3535
{
3636
for (Widget widget : widgets.getValue())
3737
{
3838
final Optional<WidgetProperty<Macros>> macros = widget.checkProperty(CommonWidgetProperties.propMacros);
3939
if (macros.isPresent())
40-
macros.get().getValue().expandValues(input);
40+
macros.get().getValue().expandValues(widget.getMacrosOrProperties());
4141
// Recurse
4242
final ChildrenProperty children = ChildrenProperty.getChildren(widget);
4343
if (children != null)
44-
expand(children, widget.getMacrosOrProperties());
44+
expand(children);
4545
}
4646
}
4747
}

app/display/model/src/test/java/org/csstudio/display/builder/model/macros/MacroHierarchyUnitTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ public void testTimeOfExpansion() throws Exception
166166
// When macros are expanded as the runtime starts..
167167
DisplayMacroExpander.expandDisplayMacros(model);
168168

169-
// ..you get $(P)="display"
169+
// ..you get $(P)="group", since 'subgroup' defines 'P' as
170+
// '$(SAVE)', and 'group' defines 'SAVE' as '$(P)' and
171+
// 'P' as 'group'.
170172
macros = label.getEffectiveMacros();
171173
System.out.println(macros);
172-
assertThat(macros.getValue("P"), equalTo("display"));
173-
assertThat(MacroHandler.replace(macros, "$(P)"), equalTo("display"));
174+
assertThat(macros.getValue("P"), equalTo("group"));
175+
assertThat(MacroHandler.replace(macros, "$(P)"), equalTo("group"));
174176
}
175177
}

0 commit comments

Comments
 (0)