diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-02-09 09:14:12 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-02-13 08:17:00 +0000 |
commit | ac8a3b948da1980bc59bae3fc76d20b5b45662a0 (patch) | |
tree | f08eed7df003491d742190f9eeb5a2fb06518ae5 /src/gui/image/qxpmhandler.cpp | |
parent | 9915630d0886434e8984904b1cadedc81dc78ca0 (diff) |
QtGui: Use QImage::constBits()/constScanLine() in non-const contexts.
Prevent potential detaching by using constBits()/constScanLine() instead
of bits()/scanLine().
Change-Id: If03f8d4d3b8ed4c07aed5eff7f580e57ca771919
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/gui/image/qxpmhandler.cpp')
-rw-r--r-- | src/gui/image/qxpmhandler.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index e9ac4a9cc2..fbce78eb74 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1098,7 +1098,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const // build color table for(y=0; y<h; y++) { - QRgb * yp = (QRgb *)image.scanLine(y); + const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y)); for(x=0; x<w; x++) { QRgb color = *(yp + x); if (!colorMap.contains(color)) @@ -1144,7 +1144,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const // write pixels, limit to 4 characters per pixel line.truncate(cpp*w); for(y=0; y<h; y++) { - QRgb * yp = (QRgb *) image.scanLine(y); + const QRgb *yp = reinterpret_cast<const QRgb *>(image.constScanLine(y)); int cc = 0; for(x=0; x<w; x++) { int color = (int)(*(yp + x)); |