diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-06-19 17:36:10 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-26 11:57:51 +0200 |
commit | 799f0841a6f22ccaa03f3673ba91ad7b40f20612 (patch) | |
tree | 47ccd347ca2f416c4d3dbde98992e9f5d09997e6 /src/gui/painting | |
parent | 34cb86d46b5cebed14bbb8c5e4143447025e9094 (diff) |
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>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qregion.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index d13389e602..357380e2d8 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -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>(); |