I have an application which is loading all dynamically created datamodules into a TList. Application is running under windows XP OS. When closing the application from the application close button the code executes correctly. But when closing the application from the taskbar menu an Invalid pointer operation is raised. The same code behaves different when closing the application in different ways.
the code responsible for destroying the datamodules
for iPos := 0 to FDatamodules.Count - 1 do //FDataModules is of type TList
if FDatamodules.Items[iPos] <> nil then
TDatamodule(FDatamodules.Items[iPos]).Free;
and the stack
:7c812a6b kernel32.RaiseException + 0x52
System.TObject.FreeInstance
System.ErrorAt(2,$4A7FEFC)
System.Error(reInvalidPtr)
System.TObject.FreeInstance
System._ClassDestroy(???)
Classes.TDataModule.Destroy
System.TObject.Free
RBAFORM.TRBABaseForm.Destroy
LE: It seems that closing the application from the taskbar menu is sending a HALT(0) to the application and the datamodule get freed. On the image bellow :on the left is the stack of the normal close action, on the right the stack of closing application from the taskbar menu.