From e0f0b19775b1d04f6f356b1a3edb30d4b845e649 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 4 Feb 2002 10:42:16 +0000 Subject: [PATCH] Ref counting fixes and compile fixes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/region.h | 4 ++++ include/wx/gtk1/region.h | 4 ++++ src/common/object.cpp | 2 +- src/gtk/region.cpp | 12 ++++++++++++ src/gtk1/region.cpp | 12 ++++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/wx/gtk/region.h b/include/wx/gtk/region.h index d98a1f9cff..63d7f35896 100644 --- a/include/wx/gtk/region.h +++ b/include/wx/gtk/region.h @@ -115,6 +115,10 @@ public: GdkRegion *GetRegion() const; protected: + // ref counting code + virtual wxObjectRefData *CreateRefData() const; + virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; + // common part of ctors for a rectangle region void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h); diff --git a/include/wx/gtk1/region.h b/include/wx/gtk1/region.h index d98a1f9cff..63d7f35896 100644 --- a/include/wx/gtk1/region.h +++ b/include/wx/gtk1/region.h @@ -115,6 +115,10 @@ public: GdkRegion *GetRegion() const; protected: + // ref counting code + virtual wxObjectRefData *CreateRefData() const; + virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; + // common part of ctors for a rectangle region void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h); diff --git a/src/common/object.cpp b/src/common/object.cpp index 96f54f4277..1fe178f04f 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -282,7 +282,7 @@ wxObjectRefData *wxObject::CreateRefData() const return NULL; } -wxObjectRefData *wxObject::CloneRefData(wxObjectRefData * WXUNUSED(data)) const +wxObjectRefData *wxObject::CloneRefData(const wxObjectRefData * WXUNUSED(data)) const { // if you use AllocExclusive() you must override this method wxFAIL_MSG( _T("CloneRefData() must be overridden if called!") ); diff --git a/src/gtk/region.cpp b/src/gtk/region.cpp index b446807937..c0a7af603f 100644 --- a/src/gtk/region.cpp +++ b/src/gtk/region.cpp @@ -168,8 +168,18 @@ wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle ) wxRegion::~wxRegion() { + // m_refData unrefed in ~wxObject } +wxObjectRefData *wxRegion::CreateRefData() const +{ + return new wxRegionRefData; +} + +wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const +{ + return new wxRegionRefData(*(wxRegionRefData *)data); +} // ---------------------------------------------------------------------------- // wxRegion comparison // ---------------------------------------------------------------------------- @@ -202,6 +212,7 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) rect.y = y; rect.width = width; rect.height = height; + if (!m_refData) { m_refData = new wxRegionRefData(); @@ -277,6 +288,7 @@ bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::Intersect( const wxRect& rect ) { wxRegion reg( rect ); + return Intersect( reg ); } diff --git a/src/gtk1/region.cpp b/src/gtk1/region.cpp index b446807937..c0a7af603f 100644 --- a/src/gtk1/region.cpp +++ b/src/gtk1/region.cpp @@ -168,8 +168,18 @@ wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle ) wxRegion::~wxRegion() { + // m_refData unrefed in ~wxObject } +wxObjectRefData *wxRegion::CreateRefData() const +{ + return new wxRegionRefData; +} + +wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const +{ + return new wxRegionRefData(*(wxRegionRefData *)data); +} // ---------------------------------------------------------------------------- // wxRegion comparison // ---------------------------------------------------------------------------- @@ -202,6 +212,7 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) rect.y = y; rect.width = width; rect.height = height; + if (!m_refData) { m_refData = new wxRegionRefData(); @@ -277,6 +288,7 @@ bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::Intersect( const wxRect& rect ) { wxRegion reg( rect ); + return Intersect( reg ); } -- 2.47.2