[Lazarus] Proper implementation of TDataLink descendant

Alexander Klenin klenin at gmail.com
Thu Aug 4 18:16:20 CEST 2011


After researching http://bugs.freepascal.org/view.php?id=19887, I have
found the following:

0) For context, here is TDbChartSource desctiption:
http://wiki.lazarus.freepascal.org/TAChart_documentation#Database_source
1) My implementation of TDbСhartSource is incorrect, because during
the chart drawing
  it accesses dataset directly from the TDataLink descendant.
  Apparently this causes infinite loop, because such accesses generate
DataSetChanged events,
  which in turn invalidate the chart.
  Even DisableControls/EnableControls do not help, since
EnableControls calls DataSetChanged (!).
2) Looking at the code in TDBGrid, it seems that the correct way is to
use DataLink's ActiveRecord property.
  Unfortunately, in contrast to TDBGrid, TDbСhartSource needs to read
the whole dataset.
  It seems that the only way to do this is to set BufferCount :=
RecordCount, i.e. buffer entire dataset in memory,
  which I do not like.

So, my questions are:

1) Is there a way to totally disable DataSetChanged events in the dataset?
2) Alternatively, is there a mechanism to read entire dataset via
TDataLink without fully buffering it?

-- 
Alexander S. Klenin




More information about the Lazarus mailing list