summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-09 09:14:12 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-13 08:17:00 +0000
commitac8a3b948da1980bc59bae3fc76d20b5b45662a0 (patch)
treef08eed7df003491d742190f9eeb5a2fb06518ae5 /src/gui/painting
parent9915630d0886434e8984904b1cadedc81dc78ca0 (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/painting')
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp4
-rw-r--r--src/gui/painting/qregion.cpp4
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp6
3 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index fb44a7aeb1..9d981dcc2c 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -3610,7 +3610,7 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
{
Q_ASSERT(image.depth() == 1);
- QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB);
+ const QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB);
QImage dest = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied);
QRgb fg = qPremultiply(color.rgba());
@@ -3619,7 +3619,7 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
int height = sourceImage.height();
int width = sourceImage.width();
for (int y=0; y<height; ++y) {
- uchar *source = sourceImage.scanLine(y);
+ const uchar *source = sourceImage.constScanLine(y);
QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y));
if (!source || !target)
QT_THROW(std::bad_alloc()); // we must have run out of memory
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index 5e648eabf5..757c78cec8 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -3735,7 +3735,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
QRegionPrivate *qt_bitmapToRegion(const QBitmap& bitmap)
{
- QImage image = bitmap.toImage();
+ const QImage image = bitmap.toImage();
QRegionPrivate *region = new QRegionPrivate;
@@ -3753,7 +3753,7 @@ QRegionPrivate *qt_bitmapToRegion(const QBitmap& bitmap)
int x,
y;
for (y = 0; y < image.height(); ++y) {
- uchar *line = image.scanLine(y);
+ const uchar *line = image.constScanLine(y);
int w = image.width();
uchar all = zero;
int prev1 = -1;
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 97f82d16d3..20039d902a 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -339,7 +339,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
uchar *dest = d + (c.y + y) *dbpl + c.x/8;
if (y < mh) {
- uchar *src = mask.scanLine(y);
+ const uchar *src = mask.constScanLine(y);
for (int x = 0; x < c.w/8; ++x) {
if (x < (mw+7)/8)
dest[x] = src[x];
@@ -361,7 +361,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
for (int y = 0; y < c.h; ++y) {
uchar *dest = d + (c.y + y) *dbpl + c.x;
if (y < mh) {
- uchar *src = (uchar *) mask.scanLine(y);
+ const uchar *src = mask.constScanLine(y);
for (int x = 0; x < c.w; ++x) {
if (x < mw)
dest[x] = (src[x >> 3] & (1 << (7 - (x & 7)))) > 0 ? 255 : 0;
@@ -372,7 +372,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP
for (int y = 0; y < c.h; ++y) {
uchar *dest = d + (c.y + y) *dbpl + c.x;
if (y < mh) {
- uchar *src = (uchar *) mask.scanLine(y);
+ const uchar *src = mask.constScanLine(y);
for (int x = 0; x < c.w; ++x) {
if (x < mw)
dest[x] = src[x];