From 978af2370b2cea39b9dc8e5b8dfed6ad899c95e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= Date: Sun, 11 Aug 2024 12:28:34 +0200 Subject: [PATCH] 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 Reviewed-by: waddlesplash Tested-by: Commit checker robot --- src/servers/app/font/GlobalFontManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/servers/app/font/GlobalFontManager.cpp b/src/servers/app/font/GlobalFontManager.cpp index 638f669b02..0f75b19e8d 100644 --- a/src/servers/app/font/GlobalFontManager.cpp +++ b/src/servers/app/font/GlobalFontManager.cpp @@ -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; }