DSharp.Core.Events.Pas AV

Issue #38 wontfix
Former user created an issue

A bug in DSharp.Core.Events.Pas causes AV when a Method remove Self in TEvent, here is the new code:

procedure TEvent.InternalInvoke(Params: PParameters; StackSize: Integer);
var
  i: Integer;
begin
  if FEnabled then
  begin
    i:=0;
    while i<FMethods.Count do
    begin
      InvokeMethod(FMethods[i], Params, StackSize);
      Inc(i);
    end;
  end;
end;

Comments (2)

  1. Stefan Glienke repo owner

    DSharp.Core.Events is deprecated quite some time now since DSharp is basing on Spring4D (see develop branch).

    The events there don't have this problem since they cache the event handlers before running them.

  2. Former user Account Deleted
    procedure TEvent.InternalInvoke(Params: PParameters; StackSize: Integer);
    var
      i: Integer;
      M:TMethod;
    begin
      if FEnabled then
      begin
        i:=0;
        while i<FMethods.Count do
        begin
          M:=FMethods[i];
          InvokeMethod(FMethods[i], Params, StackSize);
          if (i<FMethods.Count) and (M=FMethods[i]) then Inc(i);
        end;
      end;
    end;
    
  3. Log in to comment