flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dimitri kara (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FLEX-34611) Application crash when textFlow property set to null with preserveSelection
Date Fri, 17 Oct 2014 14:11:33 GMT
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:
	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,


The problem is the fact that when a RichEditableText has its textFlow property set to null,
the TextContainerManager class make this call:
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

View raw message