Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
LCL / Re: Freeing at destructor TLazCanvasState.Destroy;
« Last post by wp on Today at 01:28:43 am »
Yes. And there is another related leak because the GraphicStateList, a TFPList, does not free its elements. Committed a fix to Laz/main.

A further leak probably is due to FAssignedFont which is auto-created at first access (GetAssignedFont), but never destroyed. However, I did not touch it ATM because I am not 100% sure about font handling in TLazCanvas which should gets the fonts via FreeType.
2
General / Re: centered text in progress bar with Marquee
« Last post by wp on Today at 01:08:54 am »
If you want to be able to switch between normal and marquee mode or modify other properties it is maybe worth the effort to write a new component; it is relatively straight-forward.

ATM, the component (TProgressBarEx) is not registered, thus you must create it at runtime, as shown in the attached project (FormCreate, the other code is just to demonstrate the effect of the properties).
3
LCL / Re: Freeing at destructor TLazCanvasState.Destroy;
« Last post by jamie on Today at 12:59:06 am »
Does it leak ?
4
Beginners / Re: Compilation error with CPU vector extensions
« Last post by jamie on Today at 12:49:36 am »
Did you try "Constref" ?
5
LCL / Re: Freeing at destructor TLazCanvasState.Destroy;
« Last post by Blaazen on Today at 12:01:49 am »
Quote
also, its possible maybe a shared font is being used so it could be a bad idea to free it there.

No. It creates a new instance of Font and copies all parameters:
Code: Pascal  [Select][+][-]
  1. function TLazCanvas.SaveState: Integer;
  2. var
  3.   lState: TLazCanvasState;
  4. begin
  5.   lState := TLazCanvasState.Create;
  6.  
  7.   lState.Brush := Brush.CopyBrush;
  8.   lState.Pen := Pen.CopyPen;
  9.   lState.Font := Font.CopyFont;
  10.   lState.BaseWindowOrg := BaseWindowOrg;
  11.   lState.WindowOrg := WindowOrg;
  12.   lState.Clipping := Clipping;
  13.  
  14.   Result := GraphicStateList.Add(lState);
  15. end;
  16.  
  17. function TFPCustomFont.CopyFont : TFPCustomFont;
  18. begin
  19.   result := TFPCustomFont(self.ClassType.Create);
  20.   result.DoCopyProps (self);
  21. end;

CustomDrawn are simply *alpha*.
6
Spanish / Re: Introducción al pascal moderno.
« Last post by GAN on March 28, 2023, 11:55:33 pm »
Esa guía es muy buena, tenerla en nuestro idioma sería un lujo. Muchas gracias.
Y me sumo a Nuño en la idea de una página con un ínidice.

Saludos.
7
LCL / Re: Freeing at destructor TLazCanvasState.Destroy;
« Last post by jamie on March 28, 2023, 11:48:16 pm »
Rather badly written.

You don't need to test for Nil if you are going to use Free because Free does that already.

also, its possible maybe a shared font is being used so it could be a bad idea to free it there.
8
LCL / Re: Freeing at destructor TLazCanvasState.Destroy;
« Last post by dsiders on March 28, 2023, 11:45:31 pm »
Probably should. A basic test gives memory leak.
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2. {$mode objfpc}{$H+}
  3.  
  4. interface
  5.  
  6. uses
  7.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, LazCanvas, FPImage;
  8.  
  9. type
  10.   { TForm1 }
  11.   TForm1 = class(TForm)
  12.     procedure FormCreate(Sender: TObject);
  13.   private
  14.  
  15.   public
  16.  
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.lfm}
  25.  
  26. { TForm1 }
  27.  
  28. procedure TForm1.FormCreate(Sender: TObject);
  29. var lc: TLazCanvas;
  30.     fpi: TFPCustomImage;
  31. begin
  32.   fpi:=TFPCustomImage.Create(100, 100);
  33.   lc:=TLazCanvas.create(fpi);
  34.   lc.SaveState;
  35.   lc.RestoreState(0);
  36.   lc.Free;
  37.   fpi.Free;
  38. end;
  39.  
  40. end.
I don't know what is the purpose of LazCanvas, I never used it.

It is used as the DC in custom drawn widgetsets.
9
LCL / Re: Freeing at destructor TLazCanvasState.Destroy;
« Last post by Blaazen on March 28, 2023, 11:34:05 pm »
Probably should. A basic test gives memory leak.
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2. {$mode objfpc}{$H+}
  3.  
  4. interface
  5.  
  6. uses
  7.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, LazCanvas, FPImage;
  8.  
  9. type
  10.   { TForm1 }
  11.   TForm1 = class(TForm)
  12.     procedure FormCreate(Sender: TObject);
  13.   private
  14.  
  15.   public
  16.  
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.lfm}
  25.  
  26. { TForm1 }
  27.  
  28. procedure TForm1.FormCreate(Sender: TObject);
  29. var lc: TLazCanvas;
  30.     fpi: TFPCustomImage;
  31. begin
  32.   fpi:=TFPCustomImage.Create(100, 100);
  33.   lc:=TLazCanvas.create(fpi);
  34.   lc.SaveState;
  35.   lc.RestoreState(0);
  36.   lc.Free;
  37.   fpi.Free;
  38. end;
  39.  
  40. end.
I don't know what is the purpose of LazCanvas, I never used it.
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018