@@ -160,6 +160,8 @@ private synchronized ExceptionPopOver getPopover() {
160160 final ExceptionPopOver newPopOver = new ExceptionPopOver (this .popOverTitle );
161161 // Scene and root are null when the the constructor is called
162162 // They are not null once they are added to a scene.
163+ assert getScene () != null : "Scene should not be null, this object has not been added to the scene yet" ;
164+ assert getScene ().getRoot () != null : "Root should not be null, this object has not been added to the scene yet" ;
163165 final Parent root = getScene ().getRoot ();
164166 newPopOver .getRoot ().getStylesheets ().addAll (root .getStylesheets ());
165167 newPopOver .getRoot ().setStyle (root .getStyle ());
@@ -170,6 +172,10 @@ private synchronized ExceptionPopOver getPopover() {
170172
171173 @ Subscribe
172174 public void onExceptionEvent (ExceptionEvent event ) {
175+ if (getScene () == null || getScene ().getRoot () == null ) {
176+ // We are responding to an event prior to this button being added to the scene. Ignore this for now.
177+ return ;
178+ }
173179 if (event .getOrigin ().equals (origin )) {
174180 // Not timing sensitive. Can remain Platform.runLater
175181 Platform .runLater (() -> {
@@ -184,6 +190,10 @@ public void onExceptionEvent(ExceptionEvent event) {
184190
185191 @ Subscribe
186192 public void onExceptionClearedEvent (ExceptionClearedEvent event ) {
193+ if (getScene () == null || getScene ().getRoot () == null ) {
194+ // We are responding to an event prior to this button being added to the scene. Ignore this for now.
195+ return ;
196+ }
187197 if (event .getOrigin ().equals (origin )) {
188198 // Not timing sensitive. Can remain Platform.runLater
189199 Platform .runLater (() -> {
0 commit comments