After FPC revision 31328 a interfaced class wouldn't be destroyed
Original Reporter info from Mantis: Michl @michl1
-
Reporter name: Michl
Original Reporter info from Mantis: Michl @michl1
- Reporter name: Michl
Description:
This is new report as the result of creating a minimal example for the bugreport #28628 (closed).
The last revision, where the reference counting work correct is 31327. Since revision 31328, the reference counting fails in that special case (used for example in TAChart).
Steps to reproduce:
Try the added example or something like (with enabled Heaptrc):
type
ITestInterface = interface ['{8B84A703-5A2A-4DAC-AA4A-154E03C248CB}']
end;
TInterfacedClass = class(TInterfacedObject, ITestInterface)
strict protected
FBuffer: ^Integer;
public
constructor Create;
destructor Destroy; override;
end;
constructor TInterfacedClass.Create;
begin
inherited Create;
FBuffer := GetMem(SizeOf(Integer));
end;
destructor TInterfacedClass.Destroy;
begin
FreeMem(FBuffer);
inherited;
end;
...
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
FTestInterface: ITestInterface;
procedure DoSomething;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FTestInterface := TInterfacedClass.Create;
DoSomething;
end;
procedure TForm1.DoSomething;
var
ic: ITestInterface;
begin
Supports(FTestInterface, ITestInterface, ic);
Supports(FTestInterface, ITestInterface, ic);
end;
Mantis conversion info:
- Mantis ID: 28632
- OS: 7
- OS Build: 64 and 32bit
- Build: 31549
- Platform: Windows
- Version: 3.1.1
- Fixed in version: 3.1.1
- Fixed in revision: 31624 (#6ffd8f02)
- Monitored by: » luizamerico (Luiz Americo), » Vincent (Vincent Snijders)