changeset 1294:06a917ba0bfa

RT-22385: TableView leaks memory
author jgiles
date Wed, 13 Jun 2012 13:43:08 +1200
parents 541a5c63514f
children 8dc0f0d957e0
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java javafx-ui-controls/src/javafx/scene/control/TableCell.java
diffstat 2 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java	Wed Jun 13 13:19:26 2012 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java	Wed Jun 13 13:43:08 2012 +1200
@@ -27,7 +27,6 @@
 
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.WeakHashMap;
 
@@ -188,6 +187,8 @@
         }
     }
 
+    private int columnCount = 0;
+    
     private void recreateCells() {
         // This function is smart in the sense that we don't recreate all
         // TableCell instances every time this function is called. Instead we
@@ -205,11 +206,13 @@
         
         ObservableList<TableColumn<T,?>> columns = table.getVisibleLeafColumns();
         
-        if (fullRefreshCounter == 0 || cellsMap == null) {
+        if (columns.size() != columnCount || fullRefreshCounter == 0 || cellsMap == null) {
             clearCellsMap();
             cellsMap = new WeakHashMap<TableColumn, TableCell>(columns.size());
             fullRefreshCounter = DEFAULT_FULL_REFRESH_COUNTER;
+            getChildren().clear();
         }
+        columnCount = columns.size();
         fullRefreshCounter--;
         
         for (TableColumn col : columns) {
--- a/javafx-ui-controls/src/javafx/scene/control/TableCell.java	Wed Jun 13 13:19:26 2012 +1200
+++ b/javafx-ui-controls/src/javafx/scene/control/TableCell.java	Wed Jun 13 13:43:08 2012 +1200
@@ -168,13 +168,11 @@
             updateColumnIndex();
         }
 
-        @Override
-        public Object getBean() {
+        @Override public Object getBean() {
             return TableCell.this;
         }
 
-        @Override
-        public String getName() {
+        @Override public String getName() {
             return "tableColumn";
         }
     };