You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Bill van Melle (Created) (JIRA)" <ji...@apache.org> on 2011/11/02 03:04:32 UTC
[jira] [Created] (PIVOT-814) TextArea#getText throws
IndexOutOfBoundsException when called from TextChanged method under setText
TextArea#getText throws IndexOutOfBoundsException when called from TextChanged method under setText
---------------------------------------------------------------------------------------------------
Key: PIVOT-814
URL: https://issues.apache.org/jira/browse/PIVOT-814
Project: Pivot
Issue Type: Bug
Components: wtk
Affects Versions: 2.0.1
Reporter: Bill van Melle
Priority: Minor
Within the textChanged listener on my TextArea, I (naturally) call getText. This works fine if textChanged was called as a result of typing into the TextArea. But if it was fired because of a call to setText elsewhere in my program, getText throws IndexOutOfBoundsException. The stack looks like this:
ArrayList<T>.verifyIndexBounds(int, int, int) line: 577
ArrayList<T>.get(int) line: 346
TextArea.getParagraphAt(int) line: 853
TextArea.getText(int, int) line: 632
TextArea.getText() line: 606
<mycode>$2.textChanged(TextArea) line: 122
TextArea$TextAreaContentListenerList.textChanged(TextArea) line: 518
TextArea$ParagraphSequence.remove(int, int) line: 421
TextArea.setText(Reader) line: 722
TextArea.setText(String) line: 667
My workaround is to check for getCharacterCount() being positive before calling getText.
Here's a test case:
<Window title="Empty text area bug" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
xmlns="org.apache.pivot.wtk">
<BoxPane orientation="vertical" styles="{fill:true}">
<PushButton buttonData="Set text">
<buttonPressListeners>
function buttonPressed(button) {
textArea.setText("This is some text");
}
</buttonPressListeners>
</PushButton>
<TextArea bxml:id="textArea">
<textAreaContentListeners>
function textChanged(textArea) {
importPackage(org.apache.pivot.wtk);
Alert.alert(MessageType.INFO, "Text is " + textArea.getText(), textArea.getWindow());
}
</textAreaContentListeners>
</TextArea>
</BoxPane>
</Window>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (PIVOT-814) TextArea#getText throws
IndexOutOfBoundsException when called from TextChanged method under setText
Posted by "Noel Grandin (Resolved) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIVOT-814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Noel Grandin resolved PIVOT-814.
--------------------------------
Resolution: Fixed
Fixed in rev 1196545
> TextArea#getText throws IndexOutOfBoundsException when called from TextChanged method under setText
> ---------------------------------------------------------------------------------------------------
>
> Key: PIVOT-814
> URL: https://issues.apache.org/jira/browse/PIVOT-814
> Project: Pivot
> Issue Type: Bug
> Components: wtk
> Affects Versions: 2.0
> Reporter: Bill van Melle
> Assignee: Noel Grandin
> Priority: Minor
> Fix For: 2.0.1
>
>
> Within the textChanged listener on my TextArea, I (naturally) call getText. This works fine if textChanged was called as a result of typing into the TextArea. But if it was fired because of a call to setText elsewhere in my program, getText throws IndexOutOfBoundsException. The stack looks like this:
> ArrayList<T>.verifyIndexBounds(int, int, int) line: 577
> ArrayList<T>.get(int) line: 346
> TextArea.getParagraphAt(int) line: 853
> TextArea.getText(int, int) line: 632
> TextArea.getText() line: 606
> <mycode>$2.textChanged(TextArea) line: 122
> TextArea$TextAreaContentListenerList.textChanged(TextArea) line: 518
> TextArea$ParagraphSequence.remove(int, int) line: 421
> TextArea.setText(Reader) line: 722
> TextArea.setText(String) line: 667
> My workaround is to check for getCharacterCount() being positive before calling getText.
> Here's a test case:
> <Window title="Empty text area bug" maximized="true"
> xmlns:bxml="http://pivot.apache.org/bxml"
> xmlns="org.apache.pivot.wtk">
> <BoxPane orientation="vertical" styles="{fill:true}">
> <PushButton buttonData="Set text">
> <buttonPressListeners>
> function buttonPressed(button) {
> textArea.setText("This is some text");
> }
> </buttonPressListeners>
> </PushButton>
> <TextArea bxml:id="textArea">
> <textAreaContentListeners>
> function textChanged(textArea) {
> importPackage(org.apache.pivot.wtk);
> Alert.alert(MessageType.INFO, "Text is " + textArea.getText(), textArea.getWindow());
> }
> </textAreaContentListeners>
> </TextArea>
> </BoxPane>
> </Window>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (PIVOT-814) TextArea#getText throws
IndexOutOfBoundsException when called from TextChanged method under setText
Posted by "Sandro Martini (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIVOT-814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sandro Martini updated PIVOT-814:
---------------------------------
Affects Version/s: (was: 2.0.1)
2.0
Fix Version/s: 2.0.1
Assignee: Noel Grandin
Hi Noel,
can you take a look at this ?
Thank you.
> TextArea#getText throws IndexOutOfBoundsException when called from TextChanged method under setText
> ---------------------------------------------------------------------------------------------------
>
> Key: PIVOT-814
> URL: https://issues.apache.org/jira/browse/PIVOT-814
> Project: Pivot
> Issue Type: Bug
> Components: wtk
> Affects Versions: 2.0
> Reporter: Bill van Melle
> Assignee: Noel Grandin
> Priority: Minor
> Fix For: 2.0.1
>
>
> Within the textChanged listener on my TextArea, I (naturally) call getText. This works fine if textChanged was called as a result of typing into the TextArea. But if it was fired because of a call to setText elsewhere in my program, getText throws IndexOutOfBoundsException. The stack looks like this:
> ArrayList<T>.verifyIndexBounds(int, int, int) line: 577
> ArrayList<T>.get(int) line: 346
> TextArea.getParagraphAt(int) line: 853
> TextArea.getText(int, int) line: 632
> TextArea.getText() line: 606
> <mycode>$2.textChanged(TextArea) line: 122
> TextArea$TextAreaContentListenerList.textChanged(TextArea) line: 518
> TextArea$ParagraphSequence.remove(int, int) line: 421
> TextArea.setText(Reader) line: 722
> TextArea.setText(String) line: 667
> My workaround is to check for getCharacterCount() being positive before calling getText.
> Here's a test case:
> <Window title="Empty text area bug" maximized="true"
> xmlns:bxml="http://pivot.apache.org/bxml"
> xmlns="org.apache.pivot.wtk">
> <BoxPane orientation="vertical" styles="{fill:true}">
> <PushButton buttonData="Set text">
> <buttonPressListeners>
> function buttonPressed(button) {
> textArea.setText("This is some text");
> }
> </buttonPressListeners>
> </PushButton>
> <TextArea bxml:id="textArea">
> <textAreaContentListeners>
> function textChanged(textArea) {
> importPackage(org.apache.pivot.wtk);
> Alert.alert(MessageType.INFO, "Text is " + textArea.getText(), textArea.getWindow());
> }
> </textAreaContentListeners>
> </TextArea>
> </BoxPane>
> </Window>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira