From 7c310bc89f51fa0acd64de7e8396637beba1bc7a Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sat, 10 Mar 2007 23:00:52 +0000 Subject: [PATCH] use AllocExclusive git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44743 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/pen.h | 6 ++++-- src/msw/pen.cpp | 35 +++++++++++++++-------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/include/wx/msw/pen.h b/include/wx/msw/pen.h index 470d92c6dc..a93635e411 100644 --- a/include/wx/msw/pen.h +++ b/include/wx/msw/pen.h @@ -123,9 +123,11 @@ public: bool FreeResource(bool force = false); WXHANDLE GetResourceHandle() const; bool IsFree() const; - void Unshare(); -private: +protected: + virtual wxObjectRefData* CreateRefData() const; + virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const; + DECLARE_DYNAMIC_CLASS(wxPen) }; diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp index 92b08327a6..75fe263992 100644 --- a/src/msw/pen.cpp +++ b/src/msw/pen.cpp @@ -270,24 +270,19 @@ bool wxPen::IsFree() const return (M_PENDATA && M_PENDATA->m_hPen == 0); } -void wxPen::Unshare() +wxObjectRefData* wxPen::CreateRefData() const { - // Don't change shared data - if (!m_refData) - { - m_refData = new wxPenRefData(); - } - else - { - wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); - UnRef(); - m_refData = ref; - } + return new wxFontRefData; +} + +wxObjectRefData* wxPen::CloneRefData(const wxObjectRefData* data) const +{ + return new wxFontRefData(*wx_static_cast(const wxPenRefData*, data)); } void wxPen::SetColour(const wxColour& col) { - Unshare(); + AllocExclusive(); M_PENDATA->m_colour = col; @@ -296,7 +291,7 @@ void wxPen::SetColour(const wxColour& col) void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) { - Unshare(); + AllocExclusive(); M_PENDATA->m_colour.Set(r, g, b); @@ -305,7 +300,7 @@ void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) void wxPen::SetWidth(int Width) { - Unshare(); + AllocExclusive(); M_PENDATA->m_width = Width; @@ -314,7 +309,7 @@ void wxPen::SetWidth(int Width) void wxPen::SetStyle(int Style) { - Unshare(); + AllocExclusive(); M_PENDATA->m_style = Style; @@ -323,7 +318,7 @@ void wxPen::SetStyle(int Style) void wxPen::SetStipple(const wxBitmap& Stipple) { - Unshare(); + AllocExclusive(); M_PENDATA->m_stipple = Stipple; M_PENDATA->m_style = wxSTIPPLE; @@ -333,7 +328,7 @@ void wxPen::SetStipple(const wxBitmap& Stipple) void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) { - Unshare(); + AllocExclusive(); M_PENDATA->m_nbDash = nb_dashes; M_PENDATA->m_dash = (wxDash *)Dash; @@ -343,7 +338,7 @@ void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) void wxPen::SetJoin(int Join) { - Unshare(); + AllocExclusive(); M_PENDATA->m_join = Join; @@ -352,7 +347,7 @@ void wxPen::SetJoin(int Join) void wxPen::SetCap(int Cap) { - Unshare(); + AllocExclusive(); M_PENDATA->m_cap = Cap; -- 2.45.2