View Issue Details

IDProjectCategoryView StatusLast Update
0011503FPCCompilerpublic2008-10-16 01:03
ReporterBoian Mitov Assigned ToJonas Maebe  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionduplicate 
Summary0011503: Interfaces returned from functions are not properly released.
DescriptionIf interface is returned by function it is not released until the calling function goes out of scope:

--------CODE-------
type ITest = interface
end;

type TTest = class(TInterfacedObject, ITest)
public
  destructor Destroy(); override;
end;

destructor TTest.Destroy();
begin
  inherited;
end;

function TestFunc() : TTest;
begin
  Result := TTest.Create();
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  Atest : ITest;

begin
  Atest := TestFunc(); // Obtains interface
  Atest := NIL; // The interface should be released, but is not. The destructor is not called.
  //... Other Code
  //... Other Code
end; // The interface is released here.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

duplicate of 0009472 closedYuriy Sydorov "as" increase .RefCount in INTERFACE 
related to 0016578 closedJonas Maebe Implicit create interface references 

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2008-06-19 06:50 Boian Mitov New Issue
2008-06-19 09:39 Jonas Maebe Relationship added duplicate of 0009472
2008-06-19 09:39 Jonas Maebe Duplicate ID 0 => 9472
2008-06-19 09:39 Jonas Maebe Status new => resolved
2008-06-19 09:39 Jonas Maebe Resolution open => duplicate
2008-06-19 09:39 Jonas Maebe Assigned To => Jonas Maebe
2008-10-16 01:03 Ivo Steinmann Status resolved => closed
2010-05-27 11:41 Jonas Maebe Relationship added related to 0016578