Ignore:
Timestamp:
Jun 2, 2013, 6:59:07 PM (11 years ago)
Author:
chronos
Message:
  • Fixed: Components now have list of childs and free them on destruction.
  • Fixed: Memory leaks.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • os/trunk/Xvcl/Xvcl.Classes.pas

    r5 r7  
    22
    33interface
     4
     5uses
     6  Xvcl.Generics;
    47
    58type
     
    5154    FOwner: TComponent;
    5255    FName: string;
     56    FComponents: TObjectList<TComponent>;
     57    procedure SetOwner(const Value: TComponent);
    5358  public
    5459    constructor Create; virtual;
    55     property Owner: TComponent read FOwner write FOwner;
     60    destructor Destroy; override;
     61    property Components: TObjectList<TComponent> read FComponents;
     62    property Owner: TComponent read FOwner write SetOwner;
    5663    property Name: string read FName write FName;
    5764  end;
     
    161168constructor TComponent.Create;
    162169begin
     170  FComponents := TObjectList<TComponent>.Create;
     171end;
     172
     173destructor TComponent.Destroy;
     174begin
     175  FComponents.Destroy;
     176  inherited;
     177end;
     178
     179procedure TComponent.SetOwner(const Value: TComponent);
     180begin
     181  if Value = FOwner then Exit;
     182  if not Assigned(Value) then FOwner.Components.Remove(Self);
     183  FOwner := Value;
     184  if Assigned(Value) then FOwner.Components.Add(Self);
    163185end;
    164186
     
    181203  Self.Y := Y;
    182204end;
    183 
    184205
    185206function TPoint.IsZero: Boolean;
Note: See TracChangeset for help on using the changeset viewer.