Subjects of improvement implemented in the official development branches Free Pascal 1 SUBJECT [FPC] CheckSynchronize always returns false DETAILS rtl/objpas/classes/classes.inc has function CheckSynchronize(timeout : longint=0) : boolean; The function always returns false. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » [SOLVED] CheckSynchronize always returns false Commit e774a627: change Result of CheckSynchronize to true when at least one method was... 2 SUBJECT [FPC] Wrong check at TFPCustomCanvas.Draw DETAILS packages/fcl-image/src/fpcanvas.inc has procedure TFPCustomCanvas.Draw (x,y:integer; image:TFPCustomImage); The procedure wrongfully checks variable y with width at line: if (ym<0) or (y>width) then exit;. WEB LINKS Lazarus » Forum » Free Pascal » General (Moderators: FPK, Tomas Hajny) » [SOLVED] Three questions regarding fcl-image package Commit 1fad2878: patch by Werner Pamler: Typo in TFPCustomCanvas.Draw, resolves #40176 3 SUBJECT [FPC] Poor CPU cache usage at function TFPCustomCanvas.Erase DETAILS packages/fcl-image/src/fpcanvas.inc has function TFPCustomCanvas.Erase. The original code doesn't write data in a lean way. "for x:=0 to Width-1 do for y:=0 to Height-1 do" has been changed with "for y:=0 to Height-1 do for x:=0 to Width-1 do" WEBLINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED]Improvement of packages/fcl-image/src/fpcanvas.inc TFPCustomCanvas.Erase Commit 5e47b4a7: * switch loops in TFPCustomCanvas.Erase closes #40246 4 SUBJECT [FPC] Code cleanup at function CompareStr DETAILS rtl/objpas/sysutils/sysstr.inc has function CompareStr(const S1, S2: string): Integer; The useless declaration of variable "res" has been removed. Also, the initial useless assignment "result:=0;" has been removed, too. A patch has been presented. WEBLINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of rtl/objpas/sysutils/sysstr.inc function CompareStr Commit 8e7572fa: * small cleanup, remove redundant result assignment and unused variable (from... 5 SUBJECT [FPC] Improve CPU cache usage at packages/fcl-image/src/pixtools.pp DETAILS packages/fcl-image/src/pixtools.pp has: procedure FillRectangleColor (Canv:TFPCustomCanvas; x1,y1, x2,y2:integer; const color:TFPColor); procedure FillRectangleImage (Canv:TFPCustomCanvas; x1,y1, x2,y2:integer; const Image:TFPCustomImage); procedure FillRectangleImageRel (Canv:TFPCustomCanvas; x1,y1, x2,y2:integer; const Image:TFPCustomImage); A patch has been presented that improves CPU cache usage by switching the x and y loops so that data transfers are leaner. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improved CPU cache usage at packages/fcl-image/src/pixtools.pp Commit 322e8ca7: * fix #40242 by inverting some more x and y loops 6 SUBJECT [FPC] Code clean up at utils/h2pas/scan.pas procedure writetree DETAILS utils/h2pas/scan.pas has procedure writetree(p: presobject); This procedure has a useless variable declaration: "i : integer;". A patch has been presented that removes it. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Code clean up at utils/h2pas/scan.pas procedure writetree Commit fba56424: * remove unused variable, reported by... 7 SUBJECT [FPC] Improved CPU cache usage at procedure TFPCustomImage.Assign DETAILS packages/fcl-image/src/fpimage.inc has Procedure TFPCustomImage.Assign(Source: TPersistent); A patch has been presented that improves CPU cache usage by switching the x and y loops so that data transfers are leaner. In addition, some cosmetics: two empty lines have been removed, "Var" has been changed to "var" and "[X,Y]" has been changed to "[x,y]". WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improved CPU cache usage at procedure TFPCustomImage.Assign Commit 4d0b3970: * more loopvar sorting by... 8 SUBJECT [FPC] High instead of length in rtl/objpas/typinfo.pp DETAILS rtl/objpas/typinfo.pp has three routines where values like Length(array)-1 are assigned to variables. A patch has been presented that modifies the file to use High instead of Length. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Using high instead of length in rtl/objpas/typinfo.pp Commit 5a0ace6d: * replace Length() - 1 with High() which leads to slightly... 9 SUBJECT [FPC] Code clean up at TFontManager.SetExtention DETAILS packages/fcl-image/src/freetype.pp has procedure TFontManager.SetExtention (AValue : string); A patch has been presented that removes the else part of "if AValue <> ''" because that code is useless. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Code clean up at TFontManager.SetExtention Commit 9cc08940: * Small fix by Alexey Torgashin. Fixes issue #40335 10 SUBJECT [FPC] Improvement of TBinaryObjectWriter.WriteIdent DETAILS rtl/objpas/classes/writer.inc has procedure TBinaryObjectWriter.WriteIdent(const Ident: string); The original code may compute multiple times UpperCase(Ident), even though Ident remains unchanged. A patch has been presented that replaces the series of ifs with a "Case UpperCase(Ident) of". WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of TBinaryObjectWriter.WriteIdent Commit c7109674: * Small optimization of WriteIdent. fixes issue #40334 11 SUBJECT [FPC] Clean up at function TProcess.WaitOnExit DETAILS packages/fcl-process/src/unix/process.inc has Function TProcess.WaitOnExit : Boolean; Variable R is declared but never used. A patch has been presented that removes it. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Clean up at Function TProcess.WaitOnExit : Boolean; Commit 2628a6ee: * remove redundant variable reported by... 12 SUBJECT [FPC] Improvement of procedure SysGetEnvironmentList DETAILS packages/fcl-base/src/custapp.pp has procedure SysGetEnvironmentList(List : TStrings;NamesOnly : Boolean); The original code declares a variable and it assigns a value to that variable without using it afterwars. In addition, before a for loop, it has a useless check with zero. Also a comparison differs in the mentioned procedure, making it look different than other procedures with the same name and intended usage that could be found in other unit files. A patch has been presented that improves the procedure. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of procedure SysGetEnvironmentList Commit 31edc462: * Improvement of SysGetEnvironmentList by... 13 SUBJECT [FPC] Improvement of function TSocketServer.RunIdleLoop DETAILS packages/fcl-net/src/ssockets.pp has function TSocketServer.RunIdleLoop: Boolean; The repeat loop contains an unnecessary conditional jump. A patch has been presented that improves the procedure: "If not Result then DoOnIdle; Until Result or (Not FAccepting);" is replaced by "If Result then break; DoOnIdle; Until (Not FAccepting);" WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of function TSocketServer.RunIdleLoop Commit 656254a9: * Patch to fix issue #40351 14 SUBJECT [FPC] Clean up at procedure TCustomDaemonApplication.RemoveController DETAILS packages/fcl-extra/src/unix/daemonapp.inc has procedure TCustomDaemonApplication.RemoveController(AController: TDaemonController); The declared variables of the procedure are never used. A patch has been presented that removes them. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Clean up at procedure TCustomDaemonApplication.RemoveController Commit e00ed69d: * Remove unused variables. Fixes issue #40355 15 SUBJECT [FPC] Improvement of function TProcess.Terminate DETAILS packages/fcl-process/src/unix/process.inc has Function TProcess.Terminate(AExitCode : Integer) : Boolean; The original code has a useless "Result:=False;" initial line. In addition to that, "if Result then WaitOnExit;" is executed even if Result is known to be true and not Running. A patch has been presented and the function has been modified with simplicity as the main argument. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of function TProcess.Terminate Commit 1083111b: * Simpler form of Terminate 16 SUBJECT [FPC] Optimization of function ParseURI DETAILS packages/fcl-base/src/uriparser.pp has function ParseURI(const URI, DefaultProtocol: String; DefaultPort: Word;Decode : Boolean = True): TURI; A patch has been presented that replaces a series of Copy and Delete routines with the SetLength procedure. In addition to that, "if Length(Authority) > 0 then" has been replaced with "if Authority <> '' then" and for cosmetics, some space characters have been inserted. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Optimization of function ParseURI Commit 8539a8b7: * Patch with some micro-optimizations. Fixes issue #40378 17 SUBJECT [FPC] StringToHex might not return a result DETAILS packages/fcl-hash/src/fphashutils.pp has function StringToHex(const s: ansistring): ansistring; When s='' the function doesn't return a result. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] StringToHex might not return a result Commit 896ca4bb: * Initialize result in StingToHex. Fixes issue #40388 18 SUBJECT [FPC] Improvement of rtl/linux/system.pp procedure InitTLS; DETAILS rtl/linux/system.pp has procedure InitTLS; Because the biggest value of variable "i" is smaller than the biggest value of variable "phnum", it's not guaranteed that all loop iterations are run. A patch has been presented that removes variable "i" by replacing "for i:=1 to phnum do" with a "while phnum>0 do" loop. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of rtl/linux/system.pp procedure InitTLS; Commit c09e8778: * Small improvement in inittls. Fixes issue 40408 19 SUBJECT [FPC] Simplified GetEnumNameCount DETAILS rtl/objpas/typinfo.pp has function GetEnumNameCount(enum1: PTypeInfo): SizeInt; The function has been simplified. A patch has been presented that removes variables Count and PT and improves the result assignment. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Simplified GetEnumNameCount Commit 6a07a508: * Simplify GetEnumNameCount... Commit a748d727: * Re-add comment 20 SUBJECT [FPC] Simplified ExcludeLeadingPathDelimiter DETAILS rtl/objpas/sysutils/fina.inc has function ExcludeLeadingPathDelimiter(Const Path: PathStr): PathStr; The function has been simplified. A patch has been presented that replaces "If (L>0)" with "If (Result<>'')" and removes the variable "L". WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Simplified ExcludeLeadingPathDelimiter Commit 148bde3f: * Small improvement 21 SUBJECT [FPC] Improvement of procedure TSHA512Base.Update DETAILS packages/fcl-hash/src/fpsha512.pp has procedure TSHA512Base.Update(PBuf: PByte; Size: UInt32); In order to exit a loop the original code sets a zero value to variable "Size". A patch has been presented that changes the line "Size := 0;" with "Break;", increasing code readability. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of procedure TSHA512Base.Update Commit f8ba9e47: * use break instead of classically breaking out of the loop 22 SUBJECT [FPC] Improvement of function EncodeURI DETAILS packages/fcl-base/src/uriparser.pp has function EncodeURI(const URI: TURI): String; The function start with "SetLength(Result, 0);" and contains many comparisons of String lengths with zero. A patch has been presented that replaces the initial "SetLength(Result, 0);" line with "Result := '';". All comparisons of Length(string) with zero have been replaced by comparisons of string with ''. The only comparison of a length of a string with zero in the entire file remained inside function ParseURI, so that line has been modified from "if Length(Authority)>0 then" to "if Authority <> '' then". WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of function EncodeURI Commit 123481aa: * Minor improvements of EncodeUri. Fixes issue #40455 23 SUBJECT [FPC] Improvement of DoCopyProps routines in fcl-image package DETAILS All DoCopyProps routines in the the fcl-image package have bugs. Two solutions have been presented and one of them has been applied to the official sources. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of DoCopyProps routines in fcl-image package Commit 9ef5b8bc: * Fixes in DoCopyProps. Fixes issue #40362 24 SUBJECT [FPC] Poor optimization of constant folding DETAILS Multiplication with negative variable produces inefficient code. WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Poor optimization of constant folding Commit 6e5860cb: * check for *-1 multiplications after folding, resolves #40448 25 SUBJECT [FPC] Improvement of function SetCompileModeSwitch DETAILS compiler/scanner.pas has function SetCompileModeSwitch(s:string; changeInit: boolean):boolean; Within the code of the function "s:=copy(s,1,length(s)-1);" can be encountered twice. A patch has been presented that replaces the mentioned code with "setlength(s,length(s)-1);". WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of function SetCompileModeSwitch Commit e5de38c4: * patch by lagprogramming: Improvement of function SetCompileModeSwitch, resolves #40525 26 SUBJECT [FPC] Simplified TPasRecordType.IsAdvancedRecord DETAILS packages/fcl-passrc/src/pastree.pp has function TPasRecordType.IsAdvancedRecord: Boolean; The while loop contains a useless "(Not Result)" condition. The result is false at the loop entry and it's changed only using "exit(true);" statements. A patch has been presented that changes "While (Not Result) and (I0) is always true because before deleting the first character using "Delete(O,1,1);" the length of variable O was at least 2(due to the "If (Length(O)>1)" condition). So, "LongOpt:=(Length(O)>0) and (O[1]=FOptionChar);" has been replaced with "LongOpt:=(O[1]=FOptionChar);". After that, "If (P<>0) then O:=Copy(O,1,P-1);" has been replaced with "If P<>0 then SetLength(O,P-1);". WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » [SOLVED] Improvement of function TCustomApplication.FindOptionIndex Commit 1bb452d1: * Small optimizations in FindOptionIndex by... 29 SUBJECT [FPC] Code cleanup at function InitInheritedComponent DETAILS It can be noticed that the function contains two occurrences of the line I:=0;. A single presence of it is enough. A patch has been presented that removes the first occurrence. WEB LINKS https://gitlab.com/freepascal.org/fpc/source/-/issues/40917 Commit aec11012: * Remove superfluous initialization of local variable. Fixes issue #40917 30 SUBJECT [FPC] Improvement of function ExtractFileUnitName DETAILS packages/fcl-passrc/src/pscanner.pp has function ExtractFileUnitName(aFilename: String): String; Delete(Result,p,length(Result)); produces a conditional jump when computing length(ansistring) which can be avoided by replacing Delete with SetLength(Result,p-1);. A patch has been presented that that changes Delete with SetLength. WEB LINKS https://gitlab.com/freepascal.org/fpc/source/-/issues/40922 Commit 10bbe832: * Minor improvement, fix by lagprogramming. Fixes issue #40922 31 SUBJECT [FPC] Code cleanup at function TAOptBase.RegInInstruction DETAILS compiler/aoptbase.pas has function TAOptBase.RegInInstruction(Reg: TRegister; p1: tai): Boolean; The presence of the last "result:=false;" is useless because false is already assigned at the beginning of the function. A patch has been presented that removes it. WEB LINKS https://gitlab.com/freepascal.org/fpc/source/-/issues/40952 Commit 32d0531c: * patch by lag programming: Code cleanup at function TAOptBase.RegInInstruction, resolves #40952 32 SUBJECT [FPC] Simplyfied BuildInsTabMemRefSizeInfoCache DETAILS Procedure BuildInsTabMemRefSizeInfoCache can be found in compiler/x86/aasmcpu.pas and tests/utils/avx/asmtestgenerator.pas. It contains the nested function bitcnt. It can be noticed that the function returns the same values as popcnt, except it's slower. A patch has been presented that modifies the procedure BuildInsTabMemRefSizeInfoCache in order to make it call popcnt instead of the nested bitcnt. WEB LINKS https://gitlab.com/freepascal.org/fpc/source/-/issues/40962 Commit 5d4bb6db: * patch by lag programming to replace bitcnt by popcnt, resolves #40962 33 SUBJECT [FPC] Code cleanup at class procedure tnodeutils.InsertThreadvars DETAILS compiler/ngenutil.pas has class procedure tnodeutils.InsertThreadvars. A patch has been presented that removes the useless "else s:='';". WEB LINKS https://gitlab.com/freepascal.org/fpc/source/-/issues/40538 Commit 7b0578dc: * cleanup tnodeutils.InsertThreadvars as suggested in #40538, resolves #40538 34 SUBJECT [FPC] Modification of java's pos functions DETAILS rtl/java/jastrings.inc's pos functions differ in programming style. A patch has been presented that modifies an if statement in order to use the "SubstrLen" variable. WEB LINKS https://gitlab.com/freepascal.org/fpc/source/-/issues/41350 Commit 7dfd188a: * Actually use SubStrLen in pos() function. Fixes issue #41350 35 SUBJECT [FPC] Improvement of BIRegularMultiply DETAILS packages/fcl-hash/src/fptlsbigint.pas has function BIRegularMultiply. The statement "if (OuterPartial > 0) and ((OuterPartial-I) > 0) and (OuterPartial < N) then" can be rewritten as "if (OuterPartial > 0) and (OuterPartial > I) and (OuterPartial < N) then". The minimum value of variable I inside the repeat loop is 0, which makes the presence of the "(OuterPartial > 0)" condition redundant. A patch has been presented that replaces "if (OuterPartial > 0) and ((OuterPartial-I) > 0) and (OuterPartial < N) then" with "if (OuterPartial > I) and (OuterPartial < N) then". WEB LINKS Lazarus » Forum » Free Pascal » FPC development (Moderators: FPK, Tomas Hajny) » Improvement of BIRegularMultiply Commit 1d357c7a: * Small optimization by LagProgramming. Fixes issue #40710 36 SUBJECT [FPC] Code cleanup at procedure TDaemonThread.HandleControlCode DETAILS In procedure TDaemonThread.HandleControlCode(ACode, AEventType : DWord; AEventData : Pointer);, variables CC and S are declared, have values assigned but they are never used. A patch has been presented that removes these two variables from the procedure. WEB LINKS https://gitlab.com/freepascal.org/fpc/source/-/issues/40918 Commit 490fe2ec: * Remove unused variables. Patch by lagprogramming. Fixes issue #40918 MSEide/MSEgui 1 SUBJECT [MSEide/MSEgui] Useless check at function twidget.findtagchild DETAILS lib/common/kernel/msegui.pas has function twidget.findtagchild(const atag: integer; const aclass: widgetclassty): twidget; The function contains the following useless check: if result = nil then begin... It's useless because result will always be nil when reaching that line. An improvement of the function is to remove the useless check. WEB LINKS Commit f5c8704: ...optimization of function twidget.findtagchi... 2 SUBJECT [MSEide/MSEgui] Optimization of procedure tenvelopeedit.setactivetrace DETAILS lib/common/math/msesiggui.pas has procedure tenvelopeedit.setactivetrace(avalue: integer); The function contains the following lines: if avalue < 0 then begin avalue:= 0;end; if avalue > 1 then begin avalue:= 1;end;. These lines can be replaced with: if avalue > 0 then begin avalue:= 1;end else begin avalue:= 0;end;. The new code code is better because most likely, for i386 and x86_64 targets, the compiler will get rid of all existing conditional jumps(at default optimization level 2). WEB LINKS Commit 1ffc56d: ...optimization of procedure tenvelopeedit.set... 3 SUBJECT [MSEide/MSEgui] Function unregisterfontalias(const alias: string): boolean; always returns false. DETAILS lib/common/graphics/msefont.pas has function unregisterfontalias(const alias: string): boolean; The function always returns false. WEB LINKS Commit e7269b2: Thanks to ..., fixed function unregisterfontalias() in mse... 4 SUBJECT [MSEide/MSEgui] Improvement of function isvalidmapcolor DETAILS lib/common/graphics/msegraphics.pas has function isvalidmapcolor(index: colorty): boolean; An improvement of the result assignment has been presented. WEB LINKS Commit 717a790: Better isvalidmapcolor() in msegraphics.pas -> thanks to... Lazarus 1 SUBJECT [Lazarus] Useless code at TCanvas.TextExtent DETAILS lcl/include/canvas.inc has function TCanvas.TextExtent(const Text: string): TSize; Variable ARect has a value assigned but it's never used. The declaration can be removed, together with it's assignment: ARect := Rect(0, 0, 0, 0);. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » lcl/include/canvas.inc function TCanvas.TextExtent ARect variable Commit 79fadc1f: LCL: Remove an unused Rect from TCanvas.TextExtent... 2 SUBJECT [Lazarus] Making TextOut write using colours in customdrawn DETAILS lcl/interfaces/customdrawn/customdrawnwinapi.inc has function TCDWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; The function always writes with black because of the following line: FTDrawer.DrawText(Str, ftFont, RealX, RealY, colBlack, 255);. Writes can be coloured if the line is replaced with: FTDrawer.DrawText(Str, ftFont, RealX, RealY, lDestCanvas.Font.FPColor, 255);. A patch has been proposed but when trying to verify it, a forum user was unable to build a simple test application due to an error. In Windows, Lazarus was unable to build a simple empty form application. Both bugs have been solved. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Patch for fixing a TextOut bug Commit 00f4ec79: LCL-CustomDrawn: Fix compilation on Windows. Fix color in... 3 SUBJECT [Lazarus] Freeing at destructor TLazCanvasState.Destroy; DETAILS lcl/lazcanvas.pas contains destructor TLazCanvasState.Destroy; At TLazCanvasState.Destroy the font is not freed, leaving memory leaks. Later has been observed that Font.PixelsPerInch = 0 on Windows and that Canvas.TextHeight doesn't work properly. An additional patch has been provided to fix the TextHeight bug. WEB LINKS Lazarus » Forum » Programming » LCL » [SOLVED] Freeing at destructor TLazCanvasState.Destroy; Commit 8ec140d3: lcl: Fix memory leak in TLazCanvas (TLazCanvasState). See... Commit 90ea7941: CustomDrawn: Fix font height issue. Patch by lagprogrammin... 4 SUBJECT [Lazarus] Class function TCDWSButton.GetText doesn't return a valid result DETAILS lcl/interfaces/customdrawn/customdrawnwsstdctrls.pas has class function TCDWSButton.GetText(const AWinControl: TWinControl; var AText: String): Boolean; This function doesn't return a valid result. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] class function TCDWSButton.GetText doesn't return a result Commit 09b63c46: CustomDrawn: Add missing return value of the function TCDWSButton.GetText... 5 SUBJECT [Lazarus] function TFreeTypeStream.ForgetFrame always returns Failure DETAILS A patch that mimics the result assignment found in function TFreeTypeStream.AccessFrame( aSize : Int ) : TError; and in function TFreeTypeStream.ReadAtFile(APos: Long; var ABuff; ACount: Int): TError; has been proposed. WEB LINKS Lazarus » Forum » Using the Lazarus IDE » General » [SOLVED] function TFreeTypeStream.ForgetFrame always returns Failure Commit e7127c14: FreeType: Fix function TFreeTypeStream.ForgetFrame never returning success... 6 SUBJECT [Lazarus] Removal of duplicate code in lcl/controls.pp DETAILS procedure TControlChildSizing.Assign(Source: TPersistent); has duplicate assignments for the following variables: FEnlargeHorizontal, FEnlargeVertical, FShrinkHorizontal and FShrinkVertical. function TControlChildSizing.IsEqual(Sizing: TControlChildSizing): boolean; has duplicate checks for (FEnlargeHorizontal=Sizing.EnlargeHorizontal) and (FEnlargeVertical=Sizing.EnlargeVertical) and (FShrinkHorizontal=Sizing.ShrinkHorizontal) and FShrinkVertical=Sizing.ShrinkVertical). A patch has been provided in order to remove the duplicate code. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Duplicate code removal in lcl/controls.pp Commit 612dd84e: LCL: Remove duplicate code in TControlChildSizing. Suggested by... 7 SUBJECT [Lazarus] Poor CPU cache usage at procedure TCanvas.BrushCopy DETAILS lcl/include/canvas.inc has procedure TCanvas.BrushCopy. The original code doesn't read and write data in a lean way. "for x := 0 to lSrcWidth-1 do for y := 0 to lSrcHeight-1 do" has been replaced with "for y := 0 to lSrcHeight-1 do for x := 0 to lSrcWidth-1 do". WEBLINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Improvement of lcl/include/canvas.inc TCanvas.BrushCopy Commit c0946573: LCL/TCanvas: Switch x and y loops in TCanvas.BrushCopy. Patch by... 8 SUBJECT [Lazarus] Code cleanup at procedure SendFormToBack DETAILS lcl/interfaces/customdrawn/customdrawnproc.pas has procedure SendFormToBack(ACDForm: TCDNonNativeForm); Variable lCount has an assigned value at line "lCount := NonNativeForms.Count;" but it's not used at all. Most probably it's presence is due to a copy/paste from the previous in file, procedure BringFormToFront. A patch has been presented that removes from SendFormToBack the variable lCount and it's value assignment. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Code cleanup at procedure SendFormToBack Commit 5f488179: lcl/customdrawn: Cleanup of hints and warnings. Triggered by... 9 SUBJECT [Lazarus] function TCDWidgetSet.SetTextColor always returns CLR_INVALID DETAILS The modified code returns the previous color if succesful, CLR_INVALID otherwise. This makes the function consistent with the results of similar functions in other interfaces. Also, has been noticed that variable "lFont: TFPCustomFont;" is not used not only in SetTextColor but also in GetTextColor. A patch has been presented that removed "lFont: TFPCustomFont;" declaration as the variable is not used. In addition to that, if LazDC.Font <> nil then "Result := FPColorToTColorRef(LazDC.Font.FPColor);" has also been added. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Bug at TCDWidgetSet.SetTextColor Commit 2ae1edf2: LCL-CustomDrawn: Fix TCDWidgetSet.SetTextColor. Issue #40204. 10 SUBJECT [Lazarus] TCDWidgetSet.SaveDC might return a valid zero index, which would be interpretated as a failure DETAILS According to the comments found all over the interfaces, the function should return the index assigned to OR 0 if DC is not valid. The original code returns the index of TLazCanvas.SaveState, which can be zero. This makes a valid TLazCanvas.SaveState zero index to be interpreted as if DC is not valid. The patch that was presented mimics the solution found in function TCocoaContext.SaveDC: Integer; The function result is the index in the list + 1. This means that the first SaveDC will be one, not zero. TCDWidgetSet. RestoreDC has been updated, too. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Patch for fixing a bug at TCDWidgetSet.SaveDC Commit 63b6e913: LCL-CustomDrawn: Fix a bug at TCDWidgetSet.SaveDC. Issue #40205. 11 SUBJECT [Lazarus] Removal of initial nil result assignment at function FindClassNode DETAILS lcl/widgetset/wslclclasses.pp has function FindClassNode(const AComponent: TComponentClass): PClassNode; A patch has been presented that removes the initial "Result := nil;" assignment. The patch also removes the exit by adding an "else" part to the "if" condition. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [CLOSED] Result assignments removal in lcl/widgetset/wslclclasses.pp Commit: d7720468 LCL/widgetset: Clearer code in FindClassNode (unit... 12 SUBJECT [Lazarus] Code clean up at TWinControl.Loaded DETAILS lcl/include/wincontrol.inc has procedure TWinControl.Loaded; A patch has been presented that removes the useless "if AChild=nil then ;" line. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Code clean up at TWinControl.Loaded Commit f63e4802: LCL Cleanup TWinControl.Loaded. Patch by... 13 SUBJECT [Lazarus] Customdrawn key handling doesn't work with TUTF8Char DETAILS lcl/interfaces/customdrawn/customdrawnprivate.pas has procedure CallbackKeyChar(AWindowHandle: TCDForm; AKeyData: Word; AChar: TUTF8Char); The procedure calls twice LCLSendUTF8KeyPress as if the TUTF8Char parameter would have been a variable parameter, but LCLSendUTF8KeyPress accepts the TUTF8Char parameter as a value parameter. This means that procedure CallbackKeyChar is not able to know if the TUTF8Char variable has been modified. Two patches have been presented in order to modify LCLSendUTF8KeyPress but it's original code has been preserved because it breaks compatibility with code that's not officially delivered with Lazarus(Ide and LCL). A third patch has been accepted, patch that modifies procedure CallbackKeyChar in order to use TWinControl's IntfUTF8KeyPress instead of LCLSendUTF8KeyPress. WEB LINKS Lazarus » Forum » Programming » LCL » [SOLVED] LCLSendUTF8KeyPress AUTF8Char parameter anomaly Lazarus » Forum » Miscellaneous » Suggestions » LCL » [CLOSED] LCLSendUTF8KeyPress always returns 1 Commit 059aca59: LCL: Call lTarget.IntfUTF8KeyPress instead of LCLSendUTF8KeyPress in procedure... 14 SUBJECT [Lazarus] CustomDrawn applications don't trigger OnKeyPress events DETAILS A patch has been presented that makes CustomDrawn built applications able to trigger OnKeyPress events. The patch modifies procedure CallbackKeyChar(AWindowHandle: TCDForm; AKeyData: Word; AChar: TUTF8Char); in lcl/interfaces/customdrawn/customdrawnprivate.pas WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] TEdit key press events in customdrawn LCLWidgetType Commit 9e69dd97: LCL-CustomDrawn: Improve TEdit key press events. Issue #40221, patch by... 15 SUBJECT [Lazarus] Fixing memory leaks in function RenderWinControl DETAILS lcl/interfaces/customdrawn/customdrawnproc.pas has function RenderWinControl(var AImage: TLazIntfImage; var ACanvas: TLazCanvas; ACDWinControl: TCDWinControl; ACDForm: TCDForm): Boolean; A simple form with a TEdit on it run for a couple of seconds in Linux-customdrawn. The application ran with heaptrc unit, which made the console window print lots of memory leaks. One of them was related to line: lRegion := TLazRegionWithChilds.Create; The memory allocated for lRegion is never freed. A patch for Lazarus has been presented, but a different patch has been applied, in FPC. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Fixing memory leaks in function RenderWinControl Commit facf28fb: * fix from Werner P. Setter for clipregion to fix memory leak. 16 SUBJECT Removal of obsolete code lines in lcl/lclversion.pas DETAILS Following a series of tests has been concluded that Lazarus can't be built using FPC verions prior to 3.0.0. A patch has been presented that removes code lines designed for obsolete FPC versions in the file lcl/lclversion.pas. WEB LINKS Lazarus » Forum » Programming » LCL » [SOLVED] Lazarus LCL FPC compatibility question Issue #40275: Obsolete lines from lcl/lclversion.pas Commit 45d42dfd: LCL: Remove obsolete ifdefs from LCLVersion. Issue #40275, patch by... 17 SUBJECT [Lazarus] Code clean up at function LCLSendActivateMsg DETAILS lcl/lclmessageglue.pas has function LCLSendActivateMsg(const Target: TControl; Active: Word; Minimized: Boolean; ActiveWindow: HWND = 0): PtrInt; A patch has been presented that removes the useless initial "Result := 0;" line. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Code clean up at function LCLSendActivateMsg Commit 0d14433f: LCL: remove redundant assignment in LCLSendActivateMsg(). Reported on forum by 18 SUBJECT [Lazarus] Code cleanup at lcl/interfaces/customdrawn/customdrawnwsforms_x11.inc DETAILS lcl/interfaces/customdrawn/customdrawnwsforms_x11.inc keeps redefining two functions, even though fpc has been modified 11 years ago in order to fix the targeted issue. A patch has been presented that removes the obsolete redefines from LCL. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Code cleanup at lcl/interfaces/customdrawn/customdrawnwsforms_x11.inc Commit 81002eb2: CustomDrawn: cleanup, patch by... 19 SUBJECT [Lazarus] Clean up at ide/include/ide.inc DETAILS File ide/include/ide.inc contains a series of lines usable by FPC versions prior to 2.7.0, even though Lazarus can't be built by FPC versions prior to 3.0.0. A patch has been presented that removes the obsolete lines. The decision was to clean up more than the obsolete lines presented in the patch. In addition to those, lots of other similar lines(version checks and obsolete code) have been removed from the development Lazarus sources. By the end of the clean up, it was clear that Lazarus, including LCL, needs at least version 3.2.0 of FPC. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » IDE/CodeTools » [SOLVED] Clean up at ide/include/ide.inc Commit 41adb276: Remove obsolete checks for FPC versions earlier then 3.0. Commit adfc424e: Lazarus trunk requires at least FPC 3.2.0. Remove checks for earlier FPC_FULLVERSION. 20 SUBJECT [Lazarus] TCDWidgetSet.DrawFocusRect always returns false DETAILS lcl/interfaces/customdrawn/customdrawnwinapi.inc has function TCDWidgetSet.DrawFocusRect(DC: HDC; const Rect: TRect): boolean; The function always returns false. If IsValidDC(DC) is true then GetDefaultDrawer().DrawFocusRect is called, which means the function should return true. A patch has been presented that fixes the issue, making the function also return a true value. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] TCDWidgetSet.DrawFocusRect always returns false Commit da8a33d4: CustomDrawn: Add missing result value of function TCDWidgetSet.DrawFocusRect... 21 SUBJECT [Lazarus] Improvement of TQtWidgetSet.EnumDisplayMonitors functions DETAILS The original code of the two functions unnecessarily check the result for true inside the loops. In addition to that, the loops involve pred(-1) and succ(+1) values that can be avoided just by changing "for 1 := 0" with "for i := 1". A patch has been presented that improves the functions. WEB LINKS Lazarus » Forum » Programming » Widgetset » QT » [SOLVED] Improvement of TQtWidgetSet.EnumDisplayMonitors functions Commit be92e362: LCL-QT[56]: Clean and optimise function TQtWidgetSet.EnumDisplayMonitors()... Commit dca4378f: LCL-QT4: Clean and optimize function TQtWidgetSet.EnumDisplayMonitors()... 22 SUBJECT [Lazarus] Modification of TCDEdit's destructor DETAILS lcl/customdrawncontrols.pas has destructor TCDEdit.Destroy; In the official code "inherited Destroy;" is followed by a "FLines.Free;" line, where FLines is a TStringList. A patch has been presented that moves "FLines.Free;" before "inherited Destroy;". WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Modification of TCDEdit's destructor Commit 15741490: Customdrawn: Cleanup. Issues #40387 and #40388. 23 SUBJECT [Lazarus] Code cleanup at lcl/interfaces/customdrawn/customdrawnobject_x11.inc DETAILS lcl/interfaces/customdrawn/customdrawnobject_x11.inc keeps redefining two functions, even though fpc has been modified 10 years ago in order to fix the targeted issue. A patch has been presented that removes the obsolete redefines from LCL. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Code cleanup at lcl/interfaces/customdrawn/customdrawnobject_x11.inc Commit 15741490: Customdrawn: Cleanup. Issues #40387 and #40388. 24 SUBJECT [Lazarus] Code clean up at TScreen.EndTempCursor DETAILS lcl/include/screen.inc has procedure TScreen.EndTempCursor(const aCursor: TCursor); The nested procedure is no longer needed because the minimum FPC version required to compile the sources supportd deleting array items. A patch has been presented that removes the nested procedure by replacing the "_Delete(I);" line with "delete(FTempCursors,I,1);". WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Code clean up at procedure TScreen.EndTempCursor Commit ca9cb1a6: Clean up procedure TScreen.EndTempCursor. Issue #40389. 25 SUBJECT [Lazarus] TQtWidgetSet.DrawFrameControl always return false DETAILS TQtWidgetSet.DrawFrameControl can be found in the qtwinapi.inc files. The result is always false. True boolean values should be returned, too. WEB LINKS Lazarus » Forum » Programming » Widgetset » QT » [SOLVED] TQtWidgetSet.DrawFrameControl always returns false Issue #40380: QT / TQtWidgetSet.DrawFrameControl always returns false Commit 0878535f: Qt,Qt5,Qt6: Fixed result of TQtWidgetSet.DrawFrameControl. Issue #40380 26 SUBJECT [Lazarus] Clean up at lcl/buttons.pp DETAILS File lcl/buttons.pp contains function GetDefaultButtonIcon and procedure LoadGlyphFromResource, both of them having variables declared that are not used. A patch has been presented that removes them. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Code clean up at /lcl/buttons.pp Commit 50e7d46c: LCL: cleaned up some unused variables, issue #40414 27 SUBJECT [Lazarus] Some comment fixes DETAILS A patch has been presented that fixes some comments regarding Lazarus IDE tabs in file lcl/interfaces/customdrawn/customdrawnprivate.pas. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] Some comment fixes Commit 5f924393: CustomDrawn: Fix comments (Patch by... 28 SUBJECT [Lazarus] Declarations clean up inside win32callback.inc DETAILS lcl/interfaces/win32/win32callback.inc declares WM_DPICHANGED, FLASHWINFO and FlashWindowEx. These declarations have been included in FPC. A patch has been presented that removes them from LCL. WEB LINKS Lazarus » Forum » Programming » Widgetset » Win32/64 » [SOLVED] Declarations clean up inside win32callback.inc Commit 11130cc6: LCL, Win32: cleaned up declarations available in FPC since 3.2.0, patch by... 29 SUBJECT [Lazarus] Improvement of function TFreeTypeFont.GetVersionNumber DETAILS components/freetype/easylazfreetype.pas has function TFreeTypeFont.GetVersionNumber: string; A patch has been presented that replaces the occurencies of (idxEnd+1 <= length(VersionStr)) with (idxEnd < length(VersionStr)), making the code slimmer and faster. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Improvement of TFreeTypeFont.GetVersionNumber Commit 441266a4: FreeType: Clean up TFreeTypeFont.GetVersionNumber. Issue #40438. 30 SUBJECT [Lazarus] Removal of CDCS_*, GPS_* and SIATTRIBFLAGS_* constants from LCL DETAILS CDCS_*, GPS_* and SIATTRIBFLAGS_* constants are declared but never used in LCL. The same constants are declared in fpc's packages/winunits-base/src/shlobj.pp. Third party applications should use FPC's declarations. A patch has been presented that removes the declarations from lcl/interfaces/win32/win32extra.pas and lcl/interfaces/customdrawn/customdrawn_winextra.pas. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Removal of CDCS_*, GPS_* and SIATTRIBFLAGS_* constants from LCL Commit 904b5fd7: LCL (Win32, CustomDrawn): removed constants already present in Windows/ShlObj units, issue #40451 31 SUBJECT [Lazarus] Removal of LAYOUT_* and GCLP_HBRBACKGROUND constants from LCL DETAILS LAYOUT_* and GCLP_HBRBACKGROUND constants are declared in both LCL and FPC's rtl. The constants have been included in FPC's rtl through the commites 8304d2c1 and 609f6255. A patch has been presented that removes the declarations from LCL. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Cleanup of duplicate declarations of constants Commit 904b5fd7: LCL (Win32, CustomDrawn): removed constants already present in Windows/ShlObj units, issue #40451 32 SUBJECT [Lazarus] Clean up at TFileOpener.OpenMainUnit DETAILS ide/sourcefilemanager.pas has function TFileOpener.OpenMainUnit: TModalResult; After the line "if Result<>mrOk then exit;" for sure Result is mrOk. A patch has been presented that removes the lines: if Result<>mrOk then exit;Result:=mrOk; WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » IDE/CodeTools » [SOLVED] Clean up at TFileOpener.OpenMainUnit Commit 6d4a4ec2: IDE: Cleanup TFileOpener.OpenMainUnit. 33 SUBJECT [Lazarus] Improvement of TApplication.GetControlAtPos DETAILS lcl/include/application.inc has function TApplication.GetControlAtPos(P: TPoint): TControl; A patch has been presented that avoids the last "if Assigned(Result) then" condition. In addition to that, by switching the then and else parts of "csDesigning in Result.ComponentState" condition, the modified code follows FPC's programmer's guide recommendation: "Write your if/then/else statements so that the code in the "then"-part gets executed most of the time (improves the rate of successful jump prediction).". The useless duplicate "if Assigned(Result) then" condition has been removed but a different patch has been used. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Improvement of TApplication.GetControlAtPos Commit 895c80c4: LCL: optimized TApplication.GetControlAtMouse (no functional changes), patch by Rika, issue #40465 34 SUBJECT [Lazarus] Code cleanup at function TGtk3WidgetSet.GetKeyState DETAILS lcl/interfaces/gtk3/gtk3winapi.inc has function TGtk3WidgetSet.GetKeyState(nVirtKey: Integer): Smallint; The function has a duplicate "Result := 0;" line at start. A patch has been presented that amongst other things, removes one of these two "Result := 0;" lines. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [CLOSED] Code cleanup in gtk widgetsets Commit 0883368a: Gtk3: cleanup, issue #40489 35 SUBJECT [Lazarus] TForm's MouseMove bugfix in Custom-drawn DETAILS Add a button on an empty form and fill the OnMouseMove events for both Form1 and Button1. In linux-customdrawn, the coordinates shown when moving the mouse over the form are wrong, most likely sometimes being negative. In the context of the function FindControlPositionRelativeToTheForm, forms don't have relative positions to themselves as parent form controls, so inserting "if (ALCLControl is TCustomForm) then Exit(Point(0,0));" as the first line fixes the bug. A patch has been presented. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] TForm's MouseMove bugfix Commit 2c1472b4: CustomDrawn: Fix TForm's MouseMove. Issue #40609. 36 SUBJECT [Lazarus] TButton's missing caption bugfix in Custom-drawn DETAILS Add a tbutton on a form. In linux-customdrawn the caption of the tbutton doesn't appear. A patch has been presented that modifies class procedure TCDWSButton.InjectCDControl and class function TCDWSButton.CreateHandle WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] TButton's missing caption bugfix Commit 728725bd: Fix TButton's caption. Issue #40638, patch by... 37 SUBJECT [Lazarus] Single instance of SHGFI_* constants DETAILS SHGFI_* constants like SHGFI_SMALLICON, SHGFI_LARGEICON and SHGFI_ICON are declared in both Lazarus and FreePascal. In Free Pascal, the constants are declared in both rtl/wince/wininc/defines.inc and packages/winunits-base/src/shellapi.pp. Lazarus declares them in lcl/interfaces/customdrawn/customdrawn_winextra.pas and lcl/interfaces/win32/win32extra.pas. A patch has been presented that removes the declarations from LCL. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » [SOLVED] Single instance of SHGFI_* constants Commit f23c89a1: LCL-Win32 and CustomDrawn: cleaned up SHGFI_* constants, patch by ... 38 SUBJECT [Lazarus] VerifyAndCleanUpFontDirectories doesn't check all list entries DETAILS lcl/interfaces/customdrawn/customdrawnproc.pas has procedure VerifyAndCleanUpFontDirectories(AFontDirectories: TStringList); The original code doesn't remove all inexistent or duplicate directories because immediately after a delete the list index is increased, thus skipping a list entry. A patch has been presented that keeps the index unchanged if the list deletes an entry. WEB LINKS Lazarus » Forum » Programming » Widgetset » CustomDrawn » [SOLVED] VerifyAndCleanUpFontDirectories doesn't check all list entries Commit 9dc10d9a: LCL-CustomDrawn: Check all list entries in VerifyAndCleanUpFontDirectories... 39 [Lazarus] Improvement of TFreeTypeRenderableFont.DefaultWordBreakHandler DETAILS components/freetype/easylazfreetype.pas has procedure TFreeTypeRenderableFont.DefaultWordBreakHandler(var ABefore, AAfter: string); A patch has been presented that replaces "ABefore := copy(ABefore,1,p-1);" with "SetLength(ABefore, p-1);" and "delete(ABefore,length(ABefore),1);" with "SetLength(ABefore, length(ABefore)-1);". WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » LCL » [SOLVED] Improvement of TFreeTypeRenderableFont.DefaultWordBreakHandler Commit 56887ae8: FreeType: Minor optimization for... Other 1 SUBJECT [Other] Forum sugestion regarding video file extensions DETAILS In order to attach a video file to a message, a user has to put it in an archive first. It complicates something that can be done straight forward. It was suggested to add video file extensions(like avi, mp4, mkv...) to the list of file extensions that can be attached to a message. Files with mp4 extension are now allowed. WEB LINKS Lazarus » Forum » Miscellaneous » Suggestions » [SOLVED] Forum suggestion regarding video file extensions