Skip to content

Commit 9ddf261

Browse files
committed
Copy globalVarScopedMap entry on PlayerCharacter clone
PlayerCharacter.clone() invokes bean.copyContents(id, aClone.id) on every facet, but AbstractItemFacet.copyContents() copies the underlying map directly without going through set(), so ScopeFacet.set()'s side effect of registering the GlobalPCVarScoped sentinel was skipped on the clone. The cloned character then had a null entry in globalVarScopedMap, and getGlobalScope() handed back a ScopeInstance whose owner was null, causing NullPointerExceptions in VarScoped.getProviderFor() during the 26 pcGenGUI*Test save/restore flows. Override copyContents() to also copy the globalVarScopedMap entry.
1 parent bd9e821 commit 9ddf261

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ public boolean set(CharID id, ScopeInstanceFactory factory)
4545
return result;
4646
}
4747

48+
@Override
49+
public void copyContents(CharID source, CharID copy)
50+
{
51+
super.copyContents(source, copy);
52+
GlobalPCVarScoped globalVS = globalVarScopedMap.get(source);
53+
if (globalVS != null)
54+
{
55+
globalVarScopedMap.put(copy, globalVS);
56+
}
57+
}
58+
4859
@Override
4960
public ScopeInstanceFactory remove(CharID id)
5061
{

0 commit comments

Comments
 (0)