TFastLineSeries DrawMarks cause TChart Crash
Posted: Thu Jan 31, 2013 3:18 pm
Hi,
We are using TeeChart2012RADXE2.Build 2012.07.121105
with my Delphi XE2 Update 4
I recently observed some crashs during usage of FastLineSeries. I gave up on making some small example for you.
But I have pin-pointed some problem in your sources I believe:
We have derived from TFastLineSeries ( TOurFastLineSeries = class(TFastLineSeries) )
Here we have made override of DrawMarks.
We do nothing more that just calling inherited DrawMarks. A crash occurs.
And it turns out that when we examine FFirstVisibleIndex from parent class FFirstVisibleIndex
It is -2!!! yes we see "FFirstVisibleIndex = -2"
So for now we made a work around in
TOurFastLineSeries.DrawMarks
begin
...
if "FFirstVisibleIndex < 0 then
"FFirstVisibleIndex := 0;
...
end;
>>> This error will cause the TChart to be non-functional!!! A re-create TChart is needed!! The instance is dead.
If you examine TChartSeries.DrawMarks you will see that St := GetMarkText(t) will produce an error when you put t:= -2
Ok, so where could the the -2 happen?!
The only place we have found where some spooky stuff takes place is in VclTee.Series.pas
procedure TFastLineSeries.CalcFirstLastVisibleIndex;
begin
inherited;
if (not FDrawAll) and (FFirstVisibleIndex = FLastVisibleIndex) and
(FFirstVisibleIndex>-1) then
begin
Dec(FFirstVisibleIndex);
FFirstVisibleIndex:=GetLastYMaxIndex(FFirstVisibleIndex);
>>>> may you need to put a limit on FFirstVisibleIndex, because nothing stops it to become -2... as we have seen happen during debug.
end;
end;
>>>> or in GetLastYMaxIndex may give below -1:
function TFastLineSeries.GetLastYMaxIndex(ValueIndex: Integer): Integer;
var tmpIndex,
pixelXPos : Integer;
begin
tmpIndex:=ValueIndex;
pixelXPos:=GetHorizAxis.CalcXPosValue(XValues.Value[tmpIndex]);
repeat
Dec(tmpIndex);
if tmpIndex > -1 then
pixelXPos := GetHorizAxis.CalcXPosValue(XValues.Value[tmpIndex]);
until ((tmpIndex - 1 = -1) or
(pixelXPos <> GetHorizAxis.CalcXPosValue(XValues.Value[tmpIndex - 1]))
or (tmpIndex < -1)); //TV52015898
>>>>> here you we have seen tmpIndex := -2 ... and maybe it coule even become less... You probably have to put a limit for it?
result:=tmpIndex;
end;
Best regards Christian
We are using TeeChart2012RADXE2.Build 2012.07.121105
with my Delphi XE2 Update 4
I recently observed some crashs during usage of FastLineSeries. I gave up on making some small example for you.
But I have pin-pointed some problem in your sources I believe:
We have derived from TFastLineSeries ( TOurFastLineSeries = class(TFastLineSeries) )
Here we have made override of DrawMarks.
We do nothing more that just calling inherited DrawMarks. A crash occurs.
And it turns out that when we examine FFirstVisibleIndex from parent class FFirstVisibleIndex
It is -2!!! yes we see "FFirstVisibleIndex = -2"
So for now we made a work around in
TOurFastLineSeries.DrawMarks
begin
...
if "FFirstVisibleIndex < 0 then
"FFirstVisibleIndex := 0;
...
end;
>>> This error will cause the TChart to be non-functional!!! A re-create TChart is needed!! The instance is dead.
If you examine TChartSeries.DrawMarks you will see that St := GetMarkText(t) will produce an error when you put t:= -2
Ok, so where could the the -2 happen?!
The only place we have found where some spooky stuff takes place is in VclTee.Series.pas
procedure TFastLineSeries.CalcFirstLastVisibleIndex;
begin
inherited;
if (not FDrawAll) and (FFirstVisibleIndex = FLastVisibleIndex) and
(FFirstVisibleIndex>-1) then
begin
Dec(FFirstVisibleIndex);
FFirstVisibleIndex:=GetLastYMaxIndex(FFirstVisibleIndex);
>>>> may you need to put a limit on FFirstVisibleIndex, because nothing stops it to become -2... as we have seen happen during debug.
end;
end;
>>>> or in GetLastYMaxIndex may give below -1:
function TFastLineSeries.GetLastYMaxIndex(ValueIndex: Integer): Integer;
var tmpIndex,
pixelXPos : Integer;
begin
tmpIndex:=ValueIndex;
pixelXPos:=GetHorizAxis.CalcXPosValue(XValues.Value[tmpIndex]);
repeat
Dec(tmpIndex);
if tmpIndex > -1 then
pixelXPos := GetHorizAxis.CalcXPosValue(XValues.Value[tmpIndex]);
until ((tmpIndex - 1 = -1) or
(pixelXPos <> GetHorizAxis.CalcXPosValue(XValues.Value[tmpIndex - 1]))
or (tmpIndex < -1)); //TV52015898
>>>>> here you we have seen tmpIndex := -2 ... and maybe it coule even become less... You probably have to put a limit for it?
result:=tmpIndex;
end;
Best regards Christian