Bug #5723
closedreferences to parameter are not always renamed
0%
Description
If a parameter is referenced by another parameter, then renaming the former is not always reflected in the latter. The seems to happen when the latter is a string parameter.
To reproduce:
1. add a String Parameter to the canvas
2. rename to x
3. add a String Replace actor to the canvas
4. double-click on String Replace, set pattern to $x, close dialog
5. rename x to y
6. double-click on String Replace, pattern is set to y instead of $y
Updated by Christopher Brooks about 12 years ago
That's a strange bug.
I think the problem is with the $x syntax in the pattern PortParameter that is in string mode.
ptolemy/actor/gui/RenameConfigurer.java generates a MoMLChangeRequest
that looks like:
<property name="x"><rename name="y"/></property>
MoMLParser parses it and calls ptolemy.data.expr.Variable.setName() which
finds the listeners and sets the expression in an unusual manner:
--start--
if (_valueListeners != null) {
Iterator listeners = _valueListeners.iterator();
while (listeners.hasNext()) {
ValueListener listener = (ValueListener) listeners
.next();
if (listener instanceof Variable) {
// The listener could be referencing this variable.
ParseTreeFreeVariableRenamer renamer = new ParseTreeFreeVariableRenamer();
((Variable) listener)._parseIfNecessary();
renamer.renameVariables(
((Variable) listener)._parseTree,
(Variable) listener, this, name);
ParseTreeWriter writer = new ParseTreeWriter();
((Variable) listener)
.setExpression(writer
.parseTreeToExpression(((Variable) listener)._parseTree));
changed.add(listener);
}
}
}
super.setName(name);
// With the new name, we may now shadow variables that
// were not previously shadowed. Invalidate those. _invalidateShadowedSettables(getContainer());
validate();
--end---
I think the problem is that the $x expression is getting evaluated somewhere.
Updated by Daniel Crawl almost 12 years ago
I added some test cases for this to $PTII/ptolemy/data/expr/test/Parameter.tcl.
Updated by Daniel Crawl over 11 years ago
- Status changed from New to Resolved
Fixed. I also added another test to Rename.tcl.