Browse Source

Optimizing adjusting to updated system font in attempt for fix Bug 2149: Failure/Hang when system settings change

https://winscp.net/tracker/2149

Source commit: cf7739f920af457e0cde9314b421c344c9681bdc
Martin Prikryl 2 years ago
parent
commit
8aaf8ab4a4
1 changed files with 7 additions and 3 deletions
  1. 7 3
      source/windows/VCLCommon.cpp

+ 7 - 3
source/windows/VCLCommon.cpp

@@ -2706,10 +2706,14 @@ void TDesktopFontManager::UpdateControl(TControl * Control)
 
   // Neither CreateFontIndirect nor RestoreFont set  color, so we should should have the default set by TFont constructor here.
   DebugAssert(DesktopFont->Color == clWindowText);
-  // Preserve color (particularly white color of file panel font in dark mode)
-  DesktopFont->Color = PublicControl->Font->Color;
+  if (!SameFont(DesktopFont.get(), PublicControl->Font) ||
+      (DesktopFont->PixelsPerInch != PublicControl->Font->PixelsPerInch))
+  {
+    // Preserve color (particularly white color of file panel font in dark mode)
+    DesktopFont->Color = PublicControl->Font->Color;
 
-  PublicControl->Font->Assign(DesktopFont.get());
+    PublicControl->Font->Assign(DesktopFont.get());
+  }
 }
 //---------------------------------------------------------------------------
 void TDesktopFontManager::AddControl(TControl * Control)