@@ -160,6 +160,8 @@ private synchronized ExceptionPopOver getPopover() {
160
160
final ExceptionPopOver newPopOver = new ExceptionPopOver (this .popOverTitle );
161
161
// Scene and root are null when the the constructor is called
162
162
// 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" ;
163
165
final Parent root = getScene ().getRoot ();
164
166
newPopOver .getRoot ().getStylesheets ().addAll (root .getStylesheets ());
165
167
newPopOver .getRoot ().setStyle (root .getStyle ());
@@ -170,6 +172,10 @@ private synchronized ExceptionPopOver getPopover() {
170
172
171
173
@ Subscribe
172
174
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
+ }
173
179
if (event .getOrigin ().equals (origin )) {
174
180
// Not timing sensitive. Can remain Platform.runLater
175
181
Platform .runLater (() -> {
@@ -184,6 +190,10 @@ public void onExceptionEvent(ExceptionEvent event) {
184
190
185
191
@ Subscribe
186
192
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
+ }
187
197
if (event .getOrigin ().equals (origin )) {
188
198
// Not timing sensitive. Can remain Platform.runLater
189
199
Platform .runLater (() -> {
0 commit comments