07-04-2020, 11:43 PM
(This post was last modified: 07-04-2020, 11:43 PM by Alexandre Machado.)
Hi Victoria,
After playing with your code, here's what happens:
You are creating a TIWImageFile and not setting a parent control which causes it to be included in the internal form's list of controls. But once it has no parent, when it is destroyed it won't notify the form that it is being removed (because the owner is a IWGrid, not the form itself), so the form ends up with a dangling reference to a freed object.
In order to fix it, please set the parent of all your controls created at runtime. Example:
This will fix it.
The way tab order is set in IW 15.2 branch is different compared to 15.1 and this broke your code.
I'm implementing some other checks in a new update so it will also behave as expected even if you don't set the parent of the control. It should be released soon, if you prefer to wait.
Cheers,
After playing with your code, here's what happens:
You are creating a TIWImageFile and not setting a parent control which causes it to be included in the internal form's list of controls. But once it has no parent, when it is destroyed it won't notify the form that it is being removed (because the owner is a IWGrid, not the form itself), so the form ends up with a dangling reference to a freed object.
In order to fix it, please set the parent of all your controls created at runtime. Example:
Code:
procedure SetCellLinkIcon(oCell:TIwGridCell;sImg:String;sHint:String;oEvent:TIWAsyncEvent;sParams:String);
var
oLink:TIWImageFile;
begin
oLink := TIWImageFile.Create(IWGrid_Dispo);
oLink.Parent := IWGrid_Dispo.Parent; // <- Add your IWForm directly here, or use the IWGrid's parent
if(sParams<>'')then
begin
oLink.Css := 'ImageLink';
end else
begin
oLink.Css := 'ImageLinkForbidden';
end;
oLink.Cacheable := true;
oLink.AutoSize := false;
oLink.ImageFile.URL := '/'+sImg;
//oLink.Height := iIconDim;
//oLink.Width := iIconDim;
oLink.Hint := sHint;
oLink.ExtraTagParams.Text := sParams;
oLink.ShowHint := (sHint<>'');
oLink.OnAsyncClick := oEvent;
oLink.TabOrder := -1;
oCell.Control := oLink;
end;
This will fix it.
The way tab order is set in IW 15.2 branch is different compared to 15.1 and this broke your code.
I'm implementing some other checks in a new update so it will also behave as expected even if you don't set the parent of the control. It should be released soon, if you prefer to wait.
Cheers,