mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 07:59:27 +02:00
* 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:
parent
2cd78c03b3
commit
e3b97d99c6
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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
55
tests/test/tobject9.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user