Skip to content

Commit

Permalink
CSSTUDIO-2472 Run dispose() on the UI-thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
abrahamwolk committed Jul 4, 2024
1 parent 86b1786 commit 27cc9d2
Showing 1 changed file with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;

import javafx.application.Platform;
import org.csstudio.display.builder.model.DirtyFlag;
import org.csstudio.display.builder.model.DisplayModel;
import org.csstudio.display.builder.model.UntypedWidgetPropertyListener;
Expand Down Expand Up @@ -473,24 +474,26 @@ else if (inner.getHeight() != 0.0 && inner.getWidth() != 0.0)
@Override
public void dispose()
{
// When the file name is changed, updatePendingDisplay()
// will atomically update the active_content_model,
// represent the new model, and then set runtimePropEmbeddedModel.
//
// Fetching the embedded model from active_content_model
// could dispose a representation that hasn't been represented, yet.
// Fetching the embedded model from runtimePropEmbeddedModel
// could fail to dispose what's just now being represented.
//
// --> Very unlikely to happen because runtime has been stopped,
// so nothing is changing the file name right now.
final DisplayModel em = active_content_model.getAndSet(null);
model_widget.runtimePropEmbeddedModel().setValue(null);

if (inner != null && em != null)
toolkit.disposeRepresentation(em);
inner = null;

super.dispose();
Platform.runLater(() -> {
// When the file name is changed, updatePendingDisplay()
// will atomically update the active_content_model,
// represent the new model, and then set runtimePropEmbeddedModel.
//
// Fetching the embedded model from active_content_model
// could dispose a representation that hasn't been represented, yet.
// Fetching the embedded model from runtimePropEmbeddedModel
// could fail to dispose what's just now being represented.
//
// --> Very unlikely to happen because runtime has been stopped,
// so nothing is changing the file name right now.
final DisplayModel em = active_content_model.getAndSet(null);
model_widget.runtimePropEmbeddedModel().setValue(null);

if (inner != null && em != null)
toolkit.disposeRepresentation(em);
inner = null;

super.dispose();
});
}
}

0 comments on commit 27cc9d2

Please sign in to comment.