From 56761ebfeb16e6bdf11f598986838e45062a699b Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 22 Oct 2022 23:05:45 -0400 Subject: [PATCH] app_server: Granularize whether font settings were loaded in DesktopSettings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per axeld's review. Change-Id: Idd817156d53ebf535f162285bfd08f0566ac3901 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5755 Reviewed-by: waddlesplash Reviewed-by: Axel Dörfler Tested-by: Commit checker robot --- src/servers/app/Desktop.cpp | 2 +- src/servers/app/DesktopSettings.cpp | 37 ++++++++++-------------- src/servers/app/DesktopSettingsPrivate.h | 6 ++-- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 20804b0b8e..a9256da59f 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -527,7 +527,7 @@ Desktop::Init() // now that the mode is set, see if we should increase the default font size if (fSettings->DefaultPlainFont() == *gFontManager->DefaultPlainFont() - && !fSettings->DidLoadSettings()) { + && !fSettings->DidLoadFontSettings()) { float fontSize = fSettings->DefaultPlainFont().Size(); gScreenManager->Lock(); Screen* screen = gScreenManager->ScreenAt(0); diff --git a/src/servers/app/DesktopSettings.cpp b/src/servers/app/DesktopSettings.cpp index 972f75f6cd..e4b1eb75c8 100644 --- a/src/servers/app/DesktopSettings.cpp +++ b/src/servers/app/DesktopSettings.cpp @@ -34,7 +34,7 @@ DesktopSettingsPrivate::DesktopSettingsPrivate(server_read_only_memory* shared) { // if the on-disk settings are not complete, the defaults will be kept _SetDefaults(); - fLoadStatus = _Load(); + _Load(); } @@ -111,7 +111,6 @@ DesktopSettingsPrivate::_Load() status_t status = _GetPath(basePath); if (status < B_OK) return status; - int32 loadFailures = 0; // read workspaces settings @@ -138,10 +137,8 @@ DesktopSettingsPrivate::_Load() i, &fWorkspaceMessages[i]) == B_OK) { i++; } - } else - loadFailures++; - } else - loadFailures++; + } + } // read font settings @@ -152,7 +149,9 @@ DesktopSettingsPrivate::_Load() if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); - if (status == B_OK && gFontManager->Lock()) { + if (status != B_OK) { + fFontSettingsLoadStatus = status; + } else if (gFontManager->Lock()) { const char* family; const char* style; float size; @@ -189,9 +188,9 @@ DesktopSettingsPrivate::_Load() gFontManager->Unlock(); } else - loadFailures++; + fFontSettingsLoadStatus = EWOULDBLOCK; } else - loadFailures++; + fFontSettingsLoadStatus = status; // read mouse settings @@ -219,10 +218,8 @@ DesktopSettingsPrivate::_Load() == B_OK) { fAcceptFirstClick = acceptFirstClick; } - } else - loadFailures++; - } else - loadFailures++; + } + } // read appearance settings @@ -315,10 +312,8 @@ DesktopSettingsPrivate::_Load() fShared.colors[i] = B_TRANSPARENT_COLOR; } } - } else - loadFailures++; - } else - loadFailures++; + } + } // read dragger settings @@ -332,12 +327,10 @@ DesktopSettingsPrivate::_Load() if (status == B_OK) { if (settings.FindBool("show", &fShowAllDraggers) != B_OK) fShowAllDraggers = true; - } else - loadFailures++; - } else - loadFailures++; + } + } - return (loadFailures > 0) ? B_PARTIAL_READ : B_OK; + return B_OK; } diff --git a/src/servers/app/DesktopSettingsPrivate.h b/src/servers/app/DesktopSettingsPrivate.h index 7b061280ca..fd7c0fbc0a 100644 --- a/src/servers/app/DesktopSettingsPrivate.h +++ b/src/servers/app/DesktopSettingsPrivate.h @@ -27,8 +27,8 @@ public: server_read_only_memory* shared); ~DesktopSettingsPrivate(); - bool DidLoadSettings() const - { return fLoadStatus == B_OK; } + bool DidLoadFontSettings() const + { return fFontSettingsLoadStatus == B_OK; } status_t Save(uint32 mask = kAllSettings); void SetDefaultPlainFont(const ServerFont& font); @@ -104,7 +104,7 @@ private: void _ValidateWorkspacesLayout(int32& columns, int32& rows) const; - status_t fLoadStatus; + status_t fFontSettingsLoadStatus; ServerFont fPlainFont; ServerFont fBoldFont;