FLEX-34778
CAUSE: When a node is opened, HierarchicalCollectionView starts to listen to 
changes to its children collection. And when it's closed, it doesn't stop 
listening to these CollectionEvents. So when a closed node's child is replaced, 
nestedCollectionChangeHandler is triggered, even if the node itself is closed. 
Part of nestedCollectionChangeHandler's function is to dispatch a REMOVE 
CollectionEvent for all the nodes which were removed by the replacement (which 
is, all the descendants of the replaced - but closed! - node). Then, since the 
node that's being replaced is not accessible anymore (because its parent was 
closed), it's not added to convertedEvent.items. But the next lines assume that 
the replaced node will be in that array without mistake. Otherwise (as it 
happens in this bus) it goes into an infinite loop trying to find it.

SOLUTION: instead of looking for the node with an (indefinitely) incrementing 
index, we're now using Array.indexOf() to locate the node and remove it if it's 
found.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/d8c1a9fc
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/d8c1a9fc
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/d8c1a9fc

Branch: refs/heads/develop
Commit: d8c1a9fcaaecd3acd4e70bf7a7cd24133a2106b4
Parents: 83e4a9b
Author: Mihai Chira <mih...@apache.org>
Authored: Tue Mar 10 13:00:10 2015 +0100
Committer: Erik de Bruin <e...@ixsoftware.nl>
Committed: Fri Mar 20 09:51:21 2015 +0100

----------------------------------------------------------------------
 .../src/mx/collections/HierarchicalCollectionView.as | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d8c1a9fc/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
 
b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
index 6d4901c..d752e8e 100644
--- 
a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
+++ 
b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
@@ -1152,7 +1152,7 @@ public class HierarchicalCollectionView extends 
EventDispatcher
     private function internalRefresh(dispatch:Boolean):Boolean
     {
         var obj:Object;
-        var coll:ICollectionView
+        var coll:ICollectionView;
         var needUpdate:Boolean = false;
         
         // apply filter function to all the collections including the child 
collections
@@ -1531,9 +1531,9 @@ public class HierarchicalCollectionView extends 
EventDispatcher
                 for (i = 0; i < n; i++)
                 {
                     node = ce.items[i].oldValue;
-                    while (convertedEvent.items[j] != node)
-                        j++;
-                    convertedEvent.items.splice(j, 1);
+                    var replacedNodePosition:int = 
convertedEvent.items.indexOf(node);
+                    if(replacedNodePosition != -1)
+                        convertedEvent.items.splice(replacedNodePosition, 1);
                 }
                 if (convertedEvent.items.length)
                 {
@@ -1654,9 +1654,10 @@ public class HierarchicalCollectionView extends 
EventDispatcher
                     changingNode = ce.items[i].oldValue;
                     if (changingNode is XML)
                         stopTrackUpdates(changingNode);
-                    while (convertedEvent.items[j] != changingNode)
-                        j++;
-                    convertedEvent.items.splice(j, 1);
+
+                    var replacedNodePosition:int = 
convertedEvent.items.indexOf(changingNode);
+                    if(replacedNodePosition != -1)
+                        convertedEvent.items.splice(replacedNodePosition, 1);
                 }
                 if (convertedEvent.items.length)
                 {

Reply via email to