From 5577d5f7890edd18ddcb01647adeeec395597523 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 2 Feb 2023 14:29:34 +0100 Subject: [PATCH] LibGUI: Use the correct font when relayouting Breadcrumbbar When the system is broadcasting a "system font changed" notification, the Breadcrumbbar will be notified before its button children. This means that we have to use the Breadcrumbbar's font() for calculations inside Breadcrumbbar as the buttons themselves still have the old font at this point. --- Userland/Libraries/LibGUI/Breadcrumbbar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp index 343b8b60e9..ad16f33126 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp @@ -175,7 +175,9 @@ void Breadcrumbbar::relayout() for (auto& segment : m_segments) { VERIFY(segment.button); auto& button = *segment.button; - auto button_text_width = button.font().width(segment.text); + // NOTE: We use our own font instead of the button's font here in case we're being notified about + // a system font change, and the button hasn't been notified yet. + auto button_text_width = font().width(segment.text); auto icon_width = button.icon() ? button.icon()->width() : 0; auto icon_padding = button.icon() ? 4 : 0;