|
15 | 15 | import java.util.concurrent.atomic.AtomicReference; |
16 | 16 | import java.util.logging.Level; |
17 | 17 |
|
| 18 | +import javafx.application.Platform; |
18 | 19 | import org.csstudio.display.builder.model.DirtyFlag; |
19 | 20 | import org.csstudio.display.builder.model.DisplayModel; |
20 | 21 | import org.csstudio.display.builder.model.UntypedWidgetPropertyListener; |
@@ -473,24 +474,26 @@ else if (inner.getHeight() != 0.0 && inner.getWidth() != 0.0) |
473 | 474 | @Override |
474 | 475 | public void dispose() |
475 | 476 | { |
476 | | - // When the file name is changed, updatePendingDisplay() |
477 | | - // will atomically update the active_content_model, |
478 | | - // represent the new model, and then set runtimePropEmbeddedModel. |
479 | | - // |
480 | | - // Fetching the embedded model from active_content_model |
481 | | - // could dispose a representation that hasn't been represented, yet. |
482 | | - // Fetching the embedded model from runtimePropEmbeddedModel |
483 | | - // could fail to dispose what's just now being represented. |
484 | | - // |
485 | | - // --> Very unlikely to happen because runtime has been stopped, |
486 | | - // so nothing is changing the file name right now. |
487 | | - final DisplayModel em = active_content_model.getAndSet(null); |
488 | | - model_widget.runtimePropEmbeddedModel().setValue(null); |
489 | | - |
490 | | - if (inner != null && em != null) |
491 | | - toolkit.disposeRepresentation(em); |
492 | | - inner = null; |
493 | | - |
494 | | - super.dispose(); |
| 477 | + Platform.runLater(() -> { |
| 478 | + // When the file name is changed, updatePendingDisplay() |
| 479 | + // will atomically update the active_content_model, |
| 480 | + // represent the new model, and then set runtimePropEmbeddedModel. |
| 481 | + // |
| 482 | + // Fetching the embedded model from active_content_model |
| 483 | + // could dispose a representation that hasn't been represented, yet. |
| 484 | + // Fetching the embedded model from runtimePropEmbeddedModel |
| 485 | + // could fail to dispose what's just now being represented. |
| 486 | + // |
| 487 | + // --> Very unlikely to happen because runtime has been stopped, |
| 488 | + // so nothing is changing the file name right now. |
| 489 | + final DisplayModel em = active_content_model.getAndSet(null); |
| 490 | + model_widget.runtimePropEmbeddedModel().setValue(null); |
| 491 | + |
| 492 | + if (inner != null && em != null) |
| 493 | + toolkit.disposeRepresentation(em); |
| 494 | + inner = null; |
| 495 | + |
| 496 | + super.dispose(); |
| 497 | + }); |
495 | 498 | } |
496 | 499 | } |
0 commit comments