Changeset 15 for trunk/UGraphic.pas


Ignore:
Timestamp:
Sep 22, 2014, 11:06:27 PM (10 years ago)
Author:
chronos
Message:
  • Added: Memory leaks reporting in debug mode.
  • Fixed: Various memory leaks in bitmap, color and colorformat classes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGraphic.pas

    r14 r15  
    5151    procedure Assign(Source: TGColor); virtual;
    5252    constructor Create;
     53    destructor Destroy; override;
    5354    property Channels[Channel: TGColorChannel]: TGColor read GetChannel;
    5455    property Data: TBitMemory read FData;
     
    339340  if FColorFormat = AValue then Exit;
    340341  FColorFormat := AValue;
    341   FData.Size := FColorFormat.BitDepth;
     342  if Assigned(FColorFormat) then
     343    FData.Size := FColorFormat.BitDepth
     344    else FData.Size := 0;
    342345end;
    343346
     
    406409begin
    407410  FData := TBitMemory.Create;
    408   Format := TGColorFormat.Create;
     411  Format := nil;
     412end;
     413
     414destructor TGColor.Destroy;
     415begin
     416  FData.Free;
     417  inherited Destroy;
    409418end;
    410419
     
    566575  X, Y: Integer;
    567576  Color: TGColor;
     577  Color2: TGColor;
    568578begin
    569579  for Y := 0 to Size.Y div 2 - 1 do
    570580    for X := 0 to Size.X - 1 do begin
    571581      Color := Pixels[X, Y];
    572       Pixels[X, Y] := Pixels[X, Size.Y - 1 - Y];
     582      Color2 := Pixels[X, Size.Y - 1 - Y];
     583      Pixels[X, Y] := Color2;
     584      Color2.Free;
    573585      Pixels[X, Size.Y - 1 - Y] := Color;
    574586      Color.Free;
     
    580592  X, Y: Integer;
    581593  Color: TGColor;
     594  Color2: TGColor;
    582595begin
    583596  for Y := 0 to Size.Y - 1 do
    584597    for X := 0 to Size.X div 2 - 1 do begin
    585598      Color := Pixels[X, Y];
    586       Pixels[X, Y] := Pixels[Size.X - 1 - X, Y];
     599      Color2 := Pixels[Size.X - 1 - X, Y];
     600      Pixels[X, Y] := Color2;
     601      Color2.Free;
    587602      Pixels[Size.X - 1 - X, Y] := Color;
    588603      Color.Free;
     
    608623  FData := TBitMemory.Create;
    609624  FBackgroundColor := TGColor.Create;
    610   ColorFormat := TGColorFormat.Create;
    611   FBackgroundColor.Format := ColorFormat;
    612   FBackgroundColor.FromTColor(clBlack);
     625  ColorFormat := nil;
    613626  Canvas := TGCanvas.Create;
    614627  Canvas.Bitmap := Self;
     
    617630destructor TGBitmap.Destroy;
    618631begin
     632  FBackgroundColor.Free;
     633  Canvas.Free;
    619634  Size := Point(0, 0);
    620635  FData.Free;
Note: See TracChangeset for help on using the changeset viewer.