From fd7a7443bc6b492503ebb79fc956b7f582be3f4b Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 17 Oct 2006 04:20:47 +0000 Subject: [PATCH] use common AllocExclusive, rather than custom code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42072 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/font.h | 3 +++ src/gtk/font.cpp | 45 ++++++++++++++++++------------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/include/wx/gtk/font.h b/include/wx/gtk/font.h index 94b5d36009..11ceb4335f 100644 --- a/include/wx/gtk/font.h +++ b/include/wx/gtk/font.h @@ -84,6 +84,9 @@ protected: // common part of all ctors void Init(); + virtual wxObjectRefData* CreateRefData() const; + virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const; + private: DECLARE_DYNAMIC_CLASS(wxFont) }; diff --git a/src/gtk/font.cpp b/src/gtk/font.cpp index 8dbe0064bd..b3983ccb8a 100644 --- a/src/gtk/font.cpp +++ b/src/gtk/font.cpp @@ -31,10 +31,7 @@ #include "wx/fontutil.h" #include "wx/tokenzr.h" -#include - #include "wx/gtk/private.h" -#include // ---------------------------------------------------------------------------- // constants @@ -392,20 +389,6 @@ bool wxFont::Create(const wxString& fontname) return true; } -void wxFont::Unshare() -{ - if (!m_refData) - { - m_refData = new wxFontRefData(); - } - else - { - wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); - UnRef(); - m_refData = ref; - } -} - wxFont::~wxFont() { } @@ -502,35 +485,35 @@ bool wxFont::IsFixedWidth() const void wxFont::SetPointSize(int pointSize) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetPointSize(pointSize); } void wxFont::SetFamily(int family) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetFamily(family); } void wxFont::SetStyle(int style) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetStyle(style); } void wxFont::SetWeight(int weight) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetWeight(weight); } bool wxFont::SetFaceName(const wxString& faceName) { - Unshare(); + AllocExclusive(); return M_FONTDATA->SetFaceName(faceName) && wxFontBase::SetFaceName(faceName); @@ -538,28 +521,38 @@ bool wxFont::SetFaceName(const wxString& faceName) void wxFont::SetUnderlined(bool underlined) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetUnderlined(underlined); } void wxFont::SetEncoding(wxFontEncoding encoding) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetEncoding(encoding); } void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo& info ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetNativeFontInfo( info ); } void wxFont::SetNoAntiAliasing( bool no ) { - Unshare(); + AllocExclusive(); M_FONTDATA->SetNoAntiAliasing( no ); } + +wxObjectRefData* wxFont::CreateRefData() const +{ + return new wxFontRefData; +} + +wxObjectRefData* wxFont::CloneRefData(const wxObjectRefData* data) const +{ + return new wxFontRefData(*wx_static_cast(const wxFontRefData*, data)); +} -- 2.45.2