* fixed memory leaks in case a TP-style object inherits from another object

type that contains managed types, but this child doesn't contain any
    managed type itself (since r16632, the parent should be considered as a
    field of the child in terms of needing initialization/finalization)

git-svn-id: trunk@22461 -
This commit is contained in:
Jonas Maebe 2012-09-26 14:26:00 +00:00
parent 2cd78c03b3
commit e3b97d99c6
3 changed files with 60 additions and 1 deletions

1
.gitattributes vendored
View File

@ -11052,6 +11052,7 @@ tests/test/tobject5.pp svneol=native#text/pascal
tests/test/tobject6.pp svneol=native#text/plain
tests/test/tobject7.pp svneol=native#text/plain
tests/test/tobject8.pp svneol=native#text/plain
tests/test/tobject9.pp svneol=native#text/plain
tests/test/toperator1.pp svneol=native#text/plain
tests/test/toperator10.pp svneol=native#text/pascal
tests/test/toperator11.pp svneol=native#text/pascal

View File

@ -5927,7 +5927,10 @@ implementation
odt_interfacecorba:
needs_inittable:=is_related(interface_iunknown);
odt_object:
needs_inittable:=tObjectSymtable(symtable).needs_init_final;
needs_inittable:=
tObjectSymtable(symtable).needs_init_final or
(assigned(childof) and
childof.needs_inittable);
odt_cppclass,
odt_objcclass,
odt_objcprotocol,

55
tests/test/tobject9.pp Normal file
View File

@ -0,0 +1,55 @@
{ %OPT=-gh }
// Validate that objects with parent are finalized when statically allocated
type
pobj = ^tobj;
tobj = object
public
foo: ansistring;
constructor init(const s: ansistring);
destructor done;
end;
pobj1 = ^tobj1;
tobj1 = object(tobj)
constructor init;
destructor done;
end;
constructor tobj.init(const s: ansistring);
begin
foo:=s;
end;
destructor tobj.done;
begin
end;
constructor tobj1.init;
var
s: ansistring;
begin
s:='abc';
uniquestring(s);
inherited init(s);
end;
destructor tobj1.done;
begin
inherited done;
end;
var
obj: tobj1;
procedure local;
var
instance: tobj1;
begin
instance.init;
end;
begin
HaltOnNotReleased:=true;
local;
obj.init;
end.