[BLUEJ-1294] NullPointerException when closing editor
When closing the editor, it is possible to get in a situation where the window receives focus after the last tab has been closed, which leads to a stack trace like this:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at bluej.editor.stride.FXTabbedEditor.lambda$initialiseFX$6(FXTabbedEditor.java:299)
at bluej.utility.javafx.JavaFXUtil.lambda$addChangeListenerPlatform$26(JavaFXUtil.java:1548)
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:360)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
at javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
at javafx.beans.property.ReadOnlyBooleanWrapper.fireValueChangedEvent(ReadOnlyBooleanWrapper.java:103)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:111)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.stage.Window.setFocused(Window.java:674)
at javafx.stage.Window$1.setFocused(Window.java:149)
at com.sun.javafx.stage.WindowHelper.setFocused(WindowHelper.java:112)
at com.sun.javafx.stage.WindowPeerListener.changedFocused(WindowPeerListener.java:64)
at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:123)
at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:40)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassWindowEventHandler.lambda$handleWindowEvent$4(GlassWindowEventHandler.java:176)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at com.sun.javafx.tk.quantum.GlassWindowEventHandler.handleWindowEvent(GlassWindowEventHandler.java:174)
at com.sun.glass.ui.Window.handleWindowEvent(Window.java:1346)
at com.sun.glass.ui.Window.notifyFocus(Window.java:1325)
at com.sun.glass.ui.mac.MacApplication._enterNestedEventLoopImpl(Native Method)
at com.sun.glass.ui.mac.MacApplication._enterNestedEventLoop(MacApplication.java:109)
at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:509)
at com.sun.glass.ui.mac.MacWindow._setView(Native Method)
at com.sun.glass.ui.Window.setView(Window.java:418)
at com.sun.javafx.tk.quantum.WindowStage.lambda$setScene$1(WindowStage.java:295)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithRenderLock(QuantumToolkit.java:408)
at com.sun.javafx.tk.quantum.WindowStage.setScene(WindowStage.java:291)
at javafx.stage.Window$12.invalidated(Window.java:1130)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.stage.Window.setShowing(Window.java:1174)
at javafx.stage.Window.hide(Window.java:1199)
at com.sun.javafx.stage.WindowCloseRequestHandler.dispatchBubblingEvent(WindowCloseRequestHandler.java:45)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at com.sun.javafx.stage.WindowPeerListener.closing(WindowPeerListener.java:93)
at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:147)
at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:40)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassWindowEventHandler.lambda$handleWindowEvent$4(GlassWindowEventHandler.java:176)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at com.sun.javafx.tk.quantum.GlassWindowEventHandler.handleWindowEvent(GlassWindowEventHandler.java:174)
at com.sun.glass.ui.Window.handleWindowEvent(Window.java:1346)
at com.sun.glass.ui.Window.notifyClose(Window.java:1246)
(The last part of the trace may vary, the problem is that we blindly assume there is still a tab.)
Issue metadata
- Issue type: Bug
- Priority: Medium
- Fix versions: 5.0.0