Skip to content

Commit 27cc9d2

Browse files
committed
CSSTUDIO-2472 Run dispose() on the UI-thread.
1 parent 86b1786 commit 27cc9d2

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/EmbeddedDisplayRepresentation.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.concurrent.atomic.AtomicReference;
1616
import java.util.logging.Level;
1717

18+
import javafx.application.Platform;
1819
import org.csstudio.display.builder.model.DirtyFlag;
1920
import org.csstudio.display.builder.model.DisplayModel;
2021
import org.csstudio.display.builder.model.UntypedWidgetPropertyListener;
@@ -473,24 +474,26 @@ else if (inner.getHeight() != 0.0 && inner.getWidth() != 0.0)
473474
@Override
474475
public void dispose()
475476
{
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+
});
495498
}
496499
}

0 commit comments

Comments
 (0)