Recent

Author Topic: [SOLVED] Code cleanup at procedure SendFormToBack  (Read 1389 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 405
[SOLVED] Code cleanup at procedure SendFormToBack
« on: April 13, 2023, 12:12:17 pm »
lcl/interfaces/customdrawn/customdrawnproc.pas has procedure SendFormToBack(ACDForm: TCDNonNativeForm);
This is the original code:
Code: Pascal  [Select][+][-]
  1. procedure SendFormToBack(ACDForm: TCDNonNativeForm);
  2. var
  3.   lCount, lCurIndex: Integer;
  4. begin
  5.   // Hide the form
  6.   ACDForm.Visible := False;
  7.  
  8.   InitNonNativeForms();
  9.   lCount := NonNativeForms.Count;
  10.   lCurIndex := NonNativeForms.IndexOf(ACDForm);
  11.   {$IFDEF VerboseCDForms}
  12.     DebugLn(Format('SendFormToBack lOldIndex=%d lNewIndex=0', [lCurIndex]));
  13.   {$ENDIF}
  14.   NonNativeForms.Move(lCurIndex, 0);
  15. end;
It can be noticed that 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.

Code: Pascal  [Select][+][-]
  1. procedure BringFormToFront(ACDForm: TCDNonNativeForm);
  2. var
  3.   lCount, lCurIndex: Integer;
  4. begin
  5.   InitNonNativeForms();
  6.   lCount := NonNativeForms.Count;
  7.   lCurIndex := NonNativeForms.IndexOf(ACDForm);
  8.   {$IFDEF VerboseCDForms}
  9.     DebugLn(Format('BringFormToFront lOldIndex=%d lNewIndex=%d', [lCurIndex, lCount-1]));
  10.   {$ENDIF}
  11.   NonNativeForms.Move(lCurIndex, lCount-1);
  12. end;

The patch removes from SendFormToBack the variable lCount and it's value assignment.
The new code will be:
Code: Pascal  [Select][+][-]
  1. procedure SendFormToBack(ACDForm: TCDNonNativeForm);
  2. var
  3.   lCurIndex: Integer;
  4. begin
  5.   // Hide the form
  6.   ACDForm.Visible := False;
  7.  
  8.   InitNonNativeForms();
  9.   lCurIndex := NonNativeForms.IndexOf(ACDForm);
  10.   {$IFDEF VerboseCDForms}
  11.     DebugLn(Format('SendFormToBack lOldIndex=%d lNewIndex=0', [lCurIndex]));
  12.   {$ENDIF}
  13.   NonNativeForms.Move(lCurIndex, 0);
  14. end;

The patch:
Code: Pascal  [Select][+][-]
  1. diff --git a/lcl/interfaces/customdrawn/customdrawnproc.pas b/lcl/interfaces/customdrawn/customdrawnproc.pas
  2. index 5170ddc72b..0e8303af08 100644
  3. --- a/lcl/interfaces/customdrawn/customdrawnproc.pas
  4. +++ b/lcl/interfaces/customdrawn/customdrawnproc.pas
  5. @@ -312,13 +312,12 @@ end;
  6.  
  7.  procedure SendFormToBack(ACDForm: TCDNonNativeForm);
  8.  var
  9. -  lCount, lCurIndex: Integer;
  10. +  lCurIndex: Integer;
  11.  begin
  12.    // Hide the form
  13.    ACDForm.Visible := False;
  14.  
  15.    InitNonNativeForms();
  16. -  lCount := NonNativeForms.Count;
  17.    lCurIndex := NonNativeForms.IndexOf(ACDForm);
  18.    {$IFDEF VerboseCDForms}
  19.      DebugLn(Format('SendFormToBack lOldIndex=%d lNewIndex=0', [lCurIndex]));
« Last Edit: April 13, 2023, 05:04:01 pm by lagprogramming »

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Code cleanup at procedure SendFormToBack
« Reply #1 on: April 13, 2023, 12:52:05 pm »
Committed along with other changes to reduce hints. ATM, compilation of the customdrawn package does not generate any hints any more.

 

TinyPortal © 2005-2018