2 Replies Latest reply on Apr 13, 2010 10:47 AM by bbrewer_007

    Possible bug in DataGroup's updateRenderer method

    ngarg Level 1

      I have been using DataGroup with virtualization quietly heavily. My code was working in in Flex 4 Beta 2 release. Recently, when Adobe release the final version for Flex 4, my code stopped working.

       

      So I started looking inside the guts of the SDK. Here is what I found. Under the DataGroup.as class, in the updateRenderer method:

       

              // always set the data last
              if ((renderer is IDataRenderer) && (renderer !== data))
                  IDataRenderer(renderer).data = data;

       

      The above condition will always be true because "renderer" will never match "data". As a consequence, data will be change everytime someone scrolls or do any kind of movement.

       

      The correct implementation should be:

       

                  // always set the data last
                  if ((renderer is IDataRenderer) && (IDataRenderer(renderer).data !== data))
                      IDataRenderer(renderer).data = data;

       

       

      I extended DataGroup and made this change to confirm my suspicion. My code works correctly! Can anyone confirm my finding?

       

      Navendu

        • 1. Re: Possible bug in DataGroup's updateRenderer method
          Flex harUI Adobe Employee

          DataGroup's code is correct. The Ilist can contain visual elements in Spark

          and so we're just testing to see if the data provider item is the renderer.

           

          If you have a test case where you think the data setter is getting called

          too often, file a bug.

           

          In complex data items, a test of data == data is not going to catch changes

          to internal properties.

          • 2. Re: Possible bug in DataGroup's updateRenderer method
            bbrewer_007 Level 1

            Navendu,

             

            I'm with you on this one. Something from  Beta 2 to the final release of Flash Builder 4 has jacked up many of my  item renderers. The data property is getting set anytime I scroll. I  came across the code you posted as well in the SkinnableDataContainer  class:

             

            if ((renderer is IDataRenderer) &&  (renderer !== data))
                         IDataRenderer(renderer).data = data;

             

            Flex HarUI,

             

            Can you please explain why it would still set the ItemRenderers data property when this condition isn't met (which seems like most of the time).

             

            Thanks,
            Beau