ghkweon / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Calling script functions from a modal dialog gives “Object not instantiated” #433

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am using the latest DWS from today. 
Attached an example XE4 project.

From the following script code, I call the Run procedure from Delphi which 
calls the showmodal procedure which is also in Delphi. The global variable sl 
is not instantiated when calling Button1Click() from the newly created modal 
dialog.

The Script Code.

var sl : TStringList;

procedure Run();
begin
  sl := TStringList.create();
  ShowModal;
  showMessage(sl.Text);
  sl.free;
end;

procedure Button1Click();
begin
  sl.Add('DWS');
end;

The Delphi side code.

1) Call Run()

FExec := FCompiledScript.BeginNewExecution;
FExec.Info.Func['Run'].Call([]);
FExec.EndProgram;

2) Showmodal Eval

Form1 := TForm1.Create(nil);
Form1.Exec := FExec;
Form1.ShowModal;

3) Calling Button1Click from the modal dialog using the same 
IdwsProgramExecution object

FExec.Info.Func['Button1Click'].Call([]);

At this point I get the error "Object not instantiated". After closing the 
dialog I get the showmessage with nothing in it.

Thanks in advance!

Tom

Original issue reported on code.google.com by tom.robe...@gmail.com on 1 Sep 2013 at 11:20

Attachments:

GoogleCodeExporter commented 8 years ago
Should now be fixed by revision 2249

It was an issue with calls through IInfo made from the context of a TdwsUnit 
function call in a procedure.

Original comment by zar...@gmail.com on 2 Sep 2013 at 7:20

GoogleCodeExporter commented 8 years ago
Have downloaded latest gear and all working beautifully.
Thanks

Original comment by tom.robe...@gmail.com on 2 Sep 2013 at 7:28

GoogleCodeExporter commented 8 years ago
I think a similar fix is required for the RTTI Connector. I get the same AV's 
when replacing the TStringList above with a RTTIVariant.

Original comment by tom.robe...@gmail.com on 10 Sep 2013 at 1:48

Attachments: