[Lazarus] RFH: AV when deleting TAChart from the form
Martin
lazarus at mfriebe.de
Sun Apr 11 21:01:34 CEST 2010
On 11/04/2010 19:39, Martin wrote:
> On 11/04/2010 18:37, Alexander Klenin wrote:
>> On Mon, Apr 12, 2010 at 02:02, Martin<lazarus at mfriebe.de> wrote:
>>> destructor TChart.Destroy;
>>> begin
>>> FSeries.Free;
>>> ...
>>> inherited Destroy;
>>> end;
>>>
>>> inherited destroy calls getChildren, which accesses FSeries.
>> Even that I would call suspicious, but I think the problem is deeper.
>> The crash still happens even if I comment out the call to inherited
>> Destroy
>> in TChart.Destroy.
I applied your other patch [ FreeAndNil(Fseries); // if FSeries = nil
then exit ]
And I no longer get the crash, so that works.
--------------------
As for calls to GetChildren
the first happens when
FreeAndNil(FSeries)
is called.
I looked through the Callstack, and it seems more than reasonable:
FSerieas.Free, calls TChartSeriesList.Clear;
This destorys some TCharts that are hold by FSeries [ Items[i].FChart
:= nil; ] => TCharts are components, so they notify there owner, and
everyone who requested it, about their death. => The owner is the Form,
and the form tells OI => and OI makes sure that all of its own
structures are good (RefreshSelection;
TComponentTreeView.RebuildComponentNodes; and the likes)
IMHO that is reasonable.
I wont do it, but if you dig deeper, you will find that the other calls
are of similar nature.
Bottomline is, that any Component must expect all kinds of calls during
it's destruction, and must at least return them without crash.
And hey, the best I have seen was a WM_SETFOCUS to a Component in
destruction. I couldn't believe it.....
Martin
More information about the Lazarus
mailing list