From 6738f908f9f414d44c318057a23d4bce7dc0f178 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 May 2014 14:08:45 +0000 Subject: [PATCH] Don't destroy wxFont from its GetFaceName() in wxMSW. wxFont::GetFaceName() could destroy the HFONT used by the font accidentally, avoid it by not invalidating the font when caching its face name. Closes #16273. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/font.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 34683325ad..f20c778039 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -661,6 +661,7 @@ wxMSW: - Don't fail when using large paper sizes in print preview. - Fix wxRichMessageDialog return value for dialog with only "OK" button. - Fix precision loss in wxGraphicsContext::{Draw,Stroke}Lines() (tibo_). +- Fix destroying the font from wxFont::GetFaceName() in some cases (aebailey82). wxOSX: diff --git a/src/msw/font.cpp b/src/msw/font.cpp index bbf7d849a6..6c747e821e 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -149,7 +149,8 @@ public: { // cache the face name, it shouldn't change unless the family // does and wxNativeFontInfo::SetFamily() resets the face name - const_cast(this)->SetFaceName(facename); + // Don't call this->SetFaceName(), because it deletes the HFONT. + const_cast(m_nativeFontInfo).SetFaceName(facename); } }