Exception in TChartseries.GetValueColor

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
MarkusM
Newbie
Newbie
Posts: 3
Joined: Tue Mar 11, 2008 12:00 am

Exception in TChartseries.GetValueColor

Post by MarkusM » Wed Nov 19, 2008 10:39 am

When I add several points to a TLineseries and afterwards call Chart1.Refresh, it runs into an endless loop of exceptions:
EListError: List index out of bounds (-1). The exception occurs in TeEngine.pas in "TChartSeries.GetValueColor", where Internalcolor(ValueIndex) is called.

I use several TLineseries in this chart, and I set "Coloreach" to true and added points using AddXY with different colors. As this old project is kind of really big, it's difficult to provide an example project ... And I was not able to reproduce the error in a new project.

However, it does not occur if AddXY is only used without a parameter for "aColor".

Further investigation showed that the Problem is in Line 2172 of Series.pas:

if IsNull(ValueIndex-1) then { if null }

When FColor is assigned (which is only when a Series has colors different from clTeeColor) and ValueIndex=0, this function tries to get an item with index -1 in the list which is not accessible.

Edit:
As a bugfix, I changed the above line to

if IsNull(ValueIndex) then { if null }

is this the right solution?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 19, 2008 3:40 pm

Hi MarkusM,

It's difficult for us to say without being able to reproduce the issue here. Most likely there's a reason for that "-1" but I can tell this for sure on those conditions. Can you reproduce this with v8.04, which is the latest version available at the client area?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MarkusM
Newbie
Newbie
Posts: 3
Joined: Tue Mar 11, 2008 12:00 am

Post by MarkusM » Wed Nov 19, 2008 4:37 pm

I'm sorry, but I was not able to reproduce this error in a single application. As it works now for me, I have no problem any more ... Sorry.

To avoid errors like this in the future, you could change

Function TChartSeries.InternalColor(ValueIndex:Integer):TColor;
Begin
if Assigned(FColors) and (FColors.Count>ValueIndex) then
result:=TColor(FColors{$IFOPT R-}.List{$ENDIF}[ValueIndex])
else
result:=clTeeColor;
end;

to

Function TChartSeries.InternalColor(ValueIndex:Integer):TColor;
Begin
if Assigned(FColors) and (FColors.Count>ValueIndex) and (ValueIndex >= 0) then
result:=TColor(FColors{$IFOPT R-}.List{$ENDIF}[ValueIndex])
else
result:=clTeeColor;
end;

... because the color of a point in my opinion is not important enough to throw an exception if it is called with "-1".

OR

you try to find the reason for the "-1" ;-)

Would be better than waiting till another customer complains about it, wouldn't it?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 19, 2008 4:46 pm

Hi MarkusM,

Thanks for the information.

The best way for addressing this issue would be finding how to reproduce it consistenly so we can be sure of what is causing it and can go to the root of the problem.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply