I have an application that occasionally throws an error because it is attempting to free an object that has already been freed. All of the forms have code in them that logs the creation and destruction of the form in the corresponding event. Looking at the log for the session that generated the error I see at the end that the OnDestroy event was executed three times in a row. The only time a form is released is when the user elects to move to a different form. There is no way that normal execution of the program could release a form without having created it first. And yet it happened. Has anyone seen this behavior?
The code to change forms is as follows:
procedure TFramePgHdr.Move(AFormClass: TIWAppFormClass; FormName: string);
begin
if TIWAppForm(WebApplication.ActiveForm).Name = FormName then
exit;
// Release the current form
// Note that Intraweb keeps track of which forms exist
TIWAppForm(WebApplication.ActiveForm).Release;
// Create the next form
if TIWAppForm(WebApplication.FindFormByName(FormName)) <> nil then
TIWAppForm(WebApplication.FindFormByName(FormName)).Show
else
AFormClass.Create(WebApplication).Show;
end;
The log for the session is as follows: (ActionValue of 1=form created, -1=form destroyed)
FORM ACTIONVALUE DATECR
TfrmLogin 1 7/27/2015 3:36 PM
TfrmChangeYard 1 7/27/2015 3:36 PM
TfrmLogin -1 7/27/2015 3:36 PM
TfrmViewYard 1 7/27/2015 3:36 PM
TfrmChangeYard -1 7/27/2015 3:36 PM
TfrmRackSmry 1 7/27/2015 3:36 PM
TfrmViewYard -1 7/27/2015 3:37 PM
TfrmViewYard 1 7/27/2015 3:37 PM
TfrmRackSmry -1 7/27/2015 3:37 PM
TfrmInventory 1 7/27/2015 3:37 PM
TfrmViewYard -1 7/27/2015 3:37 PM
TfrmChangeYard 1 7/27/2015 3:38 PM
TfrmInventory -1 7/27/2015 3:38 PM
TfrmViewYard 1 7/27/2015 3:38 PM
TfrmChangeYard -1 7/27/2015 3:38 PM
TfrmInventory 1 7/27/2015 3:38 PM
TfrmViewYard -1 7/27/2015 3:38 PM
TfrmChangeYard 1 7/27/2015 3:39 PM
TfrmInventory -1 7/27/2015 3:39 PM
TfrmInventory -1 7/27/2015 3:39 PM
TfrmInventory -1 7/27/2015 3:39 PM
TfrmChangeYard -1 7/27/2015 3:39 PM
Connect with Us