You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flex.apache.org by "dimitri kara (JIRA)" <ji...@apache.org> on 2014/10/17 16:11:33 UTC
[jira] [Created] (FLEX-34611) Application crash when textFlow
property set to null with preserveSelection
dimitri kara created FLEX-34611:
-----------------------------------
Summary: Application crash when textFlow property set to null with preserveSelection
Key: FLEX-34611
URL: https://issues.apache.org/jira/browse/FLEX-34611
Project: Apache Flex
Issue Type: Bug
Components: Spark: RichEditableText
Reporter: dimitri kara
In the TextContainerManager class, the setText method has this starting code:
{quote}
public function setText(text:String):void
{
var hadPreviousSelection:Boolean = false;
var selectionChanged:Boolean = false;
var selectionState:SelectionState = null;
var oldAnchorPosition:int = -1;
var oldActivePosition:int = -1;
if (_sourceState == SOURCE_TEXTFLOW)
{
if (_textFlow.interactionManager && _textFlow.interactionManager.hasSelection()){
hadPreviousSelection = true;
//preserve the selection state
*if (_preserveSelectionOnSetText)*
{
oldAnchorPosition = Math.min(_textFlow.interactionManager.anchorPosition, *text.length*);
oldActivePosition = Math.min(_textFlow.interactionManager.activePosition, text.length);
...
{quote}
The problem is the fact that when a RichEditableText has its textFlow property set to null, the TextContainerManager class make this call:
*setText(null);*
Then, if _preserveSelectionOnSetText is true, we have a null object reference error because of line #583
*oldAnchorPosition = Math.min(_textFlow.interactionManager.anchorPosition, text.length);*
with the text variable equal to null
The problem is worse in debug, because each time the error is thrown the app lose focus because of the debugger, and the error is thrown again because of the activate event when the app regain focus, resulting in crash or unusable app.
The solution seems quite simple: check that text is not null before trying to restore selection.
line 581 would be:
*if (_preserveSelectionOnSetText && text)*
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)