LL037
Missing FreeNotification
Object Pascal — Delphi & Free Pascal
Warning
Delphi
Storing a component reference without FreeNotification risks dangling pointers when the referenced component is destroyed
storing a component reference without FreeNotification risks dangling pointers when the referenced component is destroyed.
Why this severity
storing a component reference without FreeNotification risks dangling pointers when the referenced component is destroyed.
Known false positives
references managed by owner-based lifetime or set to nil in Notification overrides.
Remediation example
procedure TMyComp.SetTarget(Value: TComponent);
begin
if FTarget <> nil then
FTarget.RemoveFreeNotification(Self);
FTarget := Value;
if FTarget <> nil then
FTarget.FreeNotification(Self);
end;