RFR: 8255248: NullPointerException in JFXPanel due to race condition in HostContainer [v3]
Andy Goryachev
angorya at openjdk.org
Mon Jul 24 14:51:51 UTC 2023
On Mon, 24 Jul 2023 06:55:19 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 1069:
>>
>>> 1067:
>>> 1068: @Override
>>> 1069: public void setEmbeddedScene(EmbeddedSceneInterface embeddedScene) {
>>
>> Same comment as with `setEmbeddedStage`; surrounding all accesses to `scenePeer` and `stagePeer` like this is not the way to do it, and looks incorrect. I think this is more in the right direction:
>>
>> public void setEmbeddedScene(EmbeddedSceneInterface embeddedScene) {
>> synchronized(LOCK) {
>> if (scenePeer == embeddedScene) {
>> return;
>> }
>> scenePeer = embeddedScene;
>> }
>>
>> if (embeddedScene == null) {
>> invokeOnClientEDT(() -> {
>> if (dnd != null) {
>> dnd.removeNotify();
>> dnd = null;
>> }
>> });
>> return;
>> }
>> if (pWidth > 0 && pHeight > 0) {
>> embeddedScene.setSize(pWidth, pHeight);
>> }
>> embeddedScene.setPixelScaleFactors((float) scaleFactorX, (float) scaleFactorY);
>>
>> invokeOnClientEDT(() -> {
>> dnd = new SwingDnD(JFXPanel.this, scenePeer);
>> dnd.addNotify();
>> embeddedScene.setDragStartListener(dnd.getDragStartListener());
>> });
>> }
>
> ok
this code looks much better - eliminates TOC/TOU concern
https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1178#discussion_r1272372993
More information about the openjfx-dev
mailing list