Skip to content

Commit

Permalink
Merge pull request #376 from riwu/TerminateProc
Browse files Browse the repository at this point in the history
Account for if routines in OnTerminateProcs calls Add/DeleteOnTerminate
  • Loading branch information
MerlijnWajer committed Feb 11, 2016
2 parents f30c930 + 559dc70 commit 400e048
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Binary file removed Projects/Simba/Simba.res
Binary file not shown.
21 changes: 16 additions & 5 deletions Units/MMLAddon/mmlpsthread.pas
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,25 @@ procedure TMThread.SetFonts(Fonts: TMFonts);

procedure TMThread.HandleScriptTerminates;
var
I: integer;
V: array of Variant;
index: integer;
proc: String;
begin
if (not (SP_OnTerminate in Prop.Properties)) then
exit;

SetLength(V, 0);
if (SP_OnTerminate in Prop.Properties) then
for I := 0 to Prop.OnTerminateProcs.Count - 1 do
if (not Prop.OnTerminateProcsSkip[i]) or (not TerminatedByUser) then
CallMethod(Prop.OnTerminateProcs[I], V);
index := 0;
while (Prop.OnTerminateProcs.Count > 0) do
begin
proc := Prop.OnTerminateProcs[0];
Prop.OnTerminateProcs.Delete(0); //call first incase proc invoke DeleteOnTerminate on itself

if (not Prop.OnTerminateProcsSkip[index]) or (not TerminatedByUser) then
CallMethod(proc, V);

Inc(index);
end;
end;

{$IFDEF USE_PASCALSCRIPT}
Expand Down

0 comments on commit 400e048

Please sign in to comment.