From d12d75ae842613ff7513d2b37ceb642666cea0fb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 09:37:36 +0000 Subject: [PATCH 1/2] Initial plan From 1666a55da40ea61475971efebab5da34b74a526a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Mar 2026 09:39:26 +0000 Subject: [PATCH 2/2] Fix StatsAppState.setEnabled NPE when called before initialization When setEnabled() is called before initialize() (e.g. in simpleInitApp), fpsText/darkenFps/statsView/darkenStats are null, causing an NPE. Fix: add a null guard at the start of setEnabled() that returns early if the UI components haven't been created yet. The enabled flag is still saved via super.setEnabled(). Then, at the end of initialize(), call setEnabled(isEnabled()) to apply any pre-initialization enabled state to the freshly created components. Agent-Logs-Url: https://github.com/jMonkeyEngine/jmonkeyengine/sessions/4fd1f71f-451e-4425-8e83-ae69d6b1ce0a Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com> --- jme3-core/src/main/java/com/jme3/app/StatsAppState.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/app/StatsAppState.java b/jme3-core/src/main/java/com/jme3/app/StatsAppState.java index 52a2939143..2078626a9c 100644 --- a/jme3-core/src/main/java/com/jme3/app/StatsAppState.java +++ b/jme3-core/src/main/java/com/jme3/app/StatsAppState.java @@ -161,6 +161,9 @@ public void initialize(AppStateManager stateManager, Application app) { loadFpsText(); loadStatsView(); loadDarken(); + + // Apply any enabled state set before initialization + setEnabled(isEnabled()); } /** @@ -217,6 +220,11 @@ public void loadDarken() { public void setEnabled(boolean enabled) { super.setEnabled(enabled); + if (fpsText == null) { + // Not yet initialized; the enabled state will be applied in initialize() + return; + } + if (enabled) { fpsText.setCullHint(showFps ? CullHint.Never : CullHint.Always); darkenFps.setCullHint(showFps && darkenBehind ? CullHint.Never : CullHint.Always);