lcl/interfaces/customdrawn/customdrawnproc.pas has
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.