You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by mi...@apache.org on 2016/03/02 10:19:23 UTC

[2/2] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35043 CAUSE: The solution implemented for FLEX-34885, which had an problematic consequence: when calling itemUpdated(item) on a collection with only the first parameter provided (which developers u

FLEX-35043
CAUSE: The solution implemented for FLEX-34885, which had an problematic consequence: when calling itemUpdated(item) on a collection with only the first parameter provided (which developers usually do to signal that some - unspecified - properties of the item have changed), ListCollectionView.handlePropertyChangeEvents() would treat that as if the object had been just introduced to the collection - as "property" was null -, replacing a null value - since oldValue was null as well. (That is to say, when the "property" value of the PropertyChangeEvent was null, it was taken to mean that the oldValue - which was also null here - was changed into that item, i.e. the object reference changed in the collection, not just one of the object's properties.) As such, it would try to remove that supposedly existing null value from the collection (and sometimes a null does exist, but shouldn't be removed).

In a way this was logical based on the properties supplied to itemUpdated(), but we also know that a frequent use of that function is with only one parameter, to specify that some of the object's properties have changed (but the object itself should still be in the collection). So we should continue to support this use case.

SOLUTION: now ListCollectionView.handlePropertyChangeEvents() only assumes that the entire object has been replaced in the collection if the event's "property" is null AND if either its "oldValue" or "newValue" is non-null. In other words, if the developer entered all these arguments into the function or in the event they're dispatching, and one of them is non-null, it probably means they want to signal that the entire object has changed in the collection.

NOTES:
-renamed "entireObjectChanged" into "objectReplacedWithAnother" to emphasize that it's not the object's internal state that "entirely changed", but that the object itself was replaced in the collection by another object instance.
-some of the unit tests in ListCollectionView_PropertyChangeEvent_Tests are now failing, which is expected.


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

Branch: refs/heads/develop
Commit: 2c0c1871368dc43520334a84c5e7d046acdb0cb8
Parents: 831ed07
Author: Mihai Chira <mi...@apache.org>
Authored: Wed Mar 2 10:12:46 2016 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Wed Mar 2 10:12:46 2016 +0100

----------------------------------------------------------------------
 .../framework/src/mx/collections/ListCollectionView.as       | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/2c0c1871/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 a002f1d..15fc15d 100644
--- a/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
+++ b/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
@@ -1487,8 +1487,10 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList,
                 }
                 else
                 {
+                    var oldOrNewValueSpecified:Boolean = updateInfo.oldValue != null || updateInfo.newValue != null;
+                    var objectReplacedInCollection:Boolean = updateInfo.property == null && oldOrNewValueSpecified;
                     updateEntry = {item: item, move: defaultMove, events: [updateInfo],
-                        entireObjectChanged: updateInfo.property == null, oldItem: updateInfo.property == null ? updateInfo.oldValue : null};
+                        objectReplacedWithAnother: objectReplacedInCollection, oldItem: updateInfo.oldValue};
                     updatedItems.push(updateEntry);
                 }
 
@@ -1497,7 +1499,7 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList,
                 //if the property affects the sort, we'll need to move
                 updateEntry.move = updateEntry.move
                     || filterFunction != null
-                    || updateEntry.entireObjectChanged
+                    || updateEntry.objectReplacedWithAnother
                     || (sort && sort.propertyAffectsSort(String(updateInfo.property)));
             }
 
@@ -1509,7 +1511,7 @@ public class ListCollectionView extends Proxy implements ICollectionView, IList,
                 updateEntry = updatedItems[i];
                 if (updateEntry.move)
                 {
-                    if(updateEntry.entireObjectChanged)
+                    if(updateEntry.objectReplacedWithAnother)
                     {
                         removeItemsFromView([updateEntry.oldItem], -1, true);
                     }