From: Julian Smart Date: Sat, 3 May 2003 11:56:38 +0000 (+0000) Subject: Applied patch [ 731719 ] Owner draw font leak/overuse X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/19b4237945d5649633498c3e23eaf63c80f5937e Applied patch [ 731719 ] Owner draw font leak/overuse git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 6efb8e08eb..b9f3ca853f 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -104,7 +104,7 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu, : wxMenuItemBase(parentMenu, id, text, help, isCheckable ? wxITEM_CHECK : wxITEM_NORMAL, subMenu) #if wxUSE_OWNER_DRAWN - , wxOwnerDrawn(text, isCheckable) + , wxOwnerDrawn(text, isCheckable, true) #endif // owner drawn { Init(); diff --git a/src/msw/ownerdrw.cpp b/src/msw/ownerdrw.cpp index 0dc3e686f8..4baece7467 100644 --- a/src/msw/ownerdrw.cpp +++ b/src/msw/ownerdrw.cpp @@ -46,7 +46,7 @@ // ctor // ---- wxOwnerDrawn::wxOwnerDrawn(const wxString& str, - bool bCheckable, bool WXUNUSED(bMenuItem)) + bool bCheckable, bool bMenuItem) : m_strName(str) { #if defined(__WXMSW__) && defined(__WIN32__) && defined(SM_CXMENUCHECK) @@ -64,9 +64,23 @@ wxOwnerDrawn::wxOwnerDrawn(const wxString& str, ms_nLastMarginWidth = nm.iMenuWidth; } - wxNativeFontInfo info; - memcpy(&info.lf, &nm.lfMenuFont, sizeof(LOGFONT)); - m_font.Create(info); + if (bMenuItem) + { + static wxFont menu_font; + if (!menu_font.Ok()) + { + // create menu font + wxNativeFontInfo info; + memcpy(&info.lf, &nm.lfMenuFont, sizeof(LOGFONT)); + menu_font.Create(info); + } + + m_font = menu_font; + } + else + { + m_font = *wxNORMAL_FONT; + } #else // windows clean install default m_nMinHeight = 18;