Skip to content

Fix NPE in age field handler when closing PCGen - #7790

Merged
Vest merged 1 commit into
PCGen:masterfrom
royaldark:fix/age-field-npe-on-quit
Nov 26, 2026
Merged

Vest merged 1 commit into
PCGen:masterfrom
royaldark:fix/age-field-npe-on-quit

Conversation

@royaldark

@royaldark royaldark commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor
FormattedFieldHandler listened to every property change on its
JFormattedTextField and treated each one as a value edit. On quit,
disposing the frame fires removeNotify property changes after the
character is closed, which called setAge() on a closed character and
threw an NPE in updateAgeCategoryForAge(). Listen only to the "value"
property.

Fixes stacktraces like the following when exiting:

java.lang.NullPointerException: Cannot invoke "pcgen.core.display.CharacterDisplay.getAgeSet()" because "this.charDisplay" is null
        at pcgen.gui2.facade.CharacterFacadeImpl.updateAgeCategoryForAge(CharacterFacadeImpl.java:2590)
        at pcgen.gui2.facade.CharacterFacadeImpl.setAge(CharacterFacadeImpl.java:2580)
        at pcgen.gui2.tabs.bio.BiographyInfoPane$AgeItem$2.valueChanged(BiographyInfoPane.java:378)
        at pcgen.gui2.tabs.models.FormattedFieldHandler.propertyChange(FormattedFieldHandler.java:89)
        at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:343)
        at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:335)
        at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:268)
        at java.desktop/java.awt.Component.firePropertyChange(Component.java:8670)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4874)
        at java.desktop/javax.swing.text.JTextComponent.removeNotify(JTextComponent.java:1654)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/javax.swing.JComponent.removeNotify(JComponent.java:4870)
        at java.desktop/javax.swing.JRootPane.removeNotify(JRootPane.java:721)
        at java.desktop/java.awt.Container.removeNotify(Container.java:2822)
        at java.desktop/java.awt.Window.removeNotify(Window.java:750)
        at java.desktop/java.awt.Frame.removeNotify(Frame.java:1049)
        at java.desktop/java.awt.Window$1DisposeAction.run(Window.java:1158)
        at java.desktop/java.awt.Window.doDispose(Window.java:1174)
        at java.desktop/java.awt.Window.dispose(Window.java:1115)
        at pcgen.gui2.PCGenUIManager.closePCGen(PCGenUIManager.java:94)
        at pcgen.gui3.application.DesktopHandler$QuitHandler.handleQuitRequestWith(DesktopHandler.java:96)
        at java.desktop/com.apple.eawt._AppEventHandler$_QuitDispatcher.performUsing(_AppEventHandler.java:431)
        at java.desktop/com.apple.eawt._AppEventHandler$_QuitDispatcher.performUsing(_AppEventHandler.java:420)
        at java.desktop/com.apple.eawt._AppEventHandler$_AppEventDispatcher$1.run(_AppEventHandler.java:552)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:323)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:702)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

FormattedFieldHandler listened to every property change on its
JFormattedTextField and treated each one as a value edit. On quit,
disposing the frame fires removeNotify property changes after the
character is closed, which called setAge() on a closed character and
threw an NPE in updateAgeCategoryForAge(). Listen only to the "value"
property.
@Vest
Vest merged commit 7d3331d into PCGen:master Nov 26, 2026
4 checks passed
@Vest Vest added the bug label Nov 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚧 PCGen Code Coverage

Overall Project 28.08% ❌
Files changed 0% ❌

File Coverage
FormattedFieldHandler.java 0% -15.15% ❌

Vest added a commit to Vest/pcgen that referenced this pull request Nov 26, 2026
"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 added a commit that referenced this pull request Nov 26, 2026
"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 (#7790).
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.

2 participants