Skip to content

Detach character views before closing all characters - #7795

Merged
Vest merged 1 commit into
PCGen:masterfrom
Vest:fix/close-all-characters-order
Nov 26, 2026
Merged

Vest merged 1 commit into
PCGen:masterfrom
Vest:fix/close-all-characters-order

Conversation

@Vest

@Vest Vest commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #7790.

#7790 stopped FormattedFieldHandler from treating every property change (e.g. ancestor during frame disposal) as a value edit. That removed the trigger of the quit-time NPE, but not the underlying condition: a handler still attached to a closed character.

One path still produces that condition on master. When more than one character is unsaved and the user picks Save none, CharacterManager.removeAllCharacters() closed every character before clearing the party list. CharacterTabs only detaches the tab models (clearStateMap → storeModels → uninstall) when it receives the list change, so for that window the UI fields stayed bound to closed characters.

Changes

  • removeAllCharacters() now snapshots the open characters, clears the party list first so views detach, and then closes each character. This matches the order removeCharacter() already uses.
  • CharacterManagerTest: list listeners are notified before any character is closed, and every character is still closed.
  • FormattedFieldHandlerTest: regression coverage for Fix NPE in age field handler when closing PCGen #7790. Non-value property changes are not forwarded, committed values are, and an uninstalled handler is inert.

Verification

  • The new CharacterManagerTest fails on the old order (expected: <[]> but was: <[first, second]>) and passes with the change.
  • With Fix NPE in age field handler when closing PCGen #7790 temporarily reverted, FormattedFieldHandlerTest fails (but was: <[5, 5, 5]>).
  • ./gradlew build passes.

The only other listener on the party list, CompanionSupportFacadeImpl.elementsChanged, iterates the now-empty list and does nothing.

"Save none" closed every character before clearing the party list, so the
character tabs still had field handlers attached to closed characters until
the list change arrived. Clear the list first, matching removeCharacter, so
views detach while the characters are still usable.

Add regression tests for the close order and for FormattedFieldHandler
forwarding only "value" changes (PCGen#7790).
@Vest Vest self-assigned this Nov 26, 2026
@Vest Vest added the bug label Nov 26, 2026
@Vest
Vest merged commit f82b6e7 into PCGen:master Nov 26, 2026
4 checks passed
@Vest
Vest deleted the fix/close-all-characters-order branch November 26, 2026 12:35
@github-actions

Copy link
Copy Markdown
Contributor

🚧 PCGen Code Coverage

Overall Project 28.14% ❌
Files changed 100% 🍏

File Coverage
CharacterManager.java 8.22% 🍏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant