Skip to content

Commit

Permalink
Merge pull request #3063 from ControlSystemStudio/CSSTUDIO-2472
Browse files Browse the repository at this point in the history
CSSTUDIO-2472 Bugfix: Fix freezes of Display Runtime when rapidly changing between embedded displays
  • Loading branch information
abrahamwolk authored Jul 9, 2024
2 parents 187d6b6 + 27cc9d2 commit 99614b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 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();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ public void dispose()
logger.log(Level.WARNING, "Missing JFX parent for " + model_widget);
else
JFXRepresentation.getChildren(parent).remove(jfx_node);
jfx_node = null;
}

/** Get parent that would be used for child-widgets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,5 @@ public void dispose()
{
super.dispose();
plot.dispose();
plot = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,5 @@ public void initialize(final ToolkitRepresentation<TWP, TW> toolkit,
void destroy()
{
dispose();

// Speedup GC
model_widget = null;
toolkit = null;
}
}

0 comments on commit 99614b6

Please sign in to comment.