pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roger Whitcomb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PIVOT-954) Double click in empty TextArea causes exception
Date Fri, 18 Jul 2014 22:50:15 GMT

    [ https://issues.apache.org/jira/browse/PIVOT-954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14067040#comment-14067040
] 

Roger Whitcomb commented on PIVOT-954:
--------------------------------------

Here is the diff that fixes the problem:
Index: wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
===================================================================
--- wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (revision 1611499)
+++ wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (working copy)
@@ -966,11 +966,17 @@
         int rowLength = textArea.getRowLength(start);
         if (start - rowStart >= rowLength) {
             start = rowStart + rowLength - 1;
+            if (start < 0) {
+                return;
+            }
             char ch = textArea.getCharacterAt(start);
             if (ch == '\r' || ch == '\n') {
                 start--;
             }
         }
+        if (start < 0) {
+            return;
+        }
         char ch = textArea.getCharacterAt(start);
         int selectionStart = start;
         int selectionLength = 1;


> Double click in empty TextArea causes exception
> -----------------------------------------------
>
>                 Key: PIVOT-954
>                 URL: https://issues.apache.org/jira/browse/PIVOT-954
>             Project: Pivot
>          Issue Type: Bug
>          Components: wtk
>    Affects Versions: 2.0.4, 2.1
>         Environment: All
>            Reporter: Roger Whitcomb
>            Assignee: Roger Whitcomb
>            Priority: Minor
>              Labels: doubleclick, textarea
>             Fix For: 2.1, 2.0.5
>
>
> Start with an empty TextArea, then double click anywhere (which normally would select
the current word), there will be basically an assertion error from here:
> java.lang.IndexOutOfBoundsException: index: index (-1) < min (0)
>         at org.apache.pivot.wtk.Component.indexBoundsCheck(Component.java:2861)
>         at org.apache.pivot.wtk.TextArea.getCharacterAt(TextArea.java:904)
>         at org.apache.pivot.wtk.skin.TextAreaSkin.selectSpan(TextAreaSkin.java:969)
>         at org.apache.pivot.wtk.skin.TextAreaSkin.mouseClick(TextAreaSkin.java:1023)
> The underlying problem is trying to get the character at offset -1 in the document.
> It could also occur in any document in which the first line is empty, and trying to double
click there (with a slightly different stack trace):
> java.lang.IndexOutOfBoundsException: index: index (-1) < min (0)
>         at org.apache.pivot.wtk.Component.indexBoundsCheck(Component.java:2861)
>         at org.apache.pivot.wtk.TextArea.getCharacterAt(TextArea.java:904)
>         at org.apache.pivot.wtk.skin.TextAreaSkin.selectSpan(TextAreaSkin.java:974)
>         at org.apache.pivot.wtk.skin.TextAreaSkin.mouseClick(TextAreaSkin.java:1023)
> (This is from the "trunk" version).



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message