[SOLVED] Code clean up at procedure TScreen.EndTempCursor lazarus / 7-LCL ---------------------------------------------------------------------- lagprogramming · 2023-07-20 08:00 lcl/include/screen.inc has 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 TScreen.EndTempCursor(const aCursor: TCursor);  procedure _Delete(const _Index: Integer); // FPC 3.0.x doesn't support Delete() for arrays #36728  var    I: Integer;  begin    for I := _Index to High(FTempCursors)-1 do      FTempCursors[I] := FTempCursors[I+1];    SetLength(FTempCursors, Length(FTempCursors)-1);  end;var  I: Integer;  OldCursor: TCursor;begin  OldCursor := RealCursor;  for I := High(FTempCursors) downto Low(FTempCursors) do  begin    if FTempCursors[I]=aCursor then    begin      _Delete(I);      if OldCursor<>RealCursor then        WidgetSet.SetCursor(Cursors[RealCursor]);      Exit;    end;  end;  raise Exception.CreateFmt('Unbalanced BeginTempCursor/EndTempCursor calls for cursor %d', [aCursor]);end;The nested procedure is no longer needed. The following patch removes it by replacing the _Delete(I); line with delete(FTempCursors,I,1);. 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/screen.inc b/lcl/include/screen.incindex 346dcf03d8..6d4eaa8c34 100644--- a/lcl/include/screen.inc+++ b/lcl/include/screen.inc@@ -438,14 +438,6 @@ begin end;  procedure TScreen.EndTempCursor(const aCursor: TCursor);-  procedure _Delete(const _Index: Integer); // FPC 3.0.x doesn't support Delete() for arrays #36728-  var-    I: Integer;-  begin-    for I := _Index to High(FTempCursors)-1 do-      FTempCursors[I] := FTempCursors[I+1];-  SetLength(FTempCursors, Length(FTempCursors)-1);-  end; var   I: Integer;   OldCursor: TCursor;@@ -455,7 +447,7 @@ begin   begin     if FTempCursors[I]=aCursor then     begin-      _Delete(I);+      delete(FTempCursors,I,1);       if OldCursor<>RealCursor then         WidgetSet.SetCursor(Cursors[RealCursor]);       Exit; ---------------------------------------------------------------------- AlexTP · 2023-07-20 08:14 Posted to https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40389 ---------------------------------------------------------------------- Zvoni · 2023-07-20 08:35 Wouldn't it make more sense to put it into a conditional? 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 {$IF FPC_FULLVERSION<=30200}       //Use Nested Proc{$ELSE}       //Use "native" Delete{$ENDIF}     There might still be people having to use "older" compilers ---------------------------------------------------------------------- paweld · 2023-07-20 09:19 Quote from: ZvoniThere might still be people having to use "older" compilers Lazarus supports the last 2 stable versions of fpc, that is, Lazarus trunk version supports fpc 3.2.0 and fpc 3.2.2. so such a condition makes no sense.  Recently removed old checks: https://gitlab.com/freepascal.org/lazarus /lazarus/-/commit/adfc424e92109b038af669460d5c6bb3b4867f5c ---------------------------------------------------------------------- JuhaManninen · 2023-07-20 16:11 Quote from: Zvoni on July 20, 2023, 10:35:47 amThere might still be people having to use "older" compilers Lazarus trunk has not compiled with FPC 3.0.x for some time. It is better clean the code and remove obsolete IFDEFs. With older compilers you must use older Lazarus versions. They remain functional. An "old compiler" is a flexible term. Even the supported FPC 3.2.0 is already old because of the slow release cycle of FPC project. ... and there are no signs for a bug fix release FPC 3.2.4 yet. This FPC policy is annoying to put it mildly.