diff --git a/components/tachart/tadbsource.pas b/components/tachart/tadbsource.pas index 3f2e83cc37..7310aaaf82 100644 --- a/components/tachart/tadbsource.pas +++ b/components/tachart/tadbsource.pas @@ -147,6 +147,7 @@ begin inherited AfterDraw; try if not FDataLink.Active or (FBookmark = nil) then exit; + FDataLink.Dataset.EnableControls; FDataLink.DataSet.GotoBookmark(FBookmark); FDataLink.DataSet.FreeBookmark(FBookmark); finally @@ -159,6 +160,7 @@ procedure TDbChartSource.BeforeDraw; begin inherited BeforeDraw; VLockedDatasets.Add(FDataLink.DataSet); + FDataLink.Dataset.DisableControls; if FDataLink.Active and (FBookmark = nil) then FBookmark := FDataLink.DataSet.GetBookmark; end; diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index 3ac6e24fee..bc17108098 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -241,6 +241,7 @@ type FOnExtentChanging: TChartEvent; FOnExtentValidate: TChartExtentValidateEvent; FOnFullExtentChanged: TChartEvent; + FBufferedFullExtent: TDoubleRect; FPrevFullExtent: TDoubleRect; FPrevLogicalExtent: TDoubleRect; FScale: TDoublePoint; // Coordinates transformation @@ -254,6 +255,7 @@ type const AMinDataSpace: Integer); procedure FindComponentClass( AReader: TReader; const AClassName: String; var AClass: TComponentClass); + function FullExtentBroadcastActive: Boolean; function GetChartHeight: Integer; function GetChartWidth: Integer; function GetHorAxis: TChartAxis; @@ -969,6 +971,12 @@ begin FCurrentExtent := FLogicalExtent; end; + // Avoid calculation of the full extent when not needed + // This extent calculation must be inside the series.BeforeDraw (--> Prepare) + // and series.AfterDraw block (DBChartSource issue #39313) + if FullExtentBroadcastActive then + FBufferedFullExtent := GetFullExtent; + if Legend.Visible and not Legend.UseSidebar then Legend.Prepare(ldd, FClipRect); @@ -1006,12 +1014,12 @@ begin OnAfterDraw(Self, ADrawer); ADrawer.DrawingEnd; - tmpExtent := GetFullExtent; - if FPrevFullExtent <> tmpExtent then begin + if FullExtentBroadcastActive and (FPrevFullExtent <> FBufferedFullExtent) then + begin FFullExtentBroadcaster.Broadcast(Self); if Assigned(OnFullExtentChanged) then OnFullExtentChanged(Self); - FPrevFullExtent := tmpExtent; + FPrevFullExtent := FBufferedFullExtent; end; if FPrevLogicalExtent <> FLogicalExtent then begin @@ -1142,6 +1150,11 @@ begin AClass := nil; end; +function TChart.FullExtentBroadcastActive: Boolean; +begin + Result := (FFullExtentBroadcaster.Count > 0) or Assigned(FOnFullExtentChanged); +end; + procedure TChart.GetAllSeriesAxisLimits(AAxis: TChartAxis; out AMin, AMax: Double); var interval: TDoubleInterval;