SIGSEGV exception when freeing
Posted: Wed 17 Apr 2013 07:20
Hi there
I am having an issue in a destructor to free some components. Below a test prg. I am using Lazarus 1.0.6 on Linux and PgDac 3.6.12
P.S: With 'DisconnectMode := False' it seems to work fine!
Thx & cheers,
Peter
I am having an issue in a destructor to free some components. Below a test prg. I am using Lazarus 1.0.6 on Linux and PgDac 3.6.12
P.S: With 'DisconnectMode := False' it seems to work fine!
Code: Select all
program project1;
{$mode objfpc}{$H+}
uses
BaseUnix,
cthreads,
cMem,
Classes,
SysUtils,
Interfaces,
Forms,
Unit1,
Unit2;
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Code: Select all
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Unit2;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
lDemoClass: TDemoClass;
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
lDemoClass := TDemoClass.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
lDemoClass.Free;
end;
end.
Code: Select all
unit Unit2;
{$mode objfpc}{$H+}
interface
uses
Classes,
SysUtils,
Dialogs,
//Devart
DB,
DBAccess,
PgAccess,
PgAlerter,
MemData;
type
TDemoClass = class(TObject)
private
lPgAlerter: TPgAlerter;
lPgConnection: TPgConnection;
procedure AlerterEvent(Sender: TObject; const EventName: AnsiString; PID: LongInt; const EventMessage: AnsiString);
public
constructor Create; virtual;
destructor Destroy; override;
end;
implementation
procedure TDemoClass.AlerterEvent(Sender: TObject; const EventName: AnsiString; PID: LongInt; const EventMessage: AnsiString);
begin
end;
constructor TDemoClass.Create;
begin
inherited;
lPgConnection := TPgConnection.Create(nil);
with lPgConnection do begin
Options.DisconnectedMode := True;
Server := '.....';
Port := 5432;
Database := '.....';
Schema := '.....';
Username := '.....';
Password := '.....';
end;
lPgAlerter := TPgAlerter.Create(nil);
with lPgAlerter do begin
OnEvent := @AlerterEvent;
AutoRegister := False;
Connection := lPgConnection;
Events := 'Test123';
Start;
end;
ShowMessage('OK-All Created');
end;
destructor TDemoClass.Destroy;
begin
ShowMessage('Start Freeing');
lPgAlerter.Stop;
lPgConnection.Close;
ShowMessage('OK-Disconnected');
lPgAlerter.Free;
lPgConnection.Free;
ShowMessage('OK-Destroyed');
inherited;
end;
end.
Peter