mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:59:20 +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
|
public
|
||||||
procedure AfterDraw; virtual;
|
procedure AfterDraw; virtual;
|
||||||
procedure BeforeDraw; virtual;
|
procedure BeforeDraw; virtual;
|
||||||
|
procedure BeginUpdate; override;
|
||||||
procedure EndUpdate; override;
|
procedure EndUpdate; override;
|
||||||
public
|
public
|
||||||
class procedure CheckFormat(const AFormat: String);
|
class procedure CheckFormat(const AFormat: String);
|
||||||
@ -930,6 +931,17 @@ begin
|
|||||||
Notify;
|
Notify;
|
||||||
end;
|
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;
|
procedure TCustomChartSource.EndUpdate;
|
||||||
begin
|
begin
|
||||||
Dec(FUpdateCount);
|
Dec(FUpdateCount);
|
||||||
|
@ -612,6 +612,13 @@ end;
|
|||||||
|
|
||||||
procedure TListChartSource.Delete(AIndex: Integer);
|
procedure TListChartSource.Delete(AIndex: Integer);
|
||||||
begin
|
begin
|
||||||
|
// Optimization
|
||||||
|
if IsUpdating then begin
|
||||||
|
Dispose(Item[AIndex]);
|
||||||
|
FData.Delete(AIndex);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
with Item[AIndex]^ do begin
|
with Item[AIndex]^ do begin
|
||||||
FBasicExtentIsValid := FBasicExtentIsValid and
|
FBasicExtentIsValid := FBasicExtentIsValid and
|
||||||
(((FBasicExtent.a.X < X) and (X < FBasicExtent.b.X)) or (XCount = 0)) 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);
|
procedure TListChartSource.UpdateCachesAfterAdd(AX, AY: Double);
|
||||||
begin
|
begin
|
||||||
|
if IsUpdating then exit; // Optimization
|
||||||
if FBasicExtentIsValid then begin
|
if FBasicExtentIsValid then begin
|
||||||
if FXCount > 0 then UpdateMinMax(AX, FBasicExtent.a.X, FBasicExtent.b.X);
|
if FXCount > 0 then UpdateMinMax(AX, FBasicExtent.a.X, FBasicExtent.b.X);
|
||||||
if FYCount > 0 then UpdateMinMax(AY, FBasicExtent.a.Y, FBasicExtent.b.Y);
|
if FYCount > 0 then UpdateMinMax(AY, FBasicExtent.a.Y, FBasicExtent.b.Y);
|
||||||
|
Loading…
Reference in New Issue
Block a user