X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/61a0b9059a22e0f8b16e4396d0f8cbf49f31998f..9d5507f7a2701395e1d5c121bd877bb9066ee6ea:/src/mac/carbon/pen.cpp diff --git a/src/mac/carbon/pen.cpp b/src/mac/carbon/pen.cpp index 9812f009aa..7f0acfebe5 100644 --- a/src/mac/carbon/pen.cpp +++ b/src/mac/carbon/pen.cpp @@ -86,19 +86,24 @@ wxPen::wxPen(const wxBitmap& stipple, int Width) RealizeResource(); } -wxObjectRefData* wxPen::CreateRefData() const +void wxPen::Unshare() { - return new wxPenRefData; -} - -wxObjectRefData* wxPen::CloneRefData(const wxObjectRefData* data) const -{ - return new wxPenRefData(*wx_static_cast(const wxPenRefData*, data)); + // Don't change shared data + if (!m_refData) + { + m_refData = new wxPenRefData(); + } + else + { + wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); + UnRef(); + m_refData = ref; + } } void wxPen::SetColour(const wxColour& col) { - AllocExclusive(); + Unshare(); M_PENDATA->m_colour = col; @@ -107,7 +112,7 @@ void wxPen::SetColour(const wxColour& col) void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) { - AllocExclusive(); + Unshare(); M_PENDATA->m_colour.Set(r, g, b); @@ -116,7 +121,7 @@ void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) void wxPen::SetWidth(int Width) { - AllocExclusive(); + Unshare(); M_PENDATA->m_width = Width; @@ -125,7 +130,7 @@ void wxPen::SetWidth(int Width) void wxPen::SetStyle(int Style) { - AllocExclusive(); + Unshare(); M_PENDATA->m_style = Style; @@ -134,7 +139,7 @@ void wxPen::SetStyle(int Style) void wxPen::SetStipple(const wxBitmap& Stipple) { - AllocExclusive(); + Unshare(); M_PENDATA->m_stipple = Stipple; M_PENDATA->m_style = wxSTIPPLE; @@ -144,7 +149,7 @@ void wxPen::SetStipple(const wxBitmap& Stipple) void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) { - AllocExclusive(); + Unshare(); M_PENDATA->m_nbDash = nb_dashes; M_PENDATA->m_dash = (wxDash *)Dash; @@ -154,7 +159,7 @@ void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) void wxPen::SetJoin(int Join) { - AllocExclusive(); + Unshare(); M_PENDATA->m_join = Join; @@ -163,7 +168,7 @@ void wxPen::SetJoin(int Join) void wxPen::SetCap(int Cap) { - AllocExclusive(); + Unshare(); M_PENDATA->m_cap = Cap;