app_server: avoid duplicate scan of font directories

When scanning a directory for fonts we also include its subdirectories.
Those may already be in the list and may even have been scanned before.
That happens in a typical setup, where the system fonts directory is
obviously included and then a subdirectory is added as part of the
default mappings.

See #18979

Change-Id: I92c6b7965aee030520402e2d53c4190fdca8b0e1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8001
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
Máximo Castañeda 2024-08-11 12:28:34 +02:00 committed by waddlesplash
parent 6edfc6e012
commit 978af2370b

View File

@ -914,6 +914,9 @@ GlobalFontManager::_ScanFontDirectory(font_directory& fontDirectory)
// This bad boy does all the real work. It loads each entry in the
// directory. If a valid font file, it adds both the family and the style.
if (fontDirectory.scanned)
return B_OK;
BDirectory directory;
status_t status = directory.SetTo(&fontDirectory.directory);
if (status != B_OK)
@ -924,8 +927,10 @@ GlobalFontManager::_ScanFontDirectory(font_directory& fontDirectory)
if (entry.IsDirectory()) {
// scan this directory recursively
font_directory* newDirectory;
if (_AddPath(entry, &newDirectory) == B_OK && newDirectory != NULL)
if (_AddPath(entry, &newDirectory) == B_OK && newDirectory != NULL
&& !newDirectory->scanned) {
_ScanFontDirectory(*newDirectory);
}
continue;
}