From 966c00b930ef246d94c9b12a42d1c2b8da9eac7c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Dec 2022 00:00:02 +0100 Subject: [PATCH] Work around Wine bug with font handling in SysLink control Prevent Wine from (wrongly) deleting the font we set for the control. This avoids problems when trying to use the (unexpectedly deleted) font that was used for wxHyperlinkCtrl later. --- include/wx/msw/hyperlink.h | 1 + src/msw/hyperlink.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/wx/msw/hyperlink.h b/include/wx/msw/hyperlink.h index e33d891e12..8ffd59e374 100644 --- a/include/wx/msw/hyperlink.h +++ b/include/wx/msw/hyperlink.h @@ -43,6 +43,7 @@ public: long style = wxHL_DEFAULT_STYLE, const wxString& name = wxASCII_STR(wxHyperlinkCtrlNameStr)); + virtual ~wxHyperlinkCtrl(); // overridden base class methods // ----------------------------- diff --git a/src/msw/hyperlink.cpp b/src/msw/hyperlink.cpp index 625c830c62..3351c4bf70 100644 --- a/src/msw/hyperlink.cpp +++ b/src/msw/hyperlink.cpp @@ -112,6 +112,17 @@ bool wxHyperlinkCtrl::Create(wxWindow *parent, return true; } +wxHyperlinkCtrl::~wxHyperlinkCtrl() +{ + if ( m_hWnd ) + { + // Due to https://bugs.winehq.org/show_bug.cgi?id=54066 we have to + // reset the font before the native control destroys it. + if ( wxIsRunningUnderWine() ) + ::SendMessage(m_hWnd, WM_SETFONT, 0, FALSE); + } +} + WXDWORD wxHyperlinkCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const { WXDWORD msStyle = wxControl::MSWGetStyle( style, exstyle );