Fix rectangles bug.

This commit is contained in:
2025-08-09 04:58:51 -04:00
parent 905fdbf0dd
commit 33cb7db2dd

View File

@ -231,8 +231,14 @@ void Region::addRectangle (Rectangle *rPointer)
auto r= std::make_unique< Rectangle >( rPointer->x, rPointer->y,
rPointer->width, rPointer->height );
for( auto &ownRect: rectangleList )
for( auto it= rectangleList.begin(); it != rectangleList.end(); )
{
// We have to increment immediately. The removal of the element, near the bottom
// of this loop will invalidate any iterators pointing into the rectangleList at
// that position. A range-based for loop will increment the iterator after the
// current pass, which would cause crashes.
auto &ownRect= *it++;
int combinedHeight =
misc::max(r->y + r->height, ownRect->y + ownRect->height) -
misc::min(r->y, ownRect->y);