Skip to content

Commit 2ace84f

Browse files
committed
Restore processSolver after addModifier/removeModifier in SolverManagerFacet
The Phase 6 API migration (094525d) replaced addModifierAndSolve() with addModifier() but omitted the follow-up processSolver() call that recomputes the variable value. Without it, modifiers were registered but never evaluated, causing GlobalModifyTest to hang waiting for a value that was never computed. Also short-circuit global-scope resolution: when the target scope is global, call scopeFacet.getGlobalScope() directly instead of walking the VarScoped hierarchy — global variables have no meaningful scoped object to traverse. In GlobalModifyTest.targetFacetCount(), guard against an empty diagnose list (which is valid when no solver has been built yet) and remove a stale comment about a missing API method.
1 parent febc907 commit 2ace84f

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

code/src/itest/tokencontent/GlobalModifyTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ protected int targetFacetCount()
9898
try
9999
{
100100
List<?> list = sm.diagnose(varID);
101-
size = list.size() - 1;
101+
size = list.isEmpty() ? 0 : list.size() - 1;
102102
}
103103
catch (IllegalArgumentException e)
104104
{
105-
//Really, SolverManager should have isChannel(varID) to avoid diagnose complaining if something doesn't exist
106105
size = 0;
107106
}
108107
return size;

code/src/java/pcgen/cdom/facet/SolverManagerFacet.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ public <T> List<ProcessStep<T>> diagnose(CharID id, VariableID<T> varID)
4949
public <T> boolean addModifier(CharID id, VarModifier<T> vm, VarScoped thisValue, Modifier<T> modifier,
5050
ScopeInstance source)
5151
{
52-
ScopeInstance scope = scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue);
52+
ScopeInstance scope = vm.getLegalScope().isGlobal()
53+
? scopeFacet.getGlobalScope(id)
54+
: scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue);
5355
VariableID<T> varID = (VariableID<T>) loadContextFacet.get(id.getDatasetID()).get().getVariableContext()
5456
.getVariableID(scope, vm.getVarName());
55-
get(id).addModifier(varID, modifier, source);
57+
SolverManager sm = get(id);
58+
sm.addModifier(varID, modifier, source);
59+
sm.processSolver(varID);
5660
return true;
5761
}
5862

@@ -62,10 +66,14 @@ public <T> boolean addModifier(CharID id, VarModifier<T> vm, VarScoped thisValue
6266
public <T> void removeModifier(CharID id, VarModifier<T> vm, VarScoped thisValue, Modifier<T> modifier,
6367
ScopeInstance source)
6468
{
65-
ScopeInstance scope = scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue);
69+
ScopeInstance scope = vm.getLegalScope().isGlobal()
70+
? scopeFacet.getGlobalScope(id)
71+
: scopeFacet.get(id, vm.getFullLegalScopeName(), thisValue);
6672
VariableID<T> varID = (VariableID<T>) loadContextFacet.get(id.getDatasetID()).get().getVariableContext()
6773
.getVariableID(scope, vm.getVarName());
68-
get(id).removeModifier(varID, modifier, source);
74+
SolverManager sm = get(id);
75+
sm.removeModifier(varID, modifier, source);
76+
sm.processSolver(varID);
6977
}
7078

7179
public void setScopeFacet(ScopeFacet scopeFacet)

0 commit comments

Comments
 (0)