flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mih...@apache.org
Subject [2/3] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34885 CAUSE: When an item is marked as updated, ListCollectionView.handlePropertyChangeEvents() assumes that it's just one property of the item that changed. However, an entire item could have chan
Date Tue, 09 Jun 2015 09:36:35 GMT
FLEX-34885
CAUSE:
When an item is marked as updated, ListCollectionView.handlePropertyChangeEvents() assumes
that it's just one property of the item that changed. However, an entire item could have changed
(see the unit test committed on this ticket), in which case PropertyChangeEvent.property is
null or empty. When this happens, the new item is added to the localIndex correctly, but the
old one is not removed.
Moreover, ArrayList still listens to the removed item for changes, and when one occurs, as
in the unit test, the event it sends causes the item to be re-added to the localIndex via
ListCollectionView.handlePropertyChangeEvents().
Moreover, ArrayList does not listen to the new object for changes, causing the sorting to
be wrong in the wrapping ListCollectionView.

SOLUTION:
ListCollectionView.handlePropertyChangeEvents() now caters for the situation where a PropertyChangeEvent
refers to an object that changed into another one (rather than just one of its properties).
Also, ArrayList now removes the listeners to the old item and adds them to the new item.


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

Branch: refs/heads/develop
Commit: c5b61d2f95cae2e05cd8114961cb6cc611e5e2d6
Parents: b266fa7
Author: Mihai Chira <mihaic@apache.org>
Authored: Tue Jun 9 11:26:55 2015 +0200
Committer: Mihai Chira <mihaic@apache.org>
Committed: Tue Jun 9 11:26:55 2015 +0200

----------------------------------------------------------------------
 .../framework/src/mx/collections/ArrayList.as         | 14 ++++++++++----
 .../src/mx/collections/ListCollectionView.as          | 14 +++++++++-----
 2 files changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/c5b61d2f/frameworks/projects/framework/src/mx/collections/ArrayList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/collections/ArrayList.as b/frameworks/projects/framework/src/mx/collections/ArrayList.as
index 3051b50..4d93c17 100644
--- a/frameworks/projects/framework/src/mx/collections/ArrayList.as
+++ b/frameworks/projects/framework/src/mx/collections/ArrayList.as
@@ -630,7 +630,13 @@ public class ArrayList extends EventDispatcher
         event.oldValue = oldValue;
         event.newValue = newValue;
         
-        itemUpdateHandler(event);        
+        if(!property)
+        {
+            stopTrackUpdates(oldValue);
+            startTrackUpdates(newValue);
+        }
+
+        itemUpdateHandler(event);
     }    
     
     /**
@@ -768,11 +774,11 @@ public class ArrayList extends EventDispatcher
     }
     
     /**
-     *  Called when any of the contained items in the list dispatch an
-     *  ObjectChange event.  
+     *  Called when any of the contained items in the list dispatches a
+     *  <code>PropertyChangeEvent</code>.
      *  Wraps it in a <code>CollectionEventKind.UPDATE</code> object.
      *
-     *  @param event The event object for the ObjectChange event.
+     *  @param event The event object for the <code>PropertyChangeEvent</code>.
      *  
      *  @langversion 3.0
      *  @playerversion Flash 9

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/c5b61d2f/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/collections/ListCollectionView.as b/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
index 367fdd5..1310ee2 100644
--- a/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
+++ b/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
@@ -1419,7 +1419,7 @@ public class ListCollectionView extends Proxy
     }
 
     /**
-     * Given a set of PropertyChangeEvents go through and update the view.
+     * Given a set of <code>PropertyChangeEvent</code>s go through and update
the view.
      * This is currently not optimized.
      *  
      *  @langversion 3.0
@@ -1490,7 +1490,8 @@ public class ListCollectionView extends Proxy
                 }
                 else
                 {
-                    updateEntry = { item: item, move: defaultMove, events: [ updateInfo ]
};
+                    updateEntry = {item: item, move: defaultMove, events: [updateInfo],
+                        entireObjectChanged: updateInfo.property == null, oldItem: updateInfo.property
== null ? updateInfo.oldValue : null};
                     updatedItems.push(updateEntry);
                 }
 
@@ -1502,7 +1503,7 @@ public class ListCollectionView extends Proxy
                 updateEntry.move =
                     updateEntry.move
                     || filterFunction != null
-                    || !updateInfo.property
+                    || updateEntry.entireObjectChanged
                     || (sort && sort.propertyAffectsSort(String(updateInfo.property)));
             }
 
@@ -1514,6 +1515,10 @@ public class ListCollectionView extends Proxy
                 updateEntry = updatedItems[i];
                 if (updateEntry.move)
                 {
+                    if(updateEntry.entireObjectChanged)
+                    {
+                        removeItemsFromView([updateEntry.oldItem], -1, true);
+                    }
                     moveItemInView(updateEntry.item, updateEntry.item, eventItems);
                 }
                 else
@@ -1665,8 +1670,7 @@ public class ListCollectionView extends Proxy
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
      */
-    private function moveItemInView(item:Object,
-                                      dispatch:Boolean = true, updateEventItems:Array = null):void
+    private function moveItemInView(item:Object, dispatch:Boolean = true, updateEventItems:Array
= null):void
     {
         if (localIndex)
         {


Mime
View raw message