changeset 3446:d38ece4804d2

RT-30036: [TableView] custom skin implementation applying causes null pointer
author jgiles
date Tue, 30 Apr 2013 10:47:36 +1200
parents d22a053e7385
children 2d98a575a794
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkinBase.java
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java	Tue Apr 30 09:24:21 2013 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java	Tue Apr 30 10:47:36 2013 +1200
@@ -45,6 +45,7 @@
 import javafx.geometry.VPos;
 import javafx.scene.control.CheckMenuItem;
 import javafx.scene.control.ContextMenu;
+import javafx.scene.control.Control;
 import javafx.scene.control.Label;
 import javafx.scene.control.TableColumn;
 import javafx.scene.control.TableColumnBase;
@@ -94,7 +95,10 @@
     private void updateTableWidth() {
         // snapping added for RT-19428
         double padding = snapSize(getTablePadding().getLeft()) + snapSize(getTablePadding().getRight());
-        this.tableWidth = snapSize(tableSkin.getSkinnable().getWidth()) - padding;
+        
+        Control c = tableSkin.getSkinnable();
+        this.tableWidth = c == null ? 0 : snapSize(c.getWidth()) - padding;
+        
         clip.setWidth(tableWidth);
     }
 
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkinBase.java	Tue Apr 30 09:24:21 2013 +1200
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkinBase.java	Tue Apr 30 10:47:36 2013 +1200
@@ -149,7 +149,8 @@
         tableHeaderRow.setFocusTraversable(false);
         control.paddingProperty().addListener(new InvalidationListener() {
             @Override public void invalidated(Observable valueModel) {
-                tableHeaderRow.setTablePadding(getSkinnable().getInsets());
+                C c = getSkinnable();
+                tableHeaderRow.setTablePadding(c == null ? Insets.EMPTY : c.getInsets());
             }
         });
 
@@ -675,7 +676,10 @@
 
     private void refreshView() {
         rowCountDirty = true;
-        getSkinnable().requestLayout();
+        Control c = getSkinnable();
+        if (c != null) {
+            c.requestLayout();
+        }
     }
 
     private int itemCount = -1;