Closing TWebform with it's parent set leads to application crash

Hello,

It's my first TMS Web application, so please bear with me.

I'm testing to display another page after a user login. Here is my code:

procedure TForm1.WebLoginPanel1Login(Sender: TObject);
var
  newform: TForm2;
begin
  newform := TForm2.Create(Self);
  newform.Parent := Form1;
  // load file HTML template + controls
  await(TForm2, newform.Load());
  // init control after loading
  newform.WebEdit1.Text := 'hello';
  try
    // excute form and wait for close
    await(TModalResult, newform.Execute);
    ShowMessage('Form 2 closed with new value:"' + newform.WebEdit1.Text + '"');
  finally
    newform.Free;
  end;

Form2 has it's align property set to allclient.
Close button code is basic;

procedure TForm2.WebButton1Click(Sender: TObject);
begin
close;
end;

Form1 is displaying after closing the dialogbox.

As soon as I click on the Form1, I'm getting an error:

Any idea on how to fix this (only workaround I found was to remove newform.Parent := Form1; but then form2 isn't full screen anymore)

Thanks

It is not clear what is causing this.
Is this with the latest version v2.0.2.2?
Did you test & compare with the demo under Demo\Basic\MultiForm?

testweb.zip (10.2 KB)

All TMS Libraries are up to date (Web Core v2.0.2.2).
Only difference I see is setting newform.Parent := Form1;

I have uploaded my project.
Ps: is there any raison why project isn't always displayed on Google Chrome? I have sometime to run project 10x time to get it display

You should not set the parent before the form is loaded. It would already internally create a form instance while in the next step you do form.load() that also creates a form instance.

We are not aware of an issue that it is not displaying in Chrome. Always check your browser console for possible errors and/or ensure your browser cache is cleared (via Empty cache & hard reload option).

Hello Bruno,

I wan't aware that setting parent before loading the form could crash everything (and I couldn't find warning regarding this in the help documentation). Can this not be handled by the framework differently? (it's odd that setting a parent property leads to application crash), anyway I know now why it happened).

Regarding Chrome issue: I tried to clear cache but problem persisted. Everything went fine after Web core 2.0.2.2 installation and VM restart.

Thank you for your help.

Kind regards

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.