From f08b7bec7f042cc8df4be88504f50961dae36697 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Mon, 5 Mar 2007 06:41:04 +0000 Subject: [PATCH] use AllocExclusive git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44607 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/carbon/font.h | 4 ++-- src/mac/carbon/font.cpp | 37 ++++++++++++++++-------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/include/wx/mac/carbon/font.h b/include/wx/mac/carbon/font.h index d7a69df50e..5df413ba3c 100644 --- a/include/wx/mac/carbon/font.h +++ b/include/wx/mac/carbon/font.h @@ -99,9 +99,9 @@ public: void* MacGetATSUStyle() const ; protected: - void Unshare(); + virtual wxObjectRefData* CreateRefData() const; + virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const; -private: DECLARE_DYNAMIC_CLASS(wxFont) }; diff --git a/src/mac/carbon/font.cpp b/src/mac/carbon/font.cpp index 3c63ecb23b..bd90c3bdf1 100644 --- a/src/mac/carbon/font.cpp +++ b/src/mac/carbon/font.cpp @@ -266,7 +266,7 @@ void wxFontRefData::MacFindFont() m_macFontFamily = FMGetFontFamilyFromName( qdFontName ); if ( m_macFontFamily == kInvalidFontFamily ) { - wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName ); + wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName.c_str() ); m_macFontFamily = GetAppFont(); } #endif @@ -444,31 +444,26 @@ bool wxFont::RealizeResource() void wxFont::SetEncoding(wxFontEncoding encoding) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_encoding = encoding; RealizeResource(); } -void wxFont::Unshare() +wxObjectRefData* wxFont::CreateRefData() const { - // Don't change shared data - if (!m_refData) - { - m_refData = new wxFontRefData(); - } - else - { - wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); - UnRef(); - m_refData = ref; - } + return new wxFontRefData; +} + +wxObjectRefData* wxFont::CloneRefData(const wxObjectRefData* data) const +{ + return new wxFontRefData(*wx_static_cast(const wxFontRefData*, data)); } void wxFont::SetPointSize(int pointSize) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_pointSize = pointSize; @@ -477,7 +472,7 @@ void wxFont::SetPointSize(int pointSize) void wxFont::SetFamily(int family) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_family = family; @@ -486,7 +481,7 @@ void wxFont::SetFamily(int family) void wxFont::SetStyle(int style) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_style = style; @@ -495,7 +490,7 @@ void wxFont::SetStyle(int style) void wxFont::SetWeight(int weight) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_weight = weight; @@ -504,7 +499,7 @@ void wxFont::SetWeight(int weight) bool wxFont::SetFaceName(const wxString& faceName) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_faceName = faceName; @@ -515,7 +510,7 @@ bool wxFont::SetFaceName(const wxString& faceName) void wxFont::SetUnderlined(bool underlined) { - Unshare(); + AllocExclusive(); M_FONTDATA->m_underlined = underlined; @@ -524,7 +519,7 @@ void wxFont::SetUnderlined(bool underlined) void wxFont::SetNoAntiAliasing( bool no ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetNoAntiAliasing( no ); -- 2.47.2