]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 731719 ] Owner draw font leak/overuse
authorJulian Smart <julian@anthemion.co.uk>
Sat, 3 May 2003 11:56:38 +0000 (11:56 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sat, 3 May 2003 11:56:38 +0000 (11:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/menuitem.cpp
src/msw/ownerdrw.cpp

index 6efb8e08ebc4987530bd5cae9e5bcdd3c77ff719..b9f3ca853fd7b25f93c8fc0427e9d7ca0625c142 100644 (file)
@@ -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();
index 0dc3e686f850d5d6830e1be0c43e7f30cdb4d1c9..4baece74673ccc6d2874b56636c8213197475141 100644 (file)
@@ -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;