Make QRegion not need to be friends with QVector

This hack was introduced in Qt 4.5 and the intention was to resize
(hopefully, shrink) the QVector without causing it to reallocate
memory. We can accomplish the same by reserving the size: until we
clear() or squeeze(), the container will not free memory.

Change-Id: I03a09537a617be0ce865eefa043005e4051e8706
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Thiago Macieira 2012-06-19 17:36:10 +02:00 committed by Qt by Nokia
parent 34cb86d46b
commit 799f0841a6

View File

@ -4206,9 +4206,8 @@ QVector<QRect> QRegion::rects() const
{
if (d->qt_rgn) {
d->qt_rgn->vectorize();
// hw: modify the vector size directly to avoid reallocation
if (d->qt_rgn->rects.d != QVector<QRect>::Data::sharedNull())
d->qt_rgn->rects.d->size = d->qt_rgn->numRects;
d->qt_rgn->rects.reserve(d->qt_rgn->numRects);
d->qt_rgn->rects.resize(d->qt_rgn->numRects);
return d->qt_rgn->rects;
} else {
return QVector<QRect>();