Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AFB3C17476 for ; Tue, 9 Jun 2015 09:36:39 +0000 (UTC) Received: (qmail 52245 invoked by uid 500); 9 Jun 2015 09:36:34 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 52199 invoked by uid 500); 9 Jun 2015 09:36:34 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 52102 invoked by uid 99); 9 Jun 2015 09:36:34 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jun 2015 09:36:34 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 40CCCDFF8E; Tue, 9 Jun 2015 09:36:34 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mihaic@apache.org To: commits@flex.apache.org Date: Tue, 09 Jun 2015 09:36:35 -0000 Message-Id: <9bde2f253d9e4cf39dfb88b97e51e087@git.apache.org> In-Reply-To: <2c68a835d25548cfb872663871a0756f@git.apache.org> References: <2c68a835d25548cfb872663871a0756f@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 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 Authored: Tue Jun 9 11:26:55 2015 +0200 Committer: Mihai Chira 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 + * PropertyChangeEvent. * Wraps it in a CollectionEventKind.UPDATE object. * - * @param event The event object for the ObjectChange event. + * @param event The event object for the PropertyChangeEvent. * * @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 PropertyChangeEvents 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) {