You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by bi...@apache.org on 2014/08/17 09:48:01 UTC

[14/50] git commit: [flex-sdk] [refs/heads/new_android_skins] - FLEX-34119 CAUSE: HierarchicalCollectionViewCursor.collectionChangeHandler dealt with CollectionEventKind.ADD and CollectionEventKind.REMOVE events in a defective way: when the event happene

FLEX-34119
CAUSE:
HierarchicalCollectionViewCursor.collectionChangeHandler dealt with CollectionEventKind.ADD and CollectionEventKind.REMOVE events in a defective way: when the event happened before the currently-selected node, but in a different collection from the selected node, it assumed that it could use the currentChildBookmark to correct the position of the bookmark in that collection. However, currentChildBookmark can only be used on the collection it was created in, which is the collection of the currently-selected node and its siblings. This made ListCollectionView.getBookmarkIndex throw the 'Bookmark no longer valid' error.

SOLUTION:
In the case detailed above instead of changing the currentChildBookmark we need to adjust the bookmark associated with the collection that the changing (i.e. added or removed) node is in.

NOTES:
-Another problem in HierarchicalCollectionViewCursor.collectionChangeHandler was that currentChildBookmark was (attempted to be) updated with the corrected position of the parent of the changing node's sibling collection. However, currentChildBookmark represents the position of the currently-selected item, and should only be updated when the selected item's siblings collection changes, not when other collections change. Instead, we need to update the parentBookmarkStack collection, which contains the positions of the selected node's parents' positions in their collections.
-After these changes HierarchicalCollectionViewCursor_FLEX_34119_Test doesn't show any more 'Bookmark no longer valid' errors. (But it still fails due to FLEX-34424).


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

Branch: refs/heads/new_android_skins
Commit: 4cb80bfbb37225b86b9e69cc4ec2fc21efe0a668
Parents: 0c4c9c0
Author: Mihai Chira <mi...@gmail.com>
Authored: Tue Jul 22 11:22:50 2014 +0100
Committer: Mihai Chira <mi...@gmail.com>
Committed: Tue Jul 22 11:22:50 2014 +0100

----------------------------------------------------------------------
 .../HierarchicalCollectionViewCursor.as         | 77 ++++++++++----------
 1 file changed, 37 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4cb80bfb/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
index b829dfe..db52010 100644
--- a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
+++ b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
@@ -111,6 +111,7 @@ public class HierarchicalCollectionViewCursor extends EventDispatcher
     
     /**
      *  @private
+     *  The bookmark representing the position of the current node in its siblings collection
      */
     private var currentChildBookmark:CursorBookmark = CursorBookmark.FIRST;
 
@@ -1152,21 +1153,9 @@ public class HierarchicalCollectionViewCursor extends EventDispatcher
         var changingNode:Object;
         var parentOfChangingNode:Object;
         var parentOfCurrentNode:Object;
-        var parentStack:Array;
-        var parentTable:Dictionary;
+        var parentStack:Array = getParentStack(current);
         var isBefore:Boolean = false;
-        
-        // get the parent of the current item
-        parentStack = getParentStack(current);
-        // hash it by parent to map to depth
-        parentTable = new Dictionary();
-        n = parentStack.length;
-        // don't insert the immediate parent
-        for (i = 0; i < n - 1; i++)
-        {
-            // 0 is null parent (the model)
-            parentTable[parentStack[i]] = i + 1;
-        }
+
         // remember the current parent
         parentOfCurrentNode = parentStack[parentStack.length - 1];
         
@@ -1206,25 +1195,29 @@ public class HierarchicalCollectionViewCursor extends EventDispatcher
                             }
                             catch (e:ItemPendingError)
                             {
-                                
                             }
                         }
                     }
-                    else if (parentTable[parentOfChangingNode] != null)
-                    {
-                        if (changingNodeAndSiblings != null)
+                    else {
+                        var parentOfChangingNodeIndex:int = parentStack.indexOf(parentOfChangingNode);
+                        var isOurAncestorChanging:Boolean = parentOfChangingNodeIndex != -1;
+                        if (isOurAncestorChanging)
                         {
-                            changingCollectionCursor = changingNodeAndSiblings.createCursor();
-                            try
-                            {
-                                changingCollectionCursor.seek(currentChildBookmark);
-                                changingCollectionCursor.moveNext();
-                                currentChildBookmark = changingCollectionCursor.bookmark;
-                            }
-                            catch (e:ItemPendingError)
+                            if (changingNodeAndSiblings != null)
                             {
+                                var changingNodeCollectionIndex:int = parentOfChangingNodeIndex + 1;
+                                changingCollectionCursor = changingNodeAndSiblings.createCursor();
+                                var bookmarkInChangingCollection:CursorBookmark = parentBookmarkStack[changingNodeCollectionIndex];
+                                try
+                                {
+                                    changingCollectionCursor.seek(bookmarkInChangingCollection);
+                                    changingCollectionCursor.moveNext();
+                                }
+                                catch (e:ItemPendingError)
+                                {
+                                }
+                                parentBookmarkStack[changingNodeCollectionIndex] = changingCollectionCursor.bookmark;
                             }
-                            parentBookmarkStack[parentTable[parentOfChangingNode]] = currentChildBookmark;
                         }
                     }
                 }
@@ -1281,25 +1274,29 @@ public class HierarchicalCollectionViewCursor extends EventDispatcher
                             }
                             catch (e:ItemPendingError)
                             {
-                                
                             }
                         }
                     }
-                    else if (parentTable[parentOfChangingNode] != null)
-                    {
-                        if (changingNodeAndSiblings != null)
+                    else {
+                        var parentOfChangingNodeIndex:int = parentStack.indexOf(parentOfChangingNode);
+                        var isOurAncestorChanging:Boolean = parentOfChangingNodeIndex != -1;
+                        if (isOurAncestorChanging)
                         {
-                            changingCollectionCursor = changingNodeAndSiblings.createCursor();
-                            try
-                            {
-                                changingCollectionCursor.seek(currentChildBookmark);
-                                changingCollectionCursor.movePrevious();
-                                currentChildBookmark = changingCollectionCursor.bookmark;
-                            }
-                            catch (e:ItemPendingError)
+                            if (changingNodeAndSiblings != null)
                             {
+                                var changingNodeCollectionBookmarkIndex:int = parentOfChangingNodeIndex + 1;
+                                changingCollectionCursor = changingNodeAndSiblings.createCursor();
+                                var bookmarkInChangingCollection:CursorBookmark = parentBookmarkStack[changingNodeCollectionBookmarkIndex];
+                                try
+                                {
+                                    changingCollectionCursor.seek(bookmarkInChangingCollection);
+                                    changingCollectionCursor.movePrevious();
+                                }
+                                catch (e:ItemPendingError)
+                                {
+                                }
+                                parentBookmarkStack[changingNodeCollectionBookmarkIndex] = changingCollectionCursor.bookmark;
                             }
-                            parentBookmarkStack[parentTable[parentOfChangingNode]] = currentChildBookmark;
                         }
                     }
                 }