6671481: NPE at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection
authoralexsch
Tue, 04 Dec 2012 15:26:57 +0400
changeset 14655 d524ae0f511e
parent 14654 98b268fecedc
child 14656 6d8446e5b460
6671481: NPE at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection Reviewed-by: serb
jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Fri Nov 30 17:09:05 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Tue Dec 04 15:26:57 2012 +0400
@@ -1941,6 +1941,9 @@
                     for(int counter = beginRow + 1; counter <= endRow; counter++) {
                             testRect = getPathBounds(tree,
                                     getPathForRow(tree, counter));
+                        if (testRect == null) {
+                            return;
+                        }
                         if((testRect.y + testRect.height) > maxY)
                                 counter = endRow;
                             }
@@ -2069,7 +2072,7 @@
                 treeState.invalidatePathBounds(oldPath);
                 updateSize();
             }
-            else {
+            else if (editingBounds != null) {
                 editingBounds.x = 0;
                 editingBounds.width = tree.getSize().width;
                 tree.repaint(editingBounds);
@@ -2114,6 +2117,9 @@
                        tree.isPathSelected(path), tree.isExpanded(path),
                        treeModel.isLeaf(path.getLastPathComponent()), row);
                 Rectangle           nodeBounds = getPathBounds(tree, path);
+                if (nodeBounds == null) {
+                    return false;
+                }
 
                 editingRow = row;
 
@@ -2134,6 +2140,9 @@
                     // To make sure x/y are updated correctly, fetch
                     // the bounds again.
                     nodeBounds = getPathBounds(tree, path);
+                    if (nodeBounds == null) {
+                        return false;
+                    }
                 }
                 else
                     editorHasDifferentSize = false;
@@ -3570,7 +3579,7 @@
             if(pressedPath != null) {
                 Rectangle bounds = getPathBounds(tree, pressedPath);
 
-                if(e.getY() >= (bounds.y + bounds.height)) {
+                if (bounds == null || e.getY() >= (bounds.y + bounds.height)) {
                     return;
                 }
 
@@ -3832,6 +3841,10 @@
 
                     // And repaint
                     Rectangle newMinBounds = getPathBounds(tree, minPath);
+                    if (minBounds == null || newMinBounds == null) {
+                        return;
+                    }
+
                     if (indices.length == 1 &&
                             newMinBounds.height == minBounds.height) {
                         tree.repaint(0, minBounds.y, tree.getWidth(),