modules/graphics/src/main/java/javafx/scene/Parent.java

Print this page

        

*** 495,505 **** } if (old.getParent() == Parent.this) { old.setParent(null); old.setScenes(null, null); } ! if (!removedChildrenOptimizationDisabled) { removed.add(old); } } } } --- 495,508 ---- } if (old.getParent() == Parent.this) { old.setParent(null); old.setScenes(null, null); } ! // Do not add parent with null scene to the removed list. ! // It will not be processed in the list and its memory ! // will not be freed. ! if (scene != null && !removedChildrenOptimizationDisabled) { removed.add(old); } } } }
*** 644,660 **** --- 647,671 ---- childrenTriggerPermutation = false; } } } + // This method is to do cleanup on parent when it is removed from a scene + private void nullSceneCleanup() { + if (removed != null) { + removed.clear(); + } + } + @Override void scenesChanged(final Scene newScene, final SubScene newSubScene, final Scene oldScene, final SubScene oldSubScene) { if (oldScene != null && newScene == null) { // RT-34863 - clean up CSS cache when Parent is removed from scene-graph StyleManager.getInstance().forget(this); + nullSceneCleanup(); } for (int i=0; i<children.size(); i++) { children.get(i).setScenes(newScene, newSubScene); }