Lazarus

Programming => Graphics and Multimedia => TAChart => Topic started by: eaea on May 04, 2018, 11:24:03 pm

Title: [SOLVED] TChart with Minors bug (unfreed memory blocks)!?
Post by: eaea on May 04, 2018, 11:24:03 pm
Hello to all!

This is my first post here (and one of my few post ever in my life to a forum), so please be patient with me   :)

When Minors are added to a TChartAxis of a TChartAxisList of a TChart and some Point are added to the charts' series (here: Chart1LineSeries1) and the application is closed then there are unfreed memory blocks reported.

I have tried to manually clear, free, destroy the series and the chart in various order, with no effect.

In the attachment's zip-file is a minimalistic project of few lines, which demonstrates this.

Lazarus version: 1.8.2 (2018-03-30)
FPC version: 3.0.4
SVN revision: 57369
OS: Windows 10, x86 64 bit

Ether this is a bug or I'm doing something wrong...

Greetings

To the admin: I wrote this post some minutes ago, but i cannot find it anymore - maybe its lost. Please delete the previous post.
Title: Re: TChart with Minors bug (unfreed memory blocks)!?
Post by: wp on May 05, 2018, 12:02:46 am
I can confirm the issue, I will have a look...
Title: Re: TChart with Minors bug (unfreed memory blocks)!?
Post by: wp on May 06, 2018, 11:13:24 pm
Thank you for waiting. Fixed in r57796, Lazarus trunk. back-porting to the next fixes release is requested.

Since you use version 1.8.2 you must appy the patch manually if you want to have the fix immediately:
Code: Pascal  [Select][+][-]
  1.   procedure DrawMinors(AFixedCoord: Integer; AMin, AMax: Double);
  2.   const
  3.     EPS = 1e-6;
  4.   var
  5.     j: Integer;
  6.     minorMarks: TChartValueTextArray;
  7.     m: TChartValueText;
  8.   begin
  9.     if IsNan(AMin) or (AMin = AMax) then exit;
  10.     for j := 0 to Minors.Count - 1 do begin
  11.       minorMarks := Minors[j].GetMarkValues(AMin, AMax);
  12.       if minorMarks = nil then continue;
  13.       with FHelper.Clone do
  14.         try
  15.           FAxis := Minors[j];
  16.           // Only draw minor marks strictly inside the major mark interval.
  17.           FValueMin := Max(FAxisTransf(AMin), FValueMin);
  18.           FValueMax := Min(FAxisTransf(AMax), FValueMax);
  19.           if FValueMax <= FValueMin then
  20.             continue;
  21.           ExpandRange(FValueMin, FValueMax, -EPS);
  22.           FClipRangeDelta := 1;
  23.           try
  24.             BeginDrawing;
  25.             for m in minorMarks do
  26.               DrawMark(AFixedCoord, FHelper.FAxisTransf(m.FValue), m.FText);
  27.           finally
  28.             EndDrawing;
  29.           end;
  30.         finally
  31.           Free;
  32.         end;
  33.     end;
  34.   end;
Title: [SOLVED] TChart with Minors bug (unfreed memory blocks)!?
Post by: eaea on May 10, 2018, 10:15:16 pm
Hello

... this works great - thank you very much!

Greetings


(How to mark a topic solved???)
Title: Re: TChart with Minors bug (unfreed memory blocks)!?
Post by: howardpc on May 10, 2018, 10:18:59 pm
You (the topic originator) are able to edit the topic Subject to include "SOLVED" or some such.
TinyPortal © 2005-2018