Forum > CustomDrawn

[SOLVED] VerifyAndCleanUpFontDirectories doesn't check all list entries


lcl/interfaces/customdrawn/customdrawnproc.pas has

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure VerifyAndCleanUpFontDirectories(AFontDirectories: TStringList);var  i, j: Integer;begin  // Add path delimitiers to the end of all paths  for i := 0 to AFontDirectories.Count -1 do  begin    AFontDirectories.Strings[i] := IncludeTrailingPathDelimiter(AFontDirectories.Strings[i]);  end;   // remove all duplicates  i := 0;  while i < AFontDirectories.Count do  begin    j := i+1;    while j < AFontDirectories.Count do    begin      if AFontDirectories.Strings[i] = AFontDirectories.Strings[j] then        AFontDirectories.Delete(j);      Inc(j);    end;    Inc(i);  end;   // Now remove all directories which don't exist  i := 0;  while i < AFontDirectories.Count do  begin    if not DirectoryExistsUTF8(AFontDirectories.Strings[i]) then      AFontDirectories.Delete(i);    Inc(i);  end;   // Raise an exception if there are no font directories  if AFontDirectories.Count = 0 then    raise Exception.Create('[VerifyAndCleanUpFontDirectories] After cleaning up no font directories were found.');end;The original code doesn't remove all nonexistent or duplicate directories because immediately after a delete the list index is increased, thus skipping a list entry. The following patch keeps the index unchanged if the list deletes an entry. Now each and every tstringlist entry is verified.



[0] Message Index

Go to full version