EdwsActivePrograms exception when closing the application

114 Views Asked by At

I'm getting the following EdwsActivePrograms exception when IdwsProgram and IdwsProgramExecution variables are defined globally:

TDelphiWebScript instance "dws" still has 1 active IdwsProgram instance(s)

Steps to reproduce based on the example below: Start the application, hit Button1, then Button2, and finally close the application. The exception pops up when I close the application.

var
  prog : IdwsProgram;
  exec : IdwsProgramExecution;

procedure TForm1.Button1Click(Sender: TObject);
begin
  prog := dws.Compile('begin'#13#10'end;');
  if prog.Msgs.Count = 0 then
    exec := prog.BeginNewExecution;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  exec.EndProgram;
end;

In above example dws is a TDelphiWebScript component dropped on the form. My goal is to reuse IdwsProgramExecution instance in the application. Running on Delphi 10.1 and latest DWScript sources.

0

There are 0 best solutions below