X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/61a0b9059a22e0f8b16e4396d0f8cbf49f31998f..677dc0ed1a3ff68af15f6246d6d0708d5264b07a:/src/mac/carbon/brush.cpp?ds=sidebyside diff --git a/src/mac/carbon/brush.cpp b/src/mac/carbon/brush.cpp index 88c588f67a..3c91757ec9 100644 --- a/src/mac/carbon/brush.cpp +++ b/src/mac/carbon/brush.cpp @@ -23,7 +23,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) class WXDLLEXPORT wxBrushRefData: public wxGDIRefData { - friend class WXDLLEXPORT wxBrush; + friend class wxBrush; public: wxBrushRefData(); @@ -122,19 +122,24 @@ wxBrush::wxBrush( ThemeBrush macThemeBrush ) RealizeResource(); } -wxObjectRefData* wxBrush::CreateRefData() const +void wxBrush::Unshare() { - return new wxBrushRefData; -} - -wxObjectRefData* wxBrush::CloneRefData(const wxObjectRefData* data) const -{ - return new wxBrushRefData(*wx_static_cast(const wxBrushRefData*, data)); + // Don't change shared data + if (!m_refData) + { + m_refData = new wxBrushRefData(); + } + else + { + wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData); + UnRef(); + m_refData = ref; + } } void wxBrush::SetColour(const wxColour& col) { - AllocExclusive(); + Unshare(); M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour; M_BRUSHDATA->m_colour = col; @@ -143,7 +148,7 @@ void wxBrush::SetColour(const wxColour& col) void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) { - AllocExclusive(); + Unshare(); M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour; M_BRUSHDATA->m_colour.Set(r, g, b); @@ -153,7 +158,7 @@ void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) void wxBrush::SetStyle(int Style) { - AllocExclusive(); + Unshare(); M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour; M_BRUSHDATA->m_style = Style; @@ -163,7 +168,7 @@ void wxBrush::SetStyle(int Style) void wxBrush::SetStipple(const wxBitmap& Stipple) { - AllocExclusive(); + Unshare(); M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour; M_BRUSHDATA->m_stipple = Stipple; @@ -173,7 +178,7 @@ void wxBrush::SetStipple(const wxBitmap& Stipple) void wxBrush::MacSetTheme(ThemeBrush macThemeBrush) { - AllocExclusive(); + Unshare(); M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme; M_BRUSHDATA->m_macThemeBrush = macThemeBrush; @@ -187,7 +192,7 @@ void wxBrush::MacSetTheme(ThemeBrush macThemeBrush) void wxBrush::MacSetThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent) { - AllocExclusive(); + Unshare(); M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground; M_BRUSHDATA->m_macThemeBackground = macThemeBackground;