I have a component that I create and then pass into it a panel on my main form.
Here is a very simplified example:
procedure TMy_Socket.StatusPanel_Add(AStatusPanel: TPanel);
This component will then update the panels caption as the need arises.
In my main program if I FreeAndNil the panel the next time the component tries to update the panel I get an AV. I understand why: the component’s reference to the panel now is pointing to an undefined location.
How can I detect within the component if the panel has been freed so I know I can not reference it?
I tried if (AStatusPanel = nil) but it is not nil, it still has an address.
You have to call the Panel’s
FreeNotification()method, and then have yourTMy_Socketcomponent override the virtualNotification()method, eg (given your naming scheme, I assume you can add multipleTPanelcontrols to your component):If you are only tracking one
TPanelat a time instead: