Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-34283

XML item's parent null in item renderer when added to XMLListCollection

    XMLWordPrintableJSON

    Details

      Description

      Since 4.12, there seems to be a regression bug in XMLListCollection. The scenario is:

      1. The user selects an item in a list and clicks a button to create a copy of this item below the selected one
      2. Clone the item through item.copy(), make some modifications to this item
      3. Add the item to the XMLListCollection using addItemAt, then call refresh() on the collection
      4. 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.

      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 :

      <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>
      

      Whereas when run in 4.12, you would get :

      <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
      

      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 :

      <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
      

        Attachments

        1. Tests.mxml
          2 kB
          Frédéric Monjo

          Issue Links

            Activity

              People

              • Assignee:
                quetwo Nicholas Kwiatkowski
                Reporter:
                avangel Frédéric Monjo
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: