Changeset 441


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
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Additional/UBinarySerializer.pas

    r410 r441  
    2525    Position: Integer;
    2626    OwnsList: Boolean;
    27     procedure Write(var Buffer; Count: Integer); inline;
    28     procedure Read(var Buffer; Count: Integer); inline;
     27    procedure Write(var Buffer; Count: Integer); //inline;
     28    procedure Read(var Buffer; Count: Integer); //inline;
    2929
    3030    procedure Assign(Source: TBinarySerializer);
     
    7373  StringLength: Longint;
    7474begin
    75   FList.ReadBuffer(StringLength, SizeOf(StringLength));
     75  StringLength := 0;
     76  Read(StringLength, SizeOf(StringLength));
    7677  Result := ReadString(StringLength);
    7778end;
     
    102103function TBinarySerializer.ReadByte: Byte;
    103104begin
     105  Result := 0;
    104106  Read(Result, SizeOf(Byte));
    105107end;
     
    107109function TBinarySerializer.ReadCardinal: Cardinal;
    108110begin
     111  Result := 0;
    109112  Read(Result, SizeOf(Cardinal));
    110113  if SwapData then Result := SwapEndian(Result);
     
    113116function TBinarySerializer.ReadInt64: Int64;
    114117begin
     118  Result := 0;
    115119  Read(Result, SizeOf(Int64));
    116120  if SwapData then Result := SwapEndian(Result);
     
    129133  Count: Byte;
    130134begin
     135  Count := 0;
    131136  Read(Count, 1);
    132137  Result := ReadString(Count);
     
    223228function TBinarySerializer.ReadDouble: Double;
    224229begin
     230  Result := 0;
    225231  Read(Result, SizeOf(Double));
    226232end;
     
    228234function TBinarySerializer.ReadSingle: Single;
    229235begin
     236  Result := 0;
    230237  Read(Result, SizeOf(Single));
    231238end;
     
    233240function TBinarySerializer.ReadWord: Word;
    234241begin
     242  Result := 0;
    235243  Read(Result, SizeOf(Word));
    236244  if SwapData then Result := SwapEndian(Result);
  • 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
  • Generics/TemplateGenerics/Specialized/SpecializedList.pas

    r426 r441  
    6767  procedure AddStream(Stream: TStream);
    6868  procedure AddStreamPart(Stream: TStream; ItemCount: TGListIndex);
    69   procedure WriteBuffer(var Buffer; Count: Integer);
    70   procedure ReadBuffer(var Buffer; Count: Integer);
    7169end;
    7270
     
    333331  I: TGListIndex;
    334332begin
    335   I := 0;
    336   while (I < Count) do begin
     333  I := Count - 1;
     334  while (I >= 0) do begin
    337335    TNotifyEvent(Items[I])(Sender);
    338     I := I + 1;
     336    I := I - 1;
    339337  end;
    340338end;
     
    414412end;
    415413
    416 procedure TListByte.WriteBuffer(var Buffer; Count: Integer);
    417 begin
    418 
    419 end;
    420 
    421 procedure TListByte.ReadBuffer(var Buffer; Count: Integer);
    422 begin
    423 
    424 end;
    425 
    426414
    427415end.
Note: See TracChangeset for help on using the changeset viewer.