changeset 133:a75cdc37b987

RT-18441: TreeItem.equals() calls TreeItem.getChildren(), which is too expensive
author jgiles
date Fri, 09 Dec 2011 08:45:22 +1000
parents 88dc0c2f404e
children 8d6e25f7e160
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java javafx-ui-controls/src/javafx/scene/control/TreeItem.java
diffstat 2 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java	Fri Dec 09 08:07:51 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java	Fri Dec 09 08:45:22 2011 +1000
@@ -209,12 +209,19 @@
             ((TreeCell)flow.cells.get(i)).updateTreeView(null);
         }
         
-        flow.setCellCount(getItemCount());
-
-        // This needs to be recreateCells here (rather than reconfigureCells)
-        // otherwise issues appear when expanding/collapsing branches. For example,
-        // see RT-14013.
-        flow.recreateCells();
+        int oldCount = flow.getCellCount();
+        int newCount = getItemCount();
+        
+        // if this is not called even when the count is the same, we get a 
+        // memory leak in VirtualFlow.sheet.children. This can probably be 
+        // optimised in the future when time permits.
+        flow.setCellCount(newCount);
+        
+        if (newCount != oldCount) {
+            flow.recreateCells();
+        } else {
+            flow.reconfigureCells();
+        }
     }
 
     @Override public TreeCell<T> createCell() {
--- a/javafx-ui-controls/src/javafx/scene/control/TreeItem.java	Fri Dec 09 08:07:51 2011 +1000
+++ b/javafx-ui-controls/src/javafx/scene/control/TreeItem.java	Fri Dec 09 08:45:22 2011 +1000
@@ -722,7 +722,7 @@
         if (this.getParent() != other.getParent() && (this.getParent() == null || !this.getParent().equals(other.getParent()))) {
             return false;
         }
-        if (this.getChildren() != other.getChildren() && (this.getChildren() == null || !this.getChildren().equals(other.getChildren()))) {
+        if (this.children != other.children && (this.children == null || !this.children.equals(other.children))) {
             return false;
         }
         return true;