This fixes an NPE in BasicTextUI, seen with Protege.

2006-06-03  Roman Kennke  <[EMAIL PROTECTED]>

        PR 27418
        * javax/swing/plaf/basic/BasicTextUI.java
        (damageRange): Added null check to avoid NPE.

/Roman

-- 
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/plaf/basic/BasicTextUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextUI.java,v
retrieving revision 1.83
diff -u -1 -0 -r1.83 BasicTextUI.java
--- javax/swing/plaf/basic/BasicTextUI.java	16 May 2006 18:57:33 -0000	1.83
+++ javax/swing/plaf/basic/BasicTextUI.java	3 Jun 2006 15:28:59 -0000
@@ -1032,21 +1032,26 @@
         // BadLocationExceptions. This makes it possible for the highlighter
         // to send us illegal values which can happen when a large number
         // of selected characters are removed (eg. by pressing delete
         // or backspace).
         // The reference implementation does not throw an exception, too.
         p0 = Math.min(p0, t.getDocument().getLength());
         p1 = Math.min(p1, t.getDocument().getLength());
 
         Rectangle l1 = modelToView(t, p0, firstBias);
         Rectangle l2 = modelToView(t, p1, secondBias);
-        if (l1.y == l2.y)
+        if (l1 == null || l2 == null)
+          {
+            // Unable to determine the start or end of the selection.
+            t.repaint();
+          }
+        else if (l1.y == l2.y)
           {
             SwingUtilities.computeUnion(l2.x, l2.y, l2.width, l2.height, l1);
             t.repaint(l1);
           }
         else
           {
             // The two rectangles lie on different lines and we need a
             // different algorithm to calculate the damaged area:
             // 1. The line of p0 is damaged from the position of p0
             // to the right border.

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to