diff --git a/components/tachart/tacustomsource.pas b/components/tachart/tacustomsource.pas index d68e0ac247..d229c2c9e9 100644 --- a/components/tachart/tacustomsource.pas +++ b/components/tachart/tacustomsource.pas @@ -849,7 +849,8 @@ begin end; end; - FBasicExtentIsValid := true; + FBasicExtentIsValid := not IsUpdating; // When updating, we are not allowed + // to set "Valid" for caches - see comment in TListChartSource.ClearCaches() Result := FBasicExtent; end; @@ -888,7 +889,8 @@ begin UpdateMinMax(XList[j], FXListExtent.a.X, FXListExtent.b.X); end; - FXListExtentIsValid := true; + FXListExtentIsValid := not IsUpdating; // When updating, we are not allowed + // to set "Valid" for caches - see comment in TListChartSource.ClearCaches() end; Result.a.X := Min(Result.a.X, FXListExtent.a.X); @@ -915,7 +917,8 @@ begin UpdateMinMax(YList[j], FYListExtent.a.Y, FYListExtent.b.Y); end; - FYListExtentIsValid := true; + FYListExtentIsValid := not IsUpdating; // When updating, we are not allowed + // to set "Valid" for caches - see comment in TListChartSource.ClearCaches() end; Result.a.Y := Min(Result.a.Y, FYListExtent.a.Y); @@ -1018,7 +1021,8 @@ begin end; end; - FCumulativeExtentIsValid := true; + FCumulativeExtentIsValid := not IsUpdating; // When updating, we are not allowed + // to set "Valid" for caches - see comment in TListChartSource.ClearCaches() end; Result.a.Y := Min(Result.a.Y, FCumulativeExtent.a.Y); @@ -1499,7 +1503,8 @@ begin for i := 0 to Count - 1 do with Item[i]^ do FValuesTotal += NumberOr(Y); - FValuesTotalIsValid := true; + FValuesTotalIsValid := not IsUpdating; // When updating, we are not allowed + // to set "Valid" for caches - see comment in TListChartSource.ClearCaches() Result := FValuesTotal; end; diff --git a/components/tachart/tasources.pas b/components/tachart/tasources.pas index dbc29d4f99..483ec6d69b 100644 --- a/components/tachart/tasources.pas +++ b/components/tachart/tasources.pas @@ -720,16 +720,20 @@ end; procedure TListChartSource.ClearCaches; begin + // When updating, we are not allowed to set "Valid" for caches - cached + // data is not synchronized with real data when updating, so setting "Valid" + // could lead to reading outdated cache contents, when calling methods like + // BasicExtent() when still in update mode FBasicExtent := EmptyExtent; - FBasicExtentIsValid := true; + FBasicExtentIsValid := not IsUpdating; FCumulativeExtent := EmptyExtent; - FCumulativeExtentIsValid := true; + FCumulativeExtentIsValid := not IsUpdating; FXListExtent := EmptyExtent; - FXListExtentIsValid := true; + FXListExtentIsValid := not IsUpdating; FYListExtent := EmptyExtent; - FYListExtentIsValid := true; + FYListExtentIsValid := not IsUpdating; FValuesTotal := 0; - FValuesTotalIsValid := true; + FValuesTotalIsValid := not IsUpdating; end; procedure TListChartSource.CopyFrom(ASource: TCustomChartSource);