mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 05:19:31 +02:00
TAChart: Optimization of chart sources between BeginUpdate/EndUpdate. Issue #35333, patch by Marcin Wiazowski.
git-svn-id: trunk@60868 -
This commit is contained in:
parent
11e60c45bc
commit
db88431d08
@ -219,6 +219,7 @@ type
|
||||
public
|
||||
procedure AfterDraw; virtual;
|
||||
procedure BeforeDraw; virtual;
|
||||
procedure BeginUpdate; override;
|
||||
procedure EndUpdate; override;
|
||||
public
|
||||
class procedure CheckFormat(const AFormat: String);
|
||||
@ -930,6 +931,17 @@ begin
|
||||
Notify;
|
||||
end;
|
||||
|
||||
procedure TCustomChartSource.BeginUpdate;
|
||||
begin
|
||||
// Caches will be eventually invalidated in a corresponding EndUpdate() call.
|
||||
// Since, at this moment, we are already sure, that caches will be invalidated,
|
||||
// it's better to invalidate them immediately - this will prevent useless efforts
|
||||
// to keep caches coherent between BeginUpdate() and EndUpdate() calls.
|
||||
if FUpdateCount = 0 then
|
||||
InvalidateCaches;
|
||||
Inc(FUpdateCount);
|
||||
end;
|
||||
|
||||
procedure TCustomChartSource.EndUpdate;
|
||||
begin
|
||||
Dec(FUpdateCount);
|
||||
|
@ -612,6 +612,13 @@ end;
|
||||
|
||||
procedure TListChartSource.Delete(AIndex: Integer);
|
||||
begin
|
||||
// Optimization
|
||||
if IsUpdating then begin
|
||||
Dispose(Item[AIndex]);
|
||||
FData.Delete(AIndex);
|
||||
exit;
|
||||
end;
|
||||
|
||||
with Item[AIndex]^ do begin
|
||||
FBasicExtentIsValid := FBasicExtentIsValid and
|
||||
(((FBasicExtent.a.X < X) and (X < FBasicExtent.b.X)) or (XCount = 0)) and
|
||||
@ -873,6 +880,7 @@ end;
|
||||
|
||||
procedure TListChartSource.UpdateCachesAfterAdd(AX, AY: Double);
|
||||
begin
|
||||
if IsUpdating then exit; // Optimization
|
||||
if FBasicExtentIsValid then begin
|
||||
if FXCount > 0 then UpdateMinMax(AX, FBasicExtent.a.X, FBasicExtent.b.X);
|
||||
if FYCount > 0 then UpdateMinMax(AY, FBasicExtent.a.Y, FBasicExtent.b.Y);
|
||||
|
Loading…
Reference in New Issue
Block a user