System.TypInfo.FreeAndNilProperties
Delphi
procedure FreeAndNilProperties(AObject: TObject);
C++
extern DELPHI_PACKAGE void __fastcall FreeAndNilProperties(System::TObject* AObject);
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
public | System.TypInfo.pas System.TypInfo.hpp |
System.TypInfo | System.TypInfo |
Description
Frees any property values that are objects and sets their value to nil (Delphi) or NULL (C++).
Call FreeAndNilProperties from a destructor to free all internally created objects and set the corresponding property values to nil (Delphi) or NULL (C++). FreeAndNilProperties searches the properties of AObject, identifying any that are objects. It frees those objects, and sets the corresponding property to nil (Delphi) or NULL (C++).
. By default, all persistent objects (TPersistent and descendants) are compiled with RTTI. Other TObject descendants can be compiled with RTTI by using the $M+ compiler switch in Delphi or the __declspec(delphirtti) directive in C++.
Warning: Calling FreeAndNilProperties frees all object properties, which may lead to unintended results. FreeAndNilProperties can't distinguish between objects that were created by AObject (and typically stored in a class member) from objects that are created independently and which should not be freed with AObject. To avoid unintentionally freeing independently-created objects, set properties that refer to external objects to nil (Delphi) or NULL (C++) before calling FreeAndNilProperties.