[ 
https://issues.apache.org/jira/browse/FLEX-34283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14005017#comment-14005017
 ] 

Michael Labriola commented on FLEX-34283:
-----------------------------------------

Nick,

I would perform the delete as the inverse of your addItemAt(). The addItem() is 
just an optimization and could wait.

The thing we need to understand is that XMLList is closer to String than to 
Array. Meaning its a nearly immutable list for all practical purposes. 
Therefore, the behavior will need to be more like a collection on top of a 
comma-delimited string where in a new string exists after a modification. This 
is much different than an imperative construct like an array which can be 
modified in place. XMLList unfortunately straddles the border. For an append, 
it acts like an imperative structure, but for all other operations the 
structure behaves in (nearly) unpredictable (at minimum unexpected) ways so we 
would be better off to treat it as immutable.

Ultimately, its how Flash Player is working.

Mike




> XML item's parent null in item renderer when added to XMLListCollection
> -----------------------------------------------------------------------
>
>                 Key: FLEX-34283
>                 URL: https://issues.apache.org/jira/browse/FLEX-34283
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Spark: List
>    Affects Versions: Apache Flex 4.12.0
>            Reporter: Frédéric Monjo
>            Assignee: Nick Kwiatkowski
>            Priority: Critical
>              Labels: collections, xml
>             Fix For: Apache Flex 4.13.0
>
>         Attachments: Tests.mxml
>
>
> Since 4.12, there seems to be a regression bug in XMLListCollection. The 
> scenario is:
> # The user selects an item in a list and clicks a button to create a copy of 
> this item below the selected one
> # Clone the item through {{item.copy()}}, make some modifications to this item
> # Add the item to the XMLListCollection using {{addItemAt}}, then call 
> {{refresh()}} on the collection
> # Inside some item renderers (not obviously the cloned one), XML item's 
> parent is null, and never get updated, which could cause runtime errors.
> Up to version 4.11, there has never been such problems. After a short 
> investigation, this problem may be caused by a change in {{XMLListAdapter}} 
> from [this 
> commit|https://github.com/apache/flex-sdk/commit/59dd2be7f6a9b0fda745249cf979adeac7f406b7].
>  
> Please find attached a sample program to reproduce the bug. Run the program, 
> select an item and click on the "Duplicate after" button. 
> When run in 4.11, you should see the following console trace :
> {code}
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="2"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> --------------------------------------------------
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="1+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="2"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> {code}
> Whereas when run in 4.12, you would get :
> {code}
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="2"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> --------------------------------------------------
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="1+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="2"/> --- is child of ---> null
> {code}
> Where you can see that the last item has lost his parent (note that it is not 
> the cloned item). You may try to clone several random items, and results get 
> even more confusing as you clone more items :
> {code}
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> <foo id="2"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="2"/></root>
> --------------------------------------------------
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="1+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="2"/></root>
> <foo id="2"/> --- is child of ---> null
> --------------------------------------------------
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/></root>
> <foo id="1+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/></root>
> <foo id="1++"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/></root>
> <foo id="2"/> --- is child of ---> null
> --------------------------------------------------
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/></root>
> <foo id="1+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/></root>
> <foo id="1++"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/></root>
> <foo id="2"/> --- is child of ---> null
> <foo id="2+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/></root>
> --------------------------------------------------
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/></root>
> <foo id="1+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/></root>
> <foo id="1++"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/></root>
> <foo id="2"/> --- is child of ---> null
> <foo id="2+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/></root>
> <foo id="2+"/> --- is child of ---> null
> --------------------------------------------------
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2++"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2++"/></root>
> <foo id="1+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2++"/></root>
> <foo id="1++"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2++"/></root>
> <foo id="2"/> --- is child of ---> null
> <foo id="2+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2++"/></root>
> <foo id="2+"/> --- is child of ---> null
> <foo id="2++"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2++"/></root>
> --------------------------------------------------
> <foo id="0"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2+"/><foo id="2++"/></root>
> <foo id="1"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2+"/><foo id="2++"/></root>
> <foo id="1+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2+"/><foo id="2++"/></root>
> <foo id="1++"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2+"/><foo id="2++"/></root>
> <foo id="2"/> --- is child of ---> null
> <foo id="2+"/> --- is child of ---> <root><foo id="0"/><foo id="1"/><foo 
> id="1+"/><foo id="1++"/><foo id="2"/><foo id="2+"/><foo id="2+"/><foo 
> id="2+"/><foo id="2++"/></root>
> <foo id="2+"/> --- is child of ---> null
> <foo id="2+"/> --- is child of ---> null
> <foo id="2++"/> --- is child of ---> null
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to