TAChart: Fix crash when using TChartExtentLink with LinkedChart.Chart = nil

git-svn-id: trunk@38710 -
This commit is contained in:
ask 2012-09-17 07:43:14 +00:00
parent 8870f3c68e
commit fcf2372934

View File

@ -128,23 +128,24 @@ procedure TChartExtentLink.SyncWith(AChart: TChart);
var var
c: TCollectionItem; c: TCollectionItem;
ch: TChart;
begin begin
if not FEnabled or (AChart = nil) then exit; if not FEnabled or (AChart = nil) then exit;
for c in LinkedCharts do for c in LinkedCharts do begin
with TLinkedChart(c).Chart do begin ch := TLinkedChart(c).Chart;
// Do not sync if the chart was never drawn yet. // Do not sync if the chart was never drawn yet.
if LogicalExtent = EmptyExtent then continue; if (ch = nil) or (ch.LogicalExtent = EmptyExtent) then continue;
// An event loop will be broken since setting LogicalExtent to // An event loop will be broken since setting LogicalExtent to
// the same value does not initiale the extent broadcast. // the same value does not initiale the extent broadcast.
case Mode of case Mode of
elmXY: elmXY:
LogicalExtent := AChart.LogicalExtent; ch.LogicalExtent := AChart.LogicalExtent;
elmOnlyX: elmOnlyX:
LogicalExtent := CombineXY(AChart.LogicalExtent, LogicalExtent); ch.LogicalExtent := CombineXY(AChart.LogicalExtent, ch.LogicalExtent);
elmOnlyY: elmOnlyY:
LogicalExtent := CombineXY(LogicalExtent, AChart.LogicalExtent); ch.LogicalExtent := CombineXY(ch.LogicalExtent, AChart.LogicalExtent);
end;
end; end;
end;
end; end;
end. end.