Ignore:
Timestamp:
Nov 19, 2012, 2:47:07 PM (12 years ago)
Author:
chronos
Message:
  • Fixed: Wrong memory inicialization in TListObject results in error during other object assignment.
Location:
Generics/TemplateGenerics/Generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Generic/GenericFileList.inc

    r426 r441  
    1515    procedure SetFileName(const Value: string);
    1616    procedure SetMode(const Value: Word);
     17    function GetOpenned: Boolean;
    1718  public
    1819    constructor Create; override;
     
    2223    property FileName: string read FFileName write SetFileName;
    2324    property Mode: Word read FMode write SetMode;
     25    property Openned: Boolean read GetOpenned;
    2426  end;
    2527
     
    8183end;
    8284
     85function TGFileList.GetOpenned: Boolean;
     86begin
     87  Result := FHandle <> feInvalidHandle;
     88end;
    8389
    8490{$UNDEF IMPLEMENTATION}
  • Generics/TemplateGenerics/Generic/GenericList.inc

    r427 r441  
    3939    procedure SetFirst(AValue: TGListItem);
    4040    procedure QuickSort(L, R : TGListIndex; Compare: TSortCompare);
     41    procedure DoUpdate;
    4142  protected
    4243    procedure Put(Index: TGListIndex; const AValue: TGListItem); virtual;
     
    109110begin
    110111  FCount := 0;
     112  FUpdateCount := 0;
    111113end;
    112114
     
    341343  if (Index < 0) or (Index > FCount) then
    342344    raise EListError.CreateFmt(SListIndexError, [Index]);
    343   InsertCount(Index, 1);
    344   FItems[Index] := Item;
    345   Update;
     345  try
     346    BeginUpdate;
     347    InsertCount(Index, 1);
     348    FItems[Index] := Item;
     349  finally
     350    EndUpdate;
     351  end;
    346352end;
    347353
     
    564570procedure TGList.EndUpdate;
    565571begin
    566   Dec(FUpdateCount);
    567   Update;
     572  if FUpdateCount > 0 then Dec(FUpdateCount);
     573  if FUpdateCount = 0 then DoUpdate;
     574end;
     575
     576procedure TGList.DoUpdate;
     577begin
     578  if Assigned(FOnUpdate) then FOnUpdate(Self);
    568579end;
    569580
    570581procedure TGList.Update;
    571582begin
    572   if Assigned(FOnUpdate) and (FUpdateCount = 0) then FOnUpdate(Self);
     583  if FUpdateCount = 0 then DoUpdate;
    573584end;
    574585
  • Generics/TemplateGenerics/Generic/GenericListObject.inc

    r426 r441  
    8888    end;
    8989  end;
     90  I := FCount;
    9091  inherited;
     92  // Nil newly allocated items
     93  while I < AValue do begin
     94    FItems[I] := nil;
     95    I := I + 1;
     96  end;
    9197end;
    9298
Note: See TracChangeset for help on using the changeset viewer.