mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 14:19:22 +02:00
TAChart: Fix issue with sorted TListChartSource when unsorted data are added via DataPoints property. Issue #35664, patch by Marcin Wiazowski.
git-svn-id: trunk@61314 -
This commit is contained in:
parent
96442a5bea
commit
515b81420b
@ -304,10 +304,12 @@ type
|
|||||||
function Get(Index: Integer): String; override;
|
function Get(Index: Integer): String; override;
|
||||||
function GetCount: Integer; override;
|
function GetCount: Integer; override;
|
||||||
procedure Put(Index: Integer; const S: String); override;
|
procedure Put(Index: Integer; const S: String); override;
|
||||||
|
procedure SetTextStr(const Value: string); override;
|
||||||
procedure SetUpdateState(AUpdating: Boolean); override;
|
procedure SetUpdateState(AUpdating: Boolean); override;
|
||||||
public
|
public
|
||||||
constructor Create(ASource: TListChartSource);
|
constructor Create(ASource: TListChartSource);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure Assign(Source: TPersistent); override;
|
||||||
procedure Clear; override;
|
procedure Clear; override;
|
||||||
procedure Delete(Index: Integer); override;
|
procedure Delete(Index: Integer); override;
|
||||||
procedure Insert(Index: Integer; const S: String); override;
|
procedure Insert(Index: Integer; const S: String); override;
|
||||||
@ -324,6 +326,29 @@ end;
|
|||||||
|
|
||||||
{ TListChartSourceStrings }
|
{ TListChartSourceStrings }
|
||||||
|
|
||||||
|
procedure TListChartSourceStrings.Assign(Source: TPersistent);
|
||||||
|
var
|
||||||
|
SaveSorted: Boolean;
|
||||||
|
begin
|
||||||
|
BeginUpdate;
|
||||||
|
try
|
||||||
|
// new data may come unsorted - to avoid exception in TCustomSortedChartSource.
|
||||||
|
// ItemInsert() in this case, we disable FSorted temporarily - then we'll sort
|
||||||
|
// the whole dataset if needed
|
||||||
|
SaveSorted := FSource.FSorted;
|
||||||
|
try
|
||||||
|
FSource.FSorted := false;
|
||||||
|
inherited Assign(Source);
|
||||||
|
finally
|
||||||
|
FSource.FSorted := SaveSorted;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if FSource.IsSorted then FSource.Sort;
|
||||||
|
finally
|
||||||
|
EndUpdate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TListChartSourceStrings.Clear;
|
procedure TListChartSourceStrings.Clear;
|
||||||
begin
|
begin
|
||||||
if not (csLoading in FSource.ComponentState) then
|
if not (csLoading in FSource.ComponentState) then
|
||||||
@ -501,6 +526,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TListChartSourceStrings.SetTextStr(const Value: string);
|
||||||
|
var
|
||||||
|
SaveSorted: Boolean;
|
||||||
|
begin
|
||||||
|
BeginUpdate;
|
||||||
|
try
|
||||||
|
// new data may come unsorted - to avoid exception in TCustomSortedChartSource.
|
||||||
|
// ItemInsert() in this case, we disable FSorted temporarily - then we'll sort
|
||||||
|
// the whole dataset if needed
|
||||||
|
SaveSorted := FSource.FSorted;
|
||||||
|
try
|
||||||
|
FSource.FSorted := false;
|
||||||
|
inherited SetTextStr(Value);
|
||||||
|
finally
|
||||||
|
FSource.FSorted := SaveSorted;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if FSource.IsSorted then FSource.Sort;
|
||||||
|
finally
|
||||||
|
EndUpdate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TListChartSourceStrings.SetUpdateState(AUpdating: Boolean);
|
procedure TListChartSourceStrings.SetUpdateState(AUpdating: Boolean);
|
||||||
begin
|
begin
|
||||||
if not (csLoading in FSource.ComponentState) then
|
if not (csLoading in FSource.ComponentState) then
|
||||||
@ -741,13 +789,7 @@ end;
|
|||||||
procedure TListChartSource.SetDataPoints(const AValue: TStrings);
|
procedure TListChartSource.SetDataPoints(const AValue: TStrings);
|
||||||
begin
|
begin
|
||||||
if FDataPoints = AValue then exit;
|
if FDataPoints = AValue then exit;
|
||||||
BeginUpdate;
|
FDataPoints.Assign(AValue);
|
||||||
try
|
|
||||||
FDataPoints.Assign(AValue);
|
|
||||||
if IsSorted then Sort;
|
|
||||||
finally
|
|
||||||
EndUpdate;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TListChartSource.SetText(AIndex: Integer; const AValue: String): Integer;
|
function TListChartSource.SetText(AIndex: Integer; const AValue: String): Integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user