[SOLVED] Code clean up at TWinControl.Loaded lazarus / 7-LCL ---------------------------------------------------------------------- lagprogramming · 2023-04-15 08:45 lcl/include/wincontrol.inc has procedure TWinControl.Loaded; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TWinControl.Loaded;var  CachedText: string;  i: Integer;  AChild: TControl;  LoadedClientSize: TSize;  CurControl: TWinControl;begin  //DebugLn(['TWinControl.Loaded START ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']);  DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.Loaded'){$ENDIF};  try    //DebugLn(['TWinControl.Loaded ',DbgSName(Self),' cfWidthLoaded=',cfWidthLoaded in FControlFlags,' cfHeightLoaded=',cfHeightLoaded in FControlFlags,' ']);    if cfClientWidthLoaded in FControlFlags then      LoadedClientSize.cx:=FLoadedClientSize.cx    else begin      CurControl:=Self;      while CurControl<>nil do begin        LoadedClientSize.cx:=CurControl.ClientWidth;        if LoadedClientSize.cx>0 then break;        LoadedClientSize.cx:=CurControl.Width;        if LoadedClientSize.cx>0 then break;        CurControl:=CurControl.Parent;      end;    end;  if cfClientHeightLoaded in FControlFlags then      LoadedClientSize.cy:=FLoadedClientSize.cy    else begin      CurControl:=Self;      while CurControl<>nil do begin        LoadedClientSize.cy:=CurControl.ClientHeight;        if LoadedClientSize.cy>0 then break;        LoadedClientSize.cy:=CurControl.Height;        if LoadedClientSize.cy>0 then break;        CurControl:=CurControl.Parent;      end;    end;    for i:=0 to ControlCount-1 do begin      AChild:=Controls[i];      if AChild=nil then ;      AChild.FBaseParentClientSize:=LoadedClientSize;      //DebugLn(['TWinControl.Loaded Self=',DbgSName(Self),' AChild=',AChild,' AChild.FBaseParentClientSize=',dbgs(AChild.FBaseParentClientSize)]);  end;    if HandleAllocated then    begin      // Set cached caption    if GetCachedText(CachedText) then        WSSetText(CachedText);    InvalidatePreferredSize;       if wcfColorChanged in FWinControlFlags then      begin        TWSWinControlClass(WidgetSetClass).SetColor(Self);        NotifyControls(CM_PARENTCOLORCHANGED);        Exclude(FWinControlFlags, wcfColorChanged);      end;      if wcfFontChanged in FWinControlFlags then      begin        TWSWinControlClass(WidgetSetClass).SetFont(Self,Font);        NotifyControls(CM_PARENTFONTCHANGED);        FWinControlFlags:=FWinControlFlags-[wcfFontChanged];      end;    end;     inherited Loaded;     FixupTabList;   finally    //DebugLn(['TWinControl.Loaded enableautosizing ',DbgSName(Self),' ',dbgs(BoundsRect)]);    EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.Loaded'){$ENDIF};    //DebugLn(['TWinControl.Loaded END ',DbgSName(Self),' ',dbgs(BoundsRect)]);  end;end; The following patch removes the useless "if AChild=nil then ;" line. The line can be found inside the "for" loop. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.incindex 37346973b5..7034017b77 100644--- a/lcl/include/wincontrol.inc+++ b/lcl/include/wincontrol.inc@@ -7784,7 +7784,6 @@ begin     end;     for i:=0 to ControlCount-1 do begin       AChild:=Controls[i];-      if AChild=nil then ;       AChild.FBaseParentClientSize:=LoadedClientSize;       //DebugLn(['TWinControl.Loaded Self=',DbgSName(Self),' AChild=',AChild,' AChild.FBaseParentClientSize=',dbgs(AChild.FBaseParentClientSize)]);   end; ---------------------------------------------------------------------- AlexTP · 2023-04-15 08:50 Posted to bugtracker, https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40209