X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e7600a2cabbc4d91dd53d842324eea6f5bfe3fe6..cd3c2375e6fddd3d478a6776900c21aaeb2d0f08:/src/mac/region.cpp diff --git a/src/mac/region.cpp b/src/mac/region.cpp index 16d033004c..b4dddad04b 100644 --- a/src/mac/region.cpp +++ b/src/mac/region.cpp @@ -302,26 +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_rects(iterator.m_rects) + , m_numRects(0) + , m_rects(NULL) { + 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 */ @@ -337,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;