Ignore:
Timestamp:
Sep 8, 2012, 9:28:39 PM (12 years ago)
Author:
chronos
Message:
  • Updated: Component versions.
  • Added: Missing forms.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        33backup
        44tunneler.exe
         5heaptrclog.trc
  • trunk/Components/TemplateGenerics

    • Property svn:ignore set to
      lib
  • trunk/Components/TemplateGenerics/Generic/GenericListObject.inc

    r29 r30  
    1313  // TGListObject<TListObjectIndex, TListObjectItem> = class(TGList)
    1414  TGListObject = class(TGList)
    15   private
     15  protected
    1616    procedure Put(Index: TGListIndex; const AValue: TGListItem); override;
     17    procedure SetCount(const AValue: TGListIndex); override;
    1718  public
    1819    OwnsObjects: Boolean;
     20    function AddNew(NewObject: TGListItem = nil): TGListItem;
     21    function InsertNew(Index: TGListIndex; NewObject: TGListItem = nil): TGListItem;
    1922    procedure Delete(Index: TGListObjectIndex); override;
    20     procedure Clear; override;
    2123    procedure Assign(Source: TGList); override;
    22     constructor Create;
     24    constructor Create; override;
    2325    destructor Destroy; override;
    2426  end;
     
    4951{ TGListObject }
    5052
     53function TGListObject.AddNew(NewObject: TGListItem = nil): TGListItem;
     54begin
     55  if Assigned(NewObject) then Result := NewObject
     56    else Result := TGListItem.Create;
     57  Add(Result);
     58end;
     59
     60function TGListObject.InsertNew(Index: TGListIndex;
     61  NewObject: TGListItem = nil): TGListItem;
     62begin
     63  if Assigned(NewObject) then Result := NewObject
     64    else Result := TGListItem.Create;
     65  Insert(Index, Result);
     66end;
     67
    5168procedure TGListObject.Assign(Source: TGList);
    5269begin
     
    5875procedure TGListObject.Put(Index: TGListIndex; const AValue: TGListItem);
    5976begin
    60   if OwnsObjects then FItems[Index].Free;
     77  if OwnsObjects and (FItems[Index] <> AValue) then FItems[Index].Free;
    6178  inherited Put(Index, AValue);
    6279end;
     
    6885end;
    6986
    70 procedure TGListObject.Clear;
     87procedure TGListObject.SetCount(const AValue: TGListIndex);
    7188var
    7289  I: TGListObjectIndex;
    7390begin
    7491  if OwnsObjects then begin
    75     I := 0;
    76     while I < Count do begin
     92    I := FCount - 1;
     93    while I >= AValue do begin
    7794      FItems[I].Free;
    78       I := I + 1;
     95      I := I - 1;
    7996    end;
    8097  end;
    81   inherited Clear;
     98  inherited;
    8299end;
    83100
Note: See TracChangeset for help on using the changeset viewer.