Fix NPE on load and improve row clicking#7590
Conversation
karianna
commented
Jun 6, 2026
- build.gradle: fix clean/download race and merged-module missing JDK requires (build.gradle: fix clean/download race and merged-module missing JDK requires #7583)
- build.gradle, reporting.gradle: small cleanups (build.gradle, reporting.gradle: small cleanups #7584)
- Build cleanup: distribution / plugins / release.gradle drive-by fixes (Build cleanup: distribution / plugins / release.gradle drive-by fixes #7585)
- fix NPE on PCGen load, update Agent instructions, stabalize some UI elements (row open/close)
…lements (row open/close)
Independent review — verdict: merge with nitsNPE fix looks structurally correct. Splitting FindingsNone of these block merge.
RecommendationMerge as-is is fine; ideally fix nit #1 first (or remove the version table) since the PR explicitly establishes the rule that AGENTS.md should stay accurate. Nits 2 and 3 are good follow-up material. (Reviewed by an LLM agent; happy to clarify any of the above.) |
Update: ran the repro locally — PR introduces a startup regressionFollowed up on my own review by actually running both the parent commit and this PR's HEAD on macOS Retina (Built-in Liquid Retina XDR, 3456×2234). Setup: moved repo Old code (
|
|
@karianna my bot agrees with you. I think, you can merge. |
There was a problem hiding this comment.
Pull request overview
This PR replaces use of JFXPanel-backed FXML loaders for standalone dialogs with a new PanelFromResource helper to avoid a macOS HiDPI JavaFX embedded-scene NPE, and updates developer/agent documentation accordingly.
Changes:
- Introduce
pcgen.gui3.PanelFromResourcefor opening FXML dialogs as standaloneStages (non-embedded) and migrate several call sites to it. - Remove stage-opening APIs from
JFXPanelFromResourceand clarify its intended Swing-embedding-only usage. - Update
AGENTS.mdand.gitignore.
Show a summary per file
| File | Description |
|---|---|
| code/src/java/pcgen/system/Main.java | Switches options-path prompt to PanelFromResource during startup. |
| code/src/java/pcgen/gui3/PanelFromResource.java | New helper for loading/showing FXML as a standalone Stage; adds blocking show API. |
| code/src/java/pcgen/gui3/JFXPanelFromResource.java | Removes stage APIs and documents Swing-embedding-only constraint. |
| code/src/java/pcgen/gui3/component/PCGenToolBar.java | Uses PanelFromResource for the export dialog. |
| code/src/java/pcgen/gui2/prefs/PurchaseModeFrame.java | Uses PanelFromResource for the “New Purchase Method” dialog. |
| code/src/java/pcgen/gui2/PCGenActionMap.java | Uses PanelFromResource for calculator/export dialogs. |
| AGENTS.md | Expands build/test guidance and JavaFX dialog guidance. |
| .gitignore | Ignores .superset/. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
code/src/java/pcgen/system/Main.java:266
startupWithGUI()callsloadProperties(true)before JavaFX is initialized (new JFXPanel()happens later). With this change,loadPropertiesmay callPanelFromResource.showAndBlock(...), which usesPlatform.runLater(...)and will throwIllegalStateException: Toolkit not initializedwhen the settings dir prompt is needed. Previously theJFXPanelFromResourceconstructor implicitly initialized JavaFX viaJFXPanel.
var panel = new PanelFromResource<>(
OptionsPathDialogController.class,
"OptionsPathDialog.fxml"
);
panel.showAndBlock("Directory for options.ini location");
}
- Files reviewed: 7/8 changed files
- Comments generated: 4
PanelFromResource.showAndBlock/showAsStage now lazily bootstrap the JavaFX toolkit before scheduling work on the FX thread. The previous JFXPanelFromResource implicitly started the toolkit via its JFXPanel superclass; PanelFromResource is a plain POJO and did not, so on a fresh install (no settings.files.path, no -s argument) the OptionsPathDialog opened from Main.loadProperties hit Platform.runLater before any JFXPanel was constructed and threw IllegalStateException: Toolkit not initialized, killing the JVM before the dialog could appear. The new ensureToolkitInitialized helper calls Platform.startup (catching IllegalStateException for the already-running case) and forces implicitExit to false so closing this dialog does not tear down JavaFX before the rest of the GUI brings up its own Stages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>