[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Forms' (#lcl)

TApplication.ReleaseComponent

Safely destroys a component used in the application.

Declaration

Source position: forms.pp line 1611

public procedure TApplication.ReleaseComponent(

  AComponent: TComponent

);

Arguments

AComponent

  

The component to destroy.

Description

ReleaseComponent is a method used to ensure that the component in AComponent is freed in the application.

No actions are performed in the method if Destroy has already been called for AComponent (ComponentState contains csDestroying).

If the Application Flags contains AppDestroying, the Free method for AComponent is called immediately.

During normal processing, ReleaseComponent adds the component instance to a list of components pending release when it is not already present. Its FreeNotification method is called to perform notifications for owners. If it is the first item in the pending release list, the OnDecLCLRefcountToZero handler in lclclasses.pp is set to the DoDecLCLRefcountToZero method for the application. This ensures that an asynchronously call to FreeComponent is performed when the reference count reaches 0 and the application enters an idle state.

ReleaseComponent is called from the ReleaseComponents method in TApplication, and from the Release method in TCustomForm. It may also be used in the implementation of controls to ensure that its resources are freed as needed.


Version 3.2 Generated 2024-02-25 Home