X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2012e3ea0f59ad68e129331d4853697b0efd9a3e..bf60426831535738b1b784629f08e9dd00bf9ecc:/src/mac/carbon/region.cpp?ds=sidebyside diff --git a/src/mac/carbon/region.cpp b/src/mac/carbon/region.cpp index c8ffc4632b..b4dddad04b 100644 --- a/src/mac/carbon/region.cpp +++ b/src/mac/carbon/region.cpp @@ -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;