You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Ulrich Andreas <An...@formware.de> on 2013/10/09 17:48:55 UTC

AsyncListView & DataGrid - Exception in GridViewLayout.as

Hello everyone,

I'm using James Wards implementation of a virtual paged grid (http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/  https://github.com/jamesward/DataPaging/blob/master/src/PagedList.as)

It mostly works fine but I get an Exception in GridViewLayout.as when pulling the vertical scrollbar right to the end resulting in loading the last Datablock.

It crashes in here:

private function freeLinearElements (
        elements:Vector.<IVisualElement>, 
        oldIndices:Vector.<int>, 
        newIndices:Vector.<int>, 
        lastIndex:int):void
    {
        // TODO(hmuller): rewrite this, should be one pass (no indexOf)
        for (var i:int = 0; i < elements.length; i++)
        {
                 const offset:int = newIndices.indexOf(oldIndices[i]);
                if ((oldIndices[i] == lastIndex) || (offset == -1))
                {
                    const elt:IVisualElement = elements[i];
                    if (elt)
                    {
                        freeGridElement(elt);
                        elements[i] = null;
                    }
                }
        }
    }     

The elements Vector (and thus the int i variable) is larger than the length of the oldIndices Vector therefore access to oldIndices[i] throws an exception at some point.

I don't know how to catch this Exception in my Application Code - if this would be possible at all.
To fix this issue I surrounded the loop with a try catch block and built a new spark.swf - absolutely not the way I want to handle this :(

Should this be filed as a bug or is there any suggestion where I could tweak my application code to prevent this exception?


Regards
Andi


Re: AW: AsyncListView & DataGrid - Exception in GridViewLayout.as

Posted by Tom Chiverton <tc...@extravision.com>.
You said "The elements Vector (and thus the int i variable) is larger 
than the length of the oldIndices Vector therefore access to 
oldIndices[i]" though.

We're using code modified as outlined there in production with sometimes 
more than 10k rows, loaded in batches of only a few tens, and it works fine.

You might try turning live scrolling off too.

Tom

On 10/10/2013 08:05, Ulrich Andreas wrote:
> Can you please give me some directions?
> (It's not a "more Items than TotalLength" problem)
>
> -----Ursprüngliche Nachricht-----
> Von: Tom Chiverton [mailto:tc@extravision.com]
> Gesendet: Mittwoch, 9. Oktober 2013 18:31
> An: users@flex.apache.org
> Betreff: Re: AsyncListView & DataGrid - Exception in GridViewLayout.as
>
> Did you try the modifications I outline on James blog ?
>
> Tom
>
> On 09/10/2013 16:48, Ulrich Andreas wrote:
>> Hello everyone,
>>
>> I'm using James Wards implementation of a virtual paged grid
>> (http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/
>> https://github.com/jamesward/DataPaging/blob/master/src/PagedList.as)
>>
>> It mostly works fine but I get an Exception in GridViewLayout.as when pulling the vertical scrollbar right to the end resulting in loading the last Datablock.
>>
>> It crashes in here:
>>
>> private function freeLinearElements (
>>           elements:Vector.<IVisualElement>,
>>           oldIndices:Vector.<int>,
>>           newIndices:Vector.<int>,
>>           lastIndex:int):void
>>       {
>>           // TODO(hmuller): rewrite this, should be one pass (no indexOf)
>>           for (var i:int = 0; i < elements.length; i++)
>>           {
>>                    const offset:int = newIndices.indexOf(oldIndices[i]);
>>                   if ((oldIndices[i] == lastIndex) || (offset == -1))
>>                   {
>>                       const elt:IVisualElement = elements[i];
>>                       if (elt)
>>                       {
>>                           freeGridElement(elt);
>>                           elements[i] = null;
>>                       }
>>                   }
>>           }
>>       }
>>
>> The elements Vector (and thus the int i variable) is larger than the length of the oldIndices Vector therefore access to oldIndices[i] throws an exception at some point.
>>
>> I don't know how to catch this Exception in my Application Code - if this would be possible at all.
>> To fix this issue I surrounded the loop with a try catch block and
>> built a new spark.swf - absolutely not the way I want to handle this
>> :(
>>
>> Should this be filed as a bug or is there any suggestion where I could tweak my application code to prevent this exception?
>>
>>
>> Regards
>> Andi
>>
>> ______________________________________________________________________
>> This email has been scanned by the Symantec Email Security.cloud service.
>> For more information please visit http://www.symanteccloud.com
>> ______________________________________________________________________
>>
>>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________
>
>


AW: AsyncListView & DataGrid - Exception in GridViewLayout.as

Posted by Ulrich Andreas <An...@formware.de>.
Can you please give me some directions?
(It's not a "more Items than TotalLength" problem)

-----Ursprüngliche Nachricht-----
Von: Tom Chiverton [mailto:tc@extravision.com] 
Gesendet: Mittwoch, 9. Oktober 2013 18:31
An: users@flex.apache.org
Betreff: Re: AsyncListView & DataGrid - Exception in GridViewLayout.as

Did you try the modifications I outline on James blog ?

Tom

On 09/10/2013 16:48, Ulrich Andreas wrote:
> Hello everyone,
>
> I'm using James Wards implementation of a virtual paged grid 
> (http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/  
> https://github.com/jamesward/DataPaging/blob/master/src/PagedList.as)
>
> It mostly works fine but I get an Exception in GridViewLayout.as when pulling the vertical scrollbar right to the end resulting in loading the last Datablock.
>
> It crashes in here:
>
> private function freeLinearElements (
>          elements:Vector.<IVisualElement>,
>          oldIndices:Vector.<int>,
>          newIndices:Vector.<int>,
>          lastIndex:int):void
>      {
>          // TODO(hmuller): rewrite this, should be one pass (no indexOf)
>          for (var i:int = 0; i < elements.length; i++)
>          {
>                   const offset:int = newIndices.indexOf(oldIndices[i]);
>                  if ((oldIndices[i] == lastIndex) || (offset == -1))
>                  {
>                      const elt:IVisualElement = elements[i];
>                      if (elt)
>                      {
>                          freeGridElement(elt);
>                          elements[i] = null;
>                      }
>                  }
>          }
>      }
>
> The elements Vector (and thus the int i variable) is larger than the length of the oldIndices Vector therefore access to oldIndices[i] throws an exception at some point.
>
> I don't know how to catch this Exception in my Application Code - if this would be possible at all.
> To fix this issue I surrounded the loop with a try catch block and 
> built a new spark.swf - absolutely not the way I want to handle this 
> :(
>
> Should this be filed as a bug or is there any suggestion where I could tweak my application code to prevent this exception?
>
>
> Regards
> Andi
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com 
> ______________________________________________________________________
>
>


Re: AsyncListView & DataGrid - Exception in GridViewLayout.as

Posted by Tom Chiverton <tc...@extravision.com>.
Did you try the modifications I outline on James blog ?

Tom

On 09/10/2013 16:48, Ulrich Andreas wrote:
> Hello everyone,
>
> I'm using James Wards implementation of a virtual paged grid (http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/  https://github.com/jamesward/DataPaging/blob/master/src/PagedList.as)
>
> It mostly works fine but I get an Exception in GridViewLayout.as when pulling the vertical scrollbar right to the end resulting in loading the last Datablock.
>
> It crashes in here:
>
> private function freeLinearElements (
>          elements:Vector.<IVisualElement>,
>          oldIndices:Vector.<int>,
>          newIndices:Vector.<int>,
>          lastIndex:int):void
>      {
>          // TODO(hmuller): rewrite this, should be one pass (no indexOf)
>          for (var i:int = 0; i < elements.length; i++)
>          {
>                   const offset:int = newIndices.indexOf(oldIndices[i]);
>                  if ((oldIndices[i] == lastIndex) || (offset == -1))
>                  {
>                      const elt:IVisualElement = elements[i];
>                      if (elt)
>                      {
>                          freeGridElement(elt);
>                          elements[i] = null;
>                      }
>                  }
>          }
>      }
>
> The elements Vector (and thus the int i variable) is larger than the length of the oldIndices Vector therefore access to oldIndices[i] throws an exception at some point.
>
> I don't know how to catch this Exception in my Application Code - if this would be possible at all.
> To fix this issue I surrounded the loop with a try catch block and built a new spark.swf - absolutely not the way I want to handle this :(
>
> Should this be filed as a bug or is there any suggestion where I could tweak my application code to prevent this exception?
>
>
> Regards
> Andi
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________
>
>


AW: AsyncListView & DataGrid - Exception in GridViewLayout.as

Posted by Ulrich Andreas <An...@formware.de>.
Oh my god - years of flex, but this one is new to me... thank you, I will give it a try!


-----Ursprüngliche Nachricht-----
Von: Alex Harui [mailto:aharui@adobe.com] 
Gesendet: Mittwoch, 9. Oktober 2013 18:24
An: users@flex.apache.org
Betreff: RE: AsyncListView & DataGrid - Exception in GridViewLayout.as

If the exception doesn't cause any residual harm, you can always try to catch it with an UncaughtError handler.

-Alex
________________________________________
From: Ulrich Andreas [Andreas.Ulrich@formware.de]
Sent: Wednesday, October 09, 2013 8:48 AM
To: users@flex.apache.org
Subject: AsyncListView & DataGrid - Exception in GridViewLayout.as

Hello everyone,

I'm using James Wards implementation of a virtual paged grid (http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/  https://github.com/jamesward/DataPaging/blob/master/src/PagedList.as)

It mostly works fine but I get an Exception in GridViewLayout.as when pulling the vertical scrollbar right to the end resulting in loading the last Datablock.

It crashes in here:

private function freeLinearElements (
        elements:Vector.<IVisualElement>,
        oldIndices:Vector.<int>,
        newIndices:Vector.<int>,
        lastIndex:int):void
    {
        // TODO(hmuller): rewrite this, should be one pass (no indexOf)
        for (var i:int = 0; i < elements.length; i++)
        {
                 const offset:int = newIndices.indexOf(oldIndices[i]);
                if ((oldIndices[i] == lastIndex) || (offset == -1))
                {
                    const elt:IVisualElement = elements[i];
                    if (elt)
                    {
                        freeGridElement(elt);
                        elements[i] = null;
                    }
                }
        }
    }

The elements Vector (and thus the int i variable) is larger than the length of the oldIndices Vector therefore access to oldIndices[i] throws an exception at some point.

I don't know how to catch this Exception in my Application Code - if this would be possible at all.
To fix this issue I surrounded the loop with a try catch block and built a new spark.swf - absolutely not the way I want to handle this :(

Should this be filed as a bug or is there any suggestion where I could tweak my application code to prevent this exception?


Regards
Andi


RE: AsyncListView & DataGrid - Exception in GridViewLayout.as

Posted by Alex Harui <ah...@adobe.com>.
If the exception doesn't cause any residual harm, you can always try to catch it with an UncaughtError handler.

-Alex
________________________________________
From: Ulrich Andreas [Andreas.Ulrich@formware.de]
Sent: Wednesday, October 09, 2013 8:48 AM
To: users@flex.apache.org
Subject: AsyncListView & DataGrid - Exception in GridViewLayout.as

Hello everyone,

I'm using James Wards implementation of a virtual paged grid (http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/  https://github.com/jamesward/DataPaging/blob/master/src/PagedList.as)

It mostly works fine but I get an Exception in GridViewLayout.as when pulling the vertical scrollbar right to the end resulting in loading the last Datablock.

It crashes in here:

private function freeLinearElements (
        elements:Vector.<IVisualElement>,
        oldIndices:Vector.<int>,
        newIndices:Vector.<int>,
        lastIndex:int):void
    {
        // TODO(hmuller): rewrite this, should be one pass (no indexOf)
        for (var i:int = 0; i < elements.length; i++)
        {
                 const offset:int = newIndices.indexOf(oldIndices[i]);
                if ((oldIndices[i] == lastIndex) || (offset == -1))
                {
                    const elt:IVisualElement = elements[i];
                    if (elt)
                    {
                        freeGridElement(elt);
                        elements[i] = null;
                    }
                }
        }
    }

The elements Vector (and thus the int i variable) is larger than the length of the oldIndices Vector therefore access to oldIndices[i] throws an exception at some point.

I don't know how to catch this Exception in my Application Code - if this would be possible at all.
To fix this issue I surrounded the loop with a try catch block and built a new spark.swf - absolutely not the way I want to handle this :(

Should this be filed as a bug or is there any suggestion where I could tweak my application code to prevent this exception?


Regards
Andi