Steps to reproduce:
# add data to tree using an {{ArrayCollection}} for the children of the root node.
# collapse root of tree
# call {{setItemAt()}} on one of the children in the collapsed root node.
Actual Results:
* item is changed and can be observed the next time the user expands the root node
Expected Results:
* browser hangs and, after significant delay, produces the following error message:
{quote}
Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at mx.controls.treeClasses::HierarchicalCollectionView/nestedCollectionChangeHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\controls\treeClasses\HierarchicalCollectionView.as:726]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ListCollectionView/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:833]
at mx.collections::ListCollectionView/replaceItemsInView()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1433]
at mx.collections::ListCollectionView/listChangeHandler()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1063]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ArrayList/setItemAt()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:269]
at mx.collections::ListCollectionView/setItemAt()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:462]
at sandbox/onClick()[/home/dmcgaffin/bcworkspace/sandbox/src/sandbox.mxml:35]
at sandbox/___sandbox_Button1_click()[/home/dmcgaffin/bcworkspace/sandbox/src/sandbox.mxml:62]
{quote}
Workaround (if any):
* prevent the user from collapsing the root node. It's not great, but works.
Other notes:
This was actually discovered in Flex 2.0.1 but I confirmed that it's still a problem in Flex 3 as you can see by the stack trace.
Sample Application
I wrote the following simple application to confirm that the bug was in Flex and not our code:
{code}
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute"
backgroundColor="white"
initialize="onInit()">
<mx:Script><![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var treeRoot:Object;
private var treeChildren:ArrayCollection;
private function onInit():void {
treeChildren = new ArrayCollection([
{label: "one"},
{label: "two"},
{label: "three"},
{label: "four"},
{label: "five"}
]);
treeRoot = {label: "Tree Root", children: treeChildren};
}
private function onClick():void {
if (treeChildren.getItemAt(2).label == "three") {
treeChildren.setItemAt({label:"changed!"}, 2);
} else {
treeChildren.setItemAt({label:"changed a little slower"}, 2);
}
}
]]></mx:Script>
<mx:VBox height="100%" width="100%"
paddingTop="10" paddingLeft="10" paddingRight="10">
<mx:HBox>
<mx:Tree id="tree" width="200" height="400" dataProvider="{treeRoot}"/>
<mx:Text>
<mx:htmlText>
<![CDATA[
To reproduce this bug, try this first:
<ol><li>Expand the tree.</li><li>Click <b>Edit the Third Item</b></li></ol>
It works! Now try this:
<ol><li>Collapse the tree.</li><li>Click <b>Edit the Third Item</b></li><li>Wait patiently for your script timeout message...</li></ol>
It didn't work...
]]>
</mx:htmlText>
</mx:Text>
</mx:HBox>
<mx:Button label="Edit the Third Item" click="onClick()"/>
</mx:VBox>
</mx:Application>
{code}
Good test case for Gumbo tree.