use AllocExclusive

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44607 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2007-03-05 06:41:04 +00:00
parent 86033c4b6f
commit f08b7bec7f
2 changed files with 18 additions and 23 deletions

View File

@@ -99,9 +99,9 @@ public:
void* MacGetATSUStyle() const ; void* MacGetATSUStyle() const ;
protected: protected:
void Unshare(); virtual wxObjectRefData* CreateRefData() const;
virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
private:
DECLARE_DYNAMIC_CLASS(wxFont) DECLARE_DYNAMIC_CLASS(wxFont)
}; };

View File

@@ -266,7 +266,7 @@ void wxFontRefData::MacFindFont()
m_macFontFamily = FMGetFontFamilyFromName( qdFontName ); m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
if ( m_macFontFamily == kInvalidFontFamily ) 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(); m_macFontFamily = GetAppFont();
} }
#endif #endif
@@ -444,31 +444,26 @@ bool wxFont::RealizeResource()
void wxFont::SetEncoding(wxFontEncoding encoding) void wxFont::SetEncoding(wxFontEncoding encoding)
{ {
Unshare(); AllocExclusive();
M_FONTDATA->m_encoding = encoding; M_FONTDATA->m_encoding = encoding;
RealizeResource(); RealizeResource();
} }
void wxFont::Unshare() wxObjectRefData* wxFont::CreateRefData() const
{ {
// Don't change shared data return new wxFontRefData;
if (!m_refData) }
{
m_refData = new wxFontRefData(); wxObjectRefData* wxFont::CloneRefData(const wxObjectRefData* data) const
} {
else return new wxFontRefData(*wx_static_cast(const wxFontRefData*, data));
{
wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
UnRef();
m_refData = ref;
}
} }
void wxFont::SetPointSize(int pointSize) void wxFont::SetPointSize(int pointSize)
{ {
Unshare(); AllocExclusive();
M_FONTDATA->m_pointSize = pointSize; M_FONTDATA->m_pointSize = pointSize;
@@ -477,7 +472,7 @@ void wxFont::SetPointSize(int pointSize)
void wxFont::SetFamily(int family) void wxFont::SetFamily(int family)
{ {
Unshare(); AllocExclusive();
M_FONTDATA->m_family = family; M_FONTDATA->m_family = family;
@@ -486,7 +481,7 @@ void wxFont::SetFamily(int family)
void wxFont::SetStyle(int style) void wxFont::SetStyle(int style)
{ {
Unshare(); AllocExclusive();
M_FONTDATA->m_style = style; M_FONTDATA->m_style = style;
@@ -495,7 +490,7 @@ void wxFont::SetStyle(int style)
void wxFont::SetWeight(int weight) void wxFont::SetWeight(int weight)
{ {
Unshare(); AllocExclusive();
M_FONTDATA->m_weight = weight; M_FONTDATA->m_weight = weight;
@@ -504,7 +499,7 @@ void wxFont::SetWeight(int weight)
bool wxFont::SetFaceName(const wxString& faceName) bool wxFont::SetFaceName(const wxString& faceName)
{ {
Unshare(); AllocExclusive();
M_FONTDATA->m_faceName = faceName; M_FONTDATA->m_faceName = faceName;
@@ -515,7 +510,7 @@ bool wxFont::SetFaceName(const wxString& faceName)
void wxFont::SetUnderlined(bool underlined) void wxFont::SetUnderlined(bool underlined)
{ {
Unshare(); AllocExclusive();
M_FONTDATA->m_underlined = underlined; M_FONTDATA->m_underlined = underlined;
@@ -524,7 +519,7 @@ void wxFont::SetUnderlined(bool underlined)
void wxFont::SetNoAntiAliasing( bool no ) void wxFont::SetNoAntiAliasing( bool no )
{ {
Unshare(); AllocExclusive();
M_FONTDATA->SetNoAntiAliasing( no ); M_FONTDATA->SetNoAntiAliasing( no );