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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.