Skip to content

Commit 99614b6

Browse files
authored
Merge pull request #3063 from ControlSystemStudio/CSSTUDIO-2472
CSSTUDIO-2472 Bugfix: Fix freezes of Display Runtime when rapidly changing between embedded displays
2 parents 187d6b6 + 27cc9d2 commit 99614b6

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
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
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ public void dispose()
251251
logger.log(Level.WARNING, "Missing JFX parent for " + model_widget);
252252
else
253253
JFXRepresentation.getChildren(parent).remove(jfx_node);
254-
jfx_node = null;
255254
}
256255

257256
/** Get parent that would be used for child-widgets.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,5 @@ public void dispose()
736736
{
737737
super.dispose();
738738
plot.dispose();
739-
plot = null;
740739
}
741740
}

app/display/representation/src/main/java/org/csstudio/display/builder/representation/WidgetRepresentation.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,5 @@ public void initialize(final ToolkitRepresentation<TWP, TW> toolkit,
8686
void destroy()
8787
{
8888
dispose();
89-
90-
// Speedup GC
91-
model_widget = null;
92-
toolkit = null;
9389
}
9490
}

0 commit comments

Comments
 (0)