flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mih...@apache.org
Subject [5/8] git commit: [flex-sdk] [refs/heads/FLEX-34119] - FLEX-34440 CAUSE: When HierarchicalCollectionView converts a CollectionEventKind.REPLACE CollectionEvent into a CollectionEventKind.REMOVE one, it also deletes the parent(s) of the replaced node root
Date Mon, 28 Jul 2014 17:21:55 GMT
FLEX-34440
CAUSE:
When HierarchicalCollectionView converts a CollectionEventKind.REPLACE CollectionEvent into
a CollectionEventKind.REMOVE one, it also deletes the parent(s) of the replaced node root(s).
However, if the HierarchicalCollectionViewCursor which then immediately responds to this converted
event (in collectionChangeHandler()) happens to have its 'current' node inside the replaced
branch, it will fail to retrieve all the parents of the current node, because the parent of
the root of the branch has been deleted. This is problematic, because HierarchicalCollectionViewCursor.collectionChangeHandler
assumes that parentStack and parentBookmarkStack have the same number of items, and that any
item in the latter array represents the position (CursorBookmark) of an item in the former
array in its siblings collection. So it will try to use a parentBookmarkStack item on a different
collection to which it was created on, thus throwing a 'Bookmark no longer valid' CollectionViewError.

SOLUTION:
HierarchicalCollectionView.nestedCollectionChangeHandler now deletes the parent(s) of the
replaced node root(s) *after* dispatching the converted CollectionEvent, as opposed to *before*.

NOTES:
-This now makes HierarchicalCollectionViewCursor_FLEX_34440_Test pass.
-Also removed three unused local variables from HierarchicalCollectionView.nestedCollectionChangeHandler.


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

Branch: refs/heads/FLEX-34119
Commit: c2e68dc6d130094816c9407c5fa6f2782f1023d6
Parents: 3ce553b
Author: Mihai Chira <mihaic@apache.org>
Authored: Mon Jul 28 13:09:23 2014 +0100
Committer: Mihai Chira <mihaic@apache.org>
Committed: Mon Jul 28 13:09:23 2014 +0100

----------------------------------------------------------------------
 .../mx/collections/HierarchicalCollectionView.as | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/c2e68dc6/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 6b41c62..40ba8c3 100644
--- a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
+++ b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
@@ -1540,11 +1540,8 @@ public class HierarchicalCollectionView extends EventDispatcher
     {
         var i:int;
         var n:int;
-        var location:int;
-        var uid:String;
         var parentOfChangingNode:Object;
         var changingNode:Object;
-        var items:Array;
         var convertedEvent:CollectionEvent;
 
         if (event is CollectionEvent)
@@ -1632,12 +1629,7 @@ public class HierarchicalCollectionView extends EventDispatcher
                         // if the parent node is opened
                         if (_openNodes[UIDUtil.getUID(parentOfChangingNode)] != null)
                         {
-                            var newNode:Object = ce.items[i].newValue;
-                            uid = UIDUtil.getUID(newNode);
-                            parentMap[uid] = parentOfChangingNode;
-                            
-                            // delete the parent map for the old node
-                            delete parentMap[UIDUtil.getUID(changingNode)];
+                            parentMap[UIDUtil.getUID(ce.items[i].newValue)] = parentOfChangingNode;
                         }
                     }
                 }
@@ -1660,6 +1652,15 @@ public class HierarchicalCollectionView extends EventDispatcher
                     dispatchEvent(convertedEvent);
                 }
                 dispatchEvent(event);
+
+                for (i = 0; i < n; i++)
+                {
+                    changingNode = ce.items[i].oldValue;
+                    parentOfChangingNode = getParentItem(changingNode);
+
+                    if (parentOfChangingNode != null && _openNodes[UIDUtil.getUID(parentOfChangingNode)]
!= null)
+                        delete parentMap[UIDUtil.getUID(changingNode)];
+                }
             }
             else if (ce.kind == CollectionEventKind.RESET)
             {


Mime
View raw message