Author: cframpton
Date: Wed Nov 28 21:51:51 2012
New Revision: 1414948
URL: http://svn.apache.org/viewvc?rev=1414948&view=rev
Log:
>From whiteboard/cframpton/adobe.next. Fix ListCollectionView bug. RTE
>happens because addAllAt() wasn't taking into account that some of the added
>items could be filtered out. Now, it checks the length as it is adding items.
>If the insertion index goes out of bounds because of filtering, it adds the
>rest of the items at the end.
Modified:
incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
Modified:
incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
URL:
http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/collections/ListCollectionView.as?rev=1414948&r1=1414947&r2=1414948&view=diff
==============================================================================
---
incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
(original)
+++
incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
Wed Nov 28 21:51:51 2012
@@ -25,6 +25,7 @@ import flash.events.EventDispatcher;
import flash.utils.Proxy;
import flash.utils.flash_proxy;
import flash.utils.getQualifiedClassName;
+
import mx.collections.errors.CollectionViewError;
import mx.collections.errors.CursorError;
import mx.collections.errors.ItemPendingError;
@@ -636,10 +637,25 @@ public class ListCollectionView extends
*/
public function addAllAt(addList:IList, index:int):void
{
+ if (index < 0 || index > this.length)
+ {
+ var message:String = resourceManager.getString(
+ "collections", "outOfBounds", [ index ]);
+ throw new RangeError(message);
+ }
+
var length:int = addList.length;
for (var i:int=0; i < length; i++)
{
- this.addItemAt(addList.getItemAt(i), i+index);
+ var insertIndex:int = i + index;
+
+ // incremental index may be out of bounds because of filtering,
+ // so add this item to the end.
+ var currentLength:int = this.length;
+ if (insertIndex > currentLength)
+ insertIndex = currentLength;
+
+ this.addItemAt(addList.getItemAt(i), insertIndex);
}
}