hcOPF - AV in Application with hcCodeSite defined

If you get an AV on shutdown of an application using hcOPF with the packages compiled with the hcCodeSite directive defined, the problem is likely the sequence of events.

My current project uses a global domain object representing the place of business. This domain object is created in the TDataModule.OnCreate event and destroyed in the TDataModule.OnDestroy event. The domain object uses a number of ThcParentedObjectLists which have CodeSite messages in the Clear method. Unfortunately, the hcCodeSite object used to send those messages was already freed in the Finalization section of the hcCodeSiteHelper unit prior to the TDataModule.OnDestroy event being called.

The workaround I used was to create and destroy my domain object in an initialization and finalization section I added to the datamodule.

Hopefully this post will save someone else the time it took me to figure this one out.

Tags: ,

Leave a Reply