Error when destroying a form instance

I was doing some modifications to my web application (which is working perfectly online). It's been more than a year since I modified it.
It is a multiple form application, which creates form instances at runtime following the developers guide.
When testing my new changes, I noted that a "main" form I create in runtime is not being destroyed, hence it can not be opened again because the application can not create a component with the same name. The created "main" form works perfectly and the error only happens when closing it and returning to the caller "login" form.
The error mentions that "FToolTip" is not defined and because of that it can't free the runtime "main" form.

Tested on Delphi 11.3 and Delphi 12 with same results.
Webcore installed for both delphi versions is 2.5.4.0.

It's worth mentioning that in the "main" form I have included some components I modified, adding some text properties I needed, none related to hint or tooltip. These components have two years working perfectly on my live application. I just recompiled my components projects but it still fails.

To test, I modified the multiform sample, adding all my custom components and it does not fail, but I noeted that it uses a different method for creating the form:

TAwait.ExecP <TModalResult >(newform.Execute);

Actually it is the first time I see this TAwait.ExecP and the brackets with modal result. I don't use templates for my forms on this project, since they look good for the purpose.

What I use is the other method suggested in the docs, and it has been working fine until now:

procedure TFormLogin.enterMain(user: string);
var
Mform: TFormMain;
begin
FormLogin.visible := false; // this form
Mform := TFormMain.create(self);
with Mform do
begin
POSuser := user;
MCP := 'test';
caption := 'Main Form ';
popup := false;
end;
window.location.hash := 'subform';
await(TFormMain, Mform.load());
try
await(TmodalResult, Mform.Execute);
showmessage('Logged Off');
finally
Mform.Free;
FormLogin.visible := true;
resetallVars;
end
end;

Am sure is something that can be fixed.
Thanks,


Screenshot 2024-06-21 191245
Screenshot 2024-06-21 191330

1 Like

I discovered that the cause was having TwebButtons with property ShowHint = True at design time. It does not matter if the Hint property contains a string or not.

To solve the issue temporarily I edited the form as text, removing all Hint and ShowHint properties. (But how there are no hints when hovering on the buttons. I added the hint so the button only has an icon and no caption)

On my project I could reproduce the issue by just setting the ShowHint property to True on a single TwebButton. The problem goes away setting ShowHint to false.

The strange thing is that on the multiForm demo that comes with TMS WebCore, it does not fail when setting the property in mention. Of course my project is more than two years old, so maybe there is something somewhere that contributes. (And also the multiform demo uses a different approach to create forms at runtime)

I cannot make sense of that. You can clearly see in WEBLib.Controls.pas that just ShowHint = true and Hint = '' has no impact on the runtime. The condition to add a title attribute on the control is that ShowHint = true and Hint <> ''. And I cannot see how just a title attribute on the button element in the DOM would have any effect on destroying a form.

With respect to TAwait.ExecP (newform.Execute); , this is an LSP friendly construct for await(Result, proc);

I found it happens consistently for that project. My first hypothesis was that some residue of old versions is cached somehow, although it sounds as a noob thinking. All versions of WebCore are uninstalled prior to reinstalling the new versions, and I cleaned my project, erasing all but .pas, .dpr, .dproj, corresponding html files. I have no templates or any other javascript libraries than the bootstrap CDN and the google fonts.

If you want, I can capture a desktop video forcing a failure (good thing I know how it fails) and making it work again according to my description.

Tried to post the project’s HTML complete file here but it won’t show. Can email it to you if you want.
Could bootstrap or the fonts css be the cause? Probably not, I have not had any trouble with them before.

Most efficient would be to start from our Multiform demo and modify this demo so the error shows and send this sample source project so we can investigate.

I had a copy of the old style multiform sample (i.e. not using TAwait). I added some elements that are present in my actual project, including creating a third level form, and managed to make it fail.

What I found is as before, removing the hint and set showHint to false makes it work, and showhint to true makes it fail.
But found that there is another condition: if Form2 has the cssLibrary set cssBootstrap it fails. Otherwise it does not fail. As I suspected from the start, it is clashing with bootstrap somehow.

Another interesting issue is that if the form css library is cssBootstrap, the hint does not appear when hovering over the component.

I use the bootstrap css only for a few components in my form, but most of them do not have an elementID, specially because the boxes where I require some info, like social security, must be hidden from view, but putting passwordchar = * annoys the user with browser popups asking for password actions, suggesting passwords, Etc.

Project is attached for the corresponding diagnostic.

Multiform1OLDStyle.zip (10.8 KB)