From 6011e8a9eb828d5ce5ffde3d88253a4871693599 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 5 Jul 2017 14:51:13 +0200 Subject: [PATCH] QRegion: explain why there's an apparently unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable is there to work around an aliasing issue. Since this code is likely coming straight from Qt 2 or 3, I'm not doing any major modification, just explaining why that variable is necessary and mark it as unused (so that a static analyzer that knows about value classes won't complain that we're creating a QVector without using it). Change-Id: Ie8777563724ec3c0bf97d8bc24e1b184fe26bd2f Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Sérgio Martins --- src/gui/painting/qregion.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 3fb6f925b3d..ba8defbfe3c 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -2281,7 +2281,14 @@ static void miRegionOp(QRegionPrivate &dest, dest.vectorize(); - QVector oldRects = dest.rects; + /* + * The following calls are going to detach dest.rects. Since dest might be + * aliasing *reg1 and/or *reg2, and we could have active iterators on + * reg1->rects and reg2->rects (if the regions have more than 1 rectangle), + * take a copy of dest.rects to keep those iteractors valid. + */ + const QVector destRectsCopy = dest.rects; + Q_UNUSED(destRectsCopy); dest.numRects = 0;