I am out of words and at loss of straight thinking !
WTF is that stack ?
Did Embarcadero completely redesigned the TApplication in
VCL ? and butchered it in the process ?
In D12 they completely reworked the support for
MDI UIs to allow all the modern features users expect on Win 10 and 11. There probably are a lot of legacy
MDI programs around that are in dire need of updating and from Embarcadero customers with some clout
...
This Visual manager thing was appearendly introduced to implement this support, but they introduced a bug in the process as well.
At the very end of TCustomForm.WndProc there are these lines:
Delphi-Quellcode:
inherited WndProc(Message);
if VisualManager_AcceptMessage(Message) then
VisualManager_WndProc(Message);
end;
Closing a secondary form with an OnClose handler that sets caFree as close action eventually calls TCustomform.Release, which posts a CM_RELEASE message to the form. The inherited WndProc call above passes that to the CMRelease message handler, which Frees the form instance. So the form self reference is invalid when VisualManager_AcceptMessage is called, and since that method tries to read a field of the form it blows up.