I've created an MCVE that simulates a problem that eventually happens in our software, where software freezes when it tries to register an event when a previously registered event triggers within the same cycle.
In an internal test, we found that this also occurs using the TIB_Events component.
Would this be a Firebird or FireDAC bug?
unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.Classes,
System.SysUtils,
Vcl.Controls,
Vcl.Forms,
Vcl.StdCtrls,
FireDAC.Comp.Client,
FireDAC.Comp.UI,
FireDAC.Phys,
FireDAC.Phys.FB,
FireDAC.Phys.FBDef,
FireDAC.Phys.IBBase,
FireDAC.Stan.Async,
FireDAC.Stan.Def,
FireDAC.Stan.Intf,
FireDAC.UI.Intf,
FireDAC.VCLUI.Wait;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
FConn : TFDConnection;
FEvents: TFDEventAlerter;
procedure EventAlert(ASender: TFDCustomEventAlerter; const AEventName: String; const AArgument: Variant);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
FConn.ExecSQL('EXECUTE BLOCK AS BEGIN POST_EVENT ''EVENT_1''; END');
FEvents.Names.Add('EVENT_2');
end;
procedure TForm1.EventAlert(ASender: TFDCustomEventAlerter; const AEventName: String; const AArgument: Variant);
begin
Caption := AEventName + ' ' + DateTimeToStr(Now);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FConn := TFDConnection.Create(nil);
FConn.LoginPrompt := False;
FConn.DriverName := 'FB';
FConn.Params.Values['DriverID'] := 'FB';
FConn.Params.Values['CharacterSet'] := 'ISO8859_1';
FConn.Params.Values['Server'] := '127.0.0.1';
FConn.Params.Values['Database'] := 'c:\temp\whatever.fdb';
FConn.Params.Values['User_Name'] := 'SYSDBA';
FConn.Params.Values['Password'] := 'masterkey';
FEvents := TFDEventAlerter.Create(nil);
FEvents.Connection := FConn;
FEvents.Names.Add('EVENT_1');
FEvents.OnAlert := EventAlert;
FEvents.Register;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FEvents.Free;
FConn.Free;
end;
end.