diff --git a/branches/script-component/Projects/SAMufasaGUI/project1.lpi b/branches/script-component/Projects/SAMufasaGUI/project1.lpi
index e6aca29..3586477 100644
--- a/branches/script-component/Projects/SAMufasaGUI/project1.lpi
+++ b/branches/script-component/Projects/SAMufasaGUI/project1.lpi
@@ -10,7 +10,7 @@
-
+
@@ -139,9 +139,10 @@
-
-
-
+
+
+
+
@@ -266,8 +267,8 @@
-
-
+
+
@@ -350,7 +351,7 @@
-
+
@@ -496,9 +497,9 @@
-
-
-
+
+
+
@@ -625,8 +626,10 @@
-
+
+
+
@@ -768,7 +771,7 @@
-
+
@@ -889,7 +892,7 @@
-
+
@@ -1591,7 +1594,7 @@
-
+
@@ -1646,7 +1649,7 @@
-
+
@@ -1704,10 +1707,10 @@
-
-
+
+
-
+
@@ -1723,7 +1726,7 @@
-
+
@@ -1734,7 +1737,7 @@
-
+
@@ -1855,7 +1858,7 @@
-
+
@@ -1893,7 +1896,7 @@
-
+
@@ -1950,7 +1953,7 @@
-
+
@@ -1996,19 +1999,19 @@
-
-
+
+
-
+
-
+
-
+
@@ -2021,10 +2024,10 @@
-
-
-
-
+
+
+
+
@@ -2047,7 +2050,7 @@
-
+
@@ -2061,7 +2064,7 @@
-
+
@@ -2088,123 +2091,123 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
diff --git a/branches/script-component/Projects/SAMufasaGUI/testunit.pas b/branches/script-component/Projects/SAMufasaGUI/testunit.pas
index 14ac0c1..8b041ce 100644
--- a/branches/script-component/Projects/SAMufasaGUI/testunit.pas
+++ b/branches/script-component/Projects/SAMufasaGUI/testunit.pas
@@ -1699,20 +1699,32 @@ end;
procedure TForm1.SafeCallThread;
+var
+ thread: TMThread;
begin
Writeln('Executing : ' + CurrentSyncInfo.MethodName);
- mmlpsthread.CurrThread := TMThread(CurrentSyncInfo.OldThread);
- with CurrentSyncInfo.PSScript do
- begin;
- OnLine:=@OnLinePSScript;
- CurrentSyncInfo.Res:= Exec.RunProcPVar(CurrentSyncInfo.V,Exec.GetProc(CurrentSyncInfo.MethodName));
- Online := nil;
+ thread:= TMThread(CurrentSyncInfo.OldThread);
+ mmlpsthread.CurrThread:= thread;
+ try
+ if thread is TPSThread then
+ begin
+ with TPSThread(thread).PSScript do
+ begin
+ OnLine:=@OnLinePSScript;
+ CurrentSyncInfo.Res:= Exec.RunProcPVar(CurrentSyncInfo.V,Exec.GetProc(CurrentSyncInfo.MethodName));
+ Online := nil;
+ end;
+ end else
+ begin
+ raise Exception.Create('ThreadSafeCall not implemented on this client');
+ end;
+ finally
+ mmlpsthread.CurrThread:= nil;
end;
- mmlpsthread.CurrThread := nil;
end;
function TForm1.OpenScript: boolean;
-begin;
+begin
Result := False;
if CanExitOrOpen = false then
Exit;
diff --git a/branches/script-component/Units/MMLAddon/PSInc/psexportedmethods.inc b/branches/script-component/Units/MMLAddon/PSInc/psexportedmethods.inc
index 72c8735..cf16b65 100644
--- a/branches/script-component/Units/MMLAddon/PSInc/psexportedmethods.inc
+++ b/branches/script-component/Units/MMLAddon/PSInc/psexportedmethods.inc
@@ -21,7 +21,7 @@
psexportedmethods.inc for the Mufasa Macro Library
}
-//AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;');
+AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;');
AddFunction(nil,'procedure Writeln(x);'); //We use special function for this
{ DTM }
@@ -97,7 +97,6 @@ AddFunction(@DisplayDebugImgWindow,'procedure DisplayDebugImgWindow(w, h: intege
AddFunction(@DrawBitmapDebugImg,'procedure DrawBitmapDebugImg(bmp: integer);');
AddFunction(@GetDebugBitmap,'function GetDebugBitmap: integer;');
AddFunction(@Random,'function Random(Int: integer): integer;');
-//AddFunction(@NewThreadCall,'function NewThreadCall(procname : string) : cardinal');
AddFunction(@ClearDebug,'procedure ClearDebug;');
diff --git a/branches/script-component/Units/MMLAddon/mmlpsthread.pas b/branches/script-component/Units/MMLAddon/mmlpsthread.pas
index d35b341..5c13345 100644
--- a/branches/script-component/Units/MMLAddon/mmlpsthread.pas
+++ b/branches/script-component/Units/MMLAddon/mmlpsthread.pas
@@ -44,7 +44,6 @@ type
Res : Variant;
SyncMethod : procedure of object;
OldThread : TThread;
- PSScript : TPSScript;
end;
TWritelnProc = procedure(s: string);
@@ -247,7 +246,7 @@ begin
ErrorData^.ErrType:= ErrorType;
ErrorData^.Module:= ErrorModule;
ErrorData^.IncludePath:= IncludePath;
- CurrThread.Synchronize(OnError); //what does this do???
+ CurrThread.Synchronize(OnError);
end;
procedure TMThread.OnThreadTerminate(Sender: TObject);
@@ -332,6 +331,15 @@ begin
FontPath:= FontP;
end;
+function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;
+begin
+ CurrThread.SyncInfo^.MethodName:= ProcName;
+ CurrThread.SyncInfo^.V:= V;
+ CurrThread.SyncInfo^.OldThread := CurrThread;
+ CurrThread.Synchronize(CurrThread.SyncInfo^.SyncMethod);
+ Result := CurrThread.SyncInfo^.Res;
+end;
+
{$I PSInc/Wrappers/other.inc}
{$I PSInc/Wrappers/bitmap.inc}
{$I PSInc/Wrappers/window.inc}
@@ -397,28 +405,6 @@ end;
well, it will really make the unit more straightforward to use and read.
}
-{function NewThreadCall(Procname : string) : Cardinal;
-begin;
- result := CurrThread.PSScript.Exec.GetVar(Procname);
-end;}
-
-{function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;
-begin;
- CurrThread.SyncInfo^.MethodName:= ProcName;
- CurrThread.SyncInfo^.V:= V;
- CurrThread.SyncInfo^.PSScript := CurrThread.PSScript;
- CurrThread.SyncInfo^.OldThread := CurrThread;
- CurrThread.Synchronize(CurrThread.SyncInfo^.SyncMethod);
- Result := CurrThread.SyncInfo^.Res;
-// Writeln('We have a length of: ' + inttostr(length(v)));
-// Try
-// Result := CurrThread.PSScript.Exec.RunProcPVar(v,CurrThread.PSScript.Exec.GetProc(Procname));
-// Except
-// Writeln('We has some errors :-(');
-// end;
-end;}
-
-
constructor TPSThread.Create(CreateSuspended : boolean; TheSyncInfo : PSyncInfo; plugin_dir: string);
begin
SyncInfo:= TheSyncInfo;