From 0572fce80ae8a94b6b5efc484377c2bb44659589 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 18 Apr 2009 12:27:31 +0000 Subject: [PATCH] initialize m_hFont in the beginning of wxFontRefData::Init() to avoid freeing invalid font handle in SetXXX() called afterwards; removed hard TABs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60235 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/font.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/msw/font.cpp b/src/msw/font.cpp index d99d2f8f64..63afba3161 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -291,7 +291,7 @@ protected: void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0); - // are we using m_nativeFontInfo.lf.lfHeight for point size or pixel size? + // are we using m_nativeFontInfo.lf.lfHeight for point size or pixel size? bool m_sizeUsingPixels; // Windows font handle, created on demand in GetHFONT() @@ -321,26 +321,26 @@ void wxFontRefData::Init(int pointSize, const wxString& faceName, wxFontEncoding encoding) { - m_sizeUsingPixels = sizeUsingPixels; - if ( m_sizeUsingPixels ) - SetPixelSize(pixelSize); - else - SetPointSize(pointSize); - - SetStyle(style); - SetWeight(weight); - SetUnderlined(underlined); - m_hFont = NULL; - // set the family/facename - SetFamily(family); - if ( !faceName.empty() ) - SetFaceName(faceName); + m_sizeUsingPixels = sizeUsingPixels; + if ( m_sizeUsingPixels ) + SetPixelSize(pixelSize); + else + SetPointSize(pointSize); - // deal with encoding now (it may override the font family and facename - // so do it after setting them) - SetEncoding(encoding); + SetStyle(style); + SetWeight(weight); + SetUnderlined(underlined); + + // set the family/facename + SetFamily(family); + if ( !faceName.empty() ) + SetFaceName(faceName); + + // deal with encoding now (it may override the font family and facename + // so do it after setting them) + SetEncoding(encoding); } void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont) @@ -511,7 +511,7 @@ void wxNativeFontInfo::SetPixelSize(const wxSize& pixelSize) // here if we get a negative height: wxCHECK_RET( pixelSize.GetWidth() >= 0 && pixelSize.GetHeight() > 0, "Negative values for the pixel size or zero pixel height are not allowed" ); - + lf.lfHeight = pixelSize.GetHeight(); lf.lfWidth = pixelSize.GetWidth(); } @@ -852,7 +852,7 @@ wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const bool wxFont::RealizeResource() { // NOTE: the GetHFONT() call automatically triggers a reallocation of - // the HFONT if necessary (will do nothing if we already have the resource); + // the HFONT if necessary (will do nothing if we already have the resource); // it returns NULL only if there is a failure in wxFontRefData::Alloc()... return GetHFONT() != NULL; }