Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Crash in IWForm.FillRealTabOrder - every 2-3 clicks
#10
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:

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,
Reply


Messages In This Thread
RE: Crash in IWForm.FillRealTabOrder - every 2-3 clicks - by Alexandre Machado - 07-04-2020, 11:43 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)