]> git.saurik.com Git - wxWidgets.git/commitdiff
revert use of AllocExclusive
authorPaul Cornett <paulcor@bullseye.com>
Wed, 21 Mar 2007 04:29:57 +0000 (04:29 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Wed, 21 Mar 2007 04:29:57 +0000 (04:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mac/carbon/brush.h
include/wx/mac/carbon/font.h
include/wx/mac/carbon/pen.h
src/mac/carbon/brush.cpp
src/mac/carbon/font.cpp
src/mac/carbon/pen.cpp

index 937109c915d02cd48e58ab8ec63432091802a1a9..90ac01b9fe6923d0669bbaf745341d6ae69a8861 100644 (file)
@@ -64,9 +64,8 @@ public:
     // Useful helper: create the brush resource
     bool RealizeResource();
 
-protected:
-    virtual wxObjectRefData* CreateRefData() const;
-    virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
+private:
+    void Unshare();
 };
 
 #endif
index 5df413ba3caa85b95ac12ddabaa06ebb47cea884..2113b7570981b7c165a7cae8ed232ccfdf172996 100644 (file)
@@ -98,9 +98,8 @@ public:
     // Returns an ATSUStyle not ATSUStyle*
     void* MacGetATSUStyle() const ; 
     
-protected:
-    virtual wxObjectRefData* CreateRefData() const;
-    virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
+private:
+    void Unshare();
 
     DECLARE_DYNAMIC_CLASS(wxFont)
 };
index 6603b40069c276a918abdcb06763017761cf7609..8da9153e2311e6de06a3a530d897e6690f4a7790 100644 (file)
@@ -108,9 +108,8 @@ public:
   // Useful helper: create the brush resource
   bool RealizeResource();
 
-protected:
-    virtual wxObjectRefData* CreateRefData() const;
-    virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
+private:
+    void Unshare();
 };
 
 #endif
index 88c588f67a16f1c8a80f112105c4ebbe5e508c33..74e83ebd7753ebe5bfb11563fce675985a89e5e9 100644 (file)
@@ -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;
index bd90c3bdf1ea5a0db12059eb8e0889bb326785de..77a08d785554528eb563b5c06c8d2ca9edd28d6f 100644 (file)
@@ -444,26 +444,31 @@ bool wxFont::RealizeResource()
 
 void wxFont::SetEncoding(wxFontEncoding encoding)
 {
-    AllocExclusive();
+    Unshare();
 
     M_FONTDATA->m_encoding = encoding;
 
     RealizeResource();
 }
 
-wxObjectRefData* wxFont::CreateRefData() const
+void wxFont::Unshare()
 {
-    return new wxFontRefData;
-}
-
-wxObjectRefData* wxFont::CloneRefData(const wxObjectRefData* data) const
-{
-    return new wxFontRefData(*wx_static_cast(const wxFontRefData*, data));
+    // Don't change shared data
+    if (!m_refData)
+    {
+        m_refData = new wxFontRefData();
+    }
+    else
+    {
+        wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
+        UnRef();
+        m_refData = ref;
+    }
 }
 
 void wxFont::SetPointSize(int pointSize)
 {
-    AllocExclusive();
+    Unshare();
 
     M_FONTDATA->m_pointSize = pointSize;
 
@@ -472,7 +477,7 @@ void wxFont::SetPointSize(int pointSize)
 
 void wxFont::SetFamily(int family)
 {
-    AllocExclusive();
+    Unshare();
 
     M_FONTDATA->m_family = family;
 
@@ -481,7 +486,7 @@ void wxFont::SetFamily(int family)
 
 void wxFont::SetStyle(int style)
 {
-    AllocExclusive();
+    Unshare();
 
     M_FONTDATA->m_style = style;
 
@@ -490,7 +495,7 @@ void wxFont::SetStyle(int style)
 
 void wxFont::SetWeight(int weight)
 {
-    AllocExclusive();
+    Unshare();
 
     M_FONTDATA->m_weight = weight;
 
@@ -499,7 +504,7 @@ void wxFont::SetWeight(int weight)
 
 bool wxFont::SetFaceName(const wxString& faceName)
 {
-    AllocExclusive();
+    Unshare();
 
     M_FONTDATA->m_faceName = faceName;
 
@@ -510,7 +515,7 @@ bool wxFont::SetFaceName(const wxString& faceName)
 
 void wxFont::SetUnderlined(bool underlined)
 {
-    AllocExclusive();
+    Unshare();
 
     M_FONTDATA->m_underlined = underlined;
 
@@ -519,7 +524,7 @@ void wxFont::SetUnderlined(bool underlined)
 
 void wxFont::SetNoAntiAliasing( bool no )
 {
-    AllocExclusive();
+    Unshare();
 
     M_FONTDATA->SetNoAntiAliasing( no );
 
index 9812f009aa85d2d7836cdff60ecef09e2471fd71..7f0acfebe5349bf668a4bd69535537e51519fc6c 100644 (file)
@@ -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;