I am creating a new instance of an editor form and placing the form on a tabbed dock panel. I have added an event handler (DoClose) for the dock panel which is placed in the editor form and I use to determine if document needs saving etc. I finish the handler with Action := caFree.
If I click on the Close X on the DocPanels header, my OnClose event handler in my Editor Form is called, see below:
procedure TfmEditor.DoClose(Sender: TObject; var Action: TLMDockPanelCloseAction);
// do my preclosing work here...
Action := caFree;
When I try and open another document I get an access violation. Something isn't being cleared properly
Removing caFree works and I can open other tabbed tabbed documents but tabs for all documents opened remain even though the forms placed on them have now been closed.
How should I be closing my documents to stop this happening?