located serious bug and have solution

There is a serious bug in the latet QB.

In the following proc:

procedure TOQBTable._CloseBtn(Sender: TObject);
begin

TOQBArea(Parent).UnlinkTable(Self);
TOQBForm(GetParentForm(Self)).QBGrid.RemoveColumn4Tbl(FTableName);
Parent.RemoveControl(Self);
free;
end;

The free is causing a access violation because you are freeing the container of the close button while you are still in the close buttons close event.

I am not sure what would be the best way for a permenant fix, but I came up with this

procedure TOQBTable._CloseBtn(Sender: TObject);
begin
try
TOQBArea(Parent).UnlinkTable(Self);
TOQBForm(GetParentForm(Self)).QBGrid.RemoveColumn4Tbl(FTableName);
Parent.RemoveControl(Self);
postmessage(mainform.Handle,DM_CLOSETABLE,integer(self),integer(self));
except
on e:exception do
showmessage(e.Message);
end;

end;

I send the integer value of the toqbtable via post message to the main form where I free it and then the AV is gone.

I am not sure how to solve this without using a windows message.

Any ideas?

Thanks,

snorkel

Leave a Comment