applied copy constructor fix to assignment operator as well

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15569 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Gilles Depeyrot 2002-05-15 06:22:01 +00:00
parent d18c7c6dfc
commit 6dcbb6d0d9
3 changed files with 74 additions and 44 deletions

View File

@ -128,13 +128,13 @@ public:
~wxRegionIterator();
wxRegionIterator& operator=(const wxRegionIterator& iterator);
void Reset() { m_current = 0; }
void Reset(const wxRegion& region);
operator bool () const { return m_current < m_numRects; }
bool HaveRects() const { return m_current < m_numRects; }
wxRegionIterator& operator++();
wxRegionIterator operator++(int);
@ -146,6 +146,8 @@ public:
long GetHeight() const { return GetH(); }
wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
private:
void SetRects(long numRects, wxRect *rects);
long m_current;
long m_numRects;
wxRegion m_region;

View File

@ -302,33 +302,47 @@ wxRegionIterator::wxRegionIterator()
wxRegionIterator::~wxRegionIterator()
{
if (m_rects)
if (m_rects) {
delete[] m_rects;
m_rects = NULL;
}
}
wxRegionIterator::wxRegionIterator(const wxRegionIterator& iterator)
: wxObject()
, m_current(iterator.m_current)
, m_numRects(iterator.m_numRects)
, m_numRects(0)
, m_rects(NULL)
{
int i;
if (iterator.m_rects)
{
m_rects = new wxRect[iterator.m_numRects];
for (i = 0; i < iterator.m_numRects; i++)
m_rects[i] = iterator.m_rects[i];
}
SetRects(iterator.m_numRects, iterator.m_rects);
}
wxRegionIterator& wxRegionIterator::operator=(const wxRegionIterator& iterator)
{
m_current = iterator.m_current;
m_numRects = iterator.m_numRects;
m_rects = iterator.m_rects;
SetRects(iterator.m_numRects, iterator.m_rects);
return *this;
}
/*!
* Set iterator rects for region
*/
void wxRegionIterator::SetRects(long numRects, wxRect *rects)
{
if (m_rects) {
delete[] m_rects;
m_rects = NULL;
}
if (rects)
{
int i;
m_rects = new wxRect[numRects];
for (i = 0; i < numRects; i++)
m_rects[i] = rects[i];
}
m_numRects = numRects;
}
/*!
* Initialize iterator for region
*/
@ -344,22 +358,22 @@ wxRegionIterator::wxRegionIterator(const wxRegion& region)
*/
void wxRegionIterator::Reset(const wxRegion& region)
{
m_current = 0;
m_region = region;
m_current = 0;
m_region = region;
if (m_rects)
if (m_rects) {
delete[] m_rects;
m_rects = NULL;
}
m_rects = NULL;
if (m_region.Empty())
m_numRects = 0;
else
if (m_region.Empty())
m_numRects = 0;
else
{
// we cannot dissolve it into rects on mac
m_rects = new wxRect[1];
Rect rect ;
GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
Rect rect ;
GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
m_rects[0].x = rect.left;
m_rects[0].y = rect.top;
m_rects[0].width = rect.right - rect.left;

View File

@ -302,33 +302,47 @@ wxRegionIterator::wxRegionIterator()
wxRegionIterator::~wxRegionIterator()
{
if (m_rects)
if (m_rects) {
delete[] m_rects;
m_rects = NULL;
}
}
wxRegionIterator::wxRegionIterator(const wxRegionIterator& iterator)
: wxObject()
, m_current(iterator.m_current)
, m_numRects(iterator.m_numRects)
, m_numRects(0)
, m_rects(NULL)
{
int i;
if (iterator.m_rects)
{
m_rects = new wxRect[iterator.m_numRects];
for (i = 0; i < iterator.m_numRects; i++)
m_rects[i] = iterator.m_rects[i];
}
SetRects(iterator.m_numRects, iterator.m_rects);
}
wxRegionIterator& wxRegionIterator::operator=(const wxRegionIterator& iterator)
{
m_current = iterator.m_current;
m_numRects = iterator.m_numRects;
m_rects = iterator.m_rects;
SetRects(iterator.m_numRects, iterator.m_rects);
return *this;
}
/*!
* Set iterator rects for region
*/
void wxRegionIterator::SetRects(long numRects, wxRect *rects)
{
if (m_rects) {
delete[] m_rects;
m_rects = NULL;
}
if (rects)
{
int i;
m_rects = new wxRect[numRects];
for (i = 0; i < numRects; i++)
m_rects[i] = rects[i];
}
m_numRects = numRects;
}
/*!
* Initialize iterator for region
*/
@ -344,22 +358,22 @@ wxRegionIterator::wxRegionIterator(const wxRegion& region)
*/
void wxRegionIterator::Reset(const wxRegion& region)
{
m_current = 0;
m_region = region;
m_current = 0;
m_region = region;
if (m_rects)
if (m_rects) {
delete[] m_rects;
m_rects = NULL;
}
m_rects = NULL;
if (m_region.Empty())
m_numRects = 0;
else
if (m_region.Empty())
m_numRects = 0;
else
{
// we cannot dissolve it into rects on mac
m_rects = new wxRect[1];
Rect rect ;
GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
Rect rect ;
GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
m_rects[0].x = rect.left;
m_rects[0].y = rect.top;
m_rects[0].width = rect.right - rect.left;