The attached project demonstrates the issue discussed in the previous topic. ChartImageList1 contains two "stationary" icons (a chart icon to be used for the root of the treeview next to the chart; and two dummy icons), as well as two "dynamic" icons created from the two series of the chart. Because the imagelist is cleared upon reading from the stream in the present implementation the chart icon is not shown.
The two attached patches fix the problem. At first, the SaveData method of the initial submission of TChartImageList is restored; it unlinks the chart from the Imagelist and by this way removes the dynamic icons from the imagelist before writing the stream. Since no series images are stored in the lfm the ReadData method resets the internal series counter after reading the stationary icons.
However, this is not enough -- the program can crash after this modification. The reason is a bug in TCustomImageList which allows to access the zero'th element of an array dimensioned to zero length. This is fixed in the second patch which I just reported to the BugTracker (
http://mantis.freepascal.org/view.php?id=23834).
With both patches applied the demo runs fine. Also, there is no memory leak.
Please don't apply the ChartImageList patch before the other patch has been applied by the bug tracker team. I can drop a message here when this has been done.