diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 5cfa9d07f..86096022b 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1167,9 +1167,11 @@ QImage QImage::copy(const QRect& r) const if (image.d->nbytes != d->nbytes) { int bpl = qMin(bytesPerLine(), image.bytesPerLine()); for (int i = 0; i < height(); i++) - memcpy(image.scanLine(i), scanLine(i), bpl); - } else - memcpy(image.bits(), bits(), d->nbytes); + memcpy(image.scanLine(i), constScanLine(i), bpl); + } else { + // using bits() to detach + memcpy(image.bits(), d->data, d->nbytes); + } image.d->colortable = d->colortable; image.d->dpmx = d->dpmx; image.d->dpmy = d->dpmy; @@ -1205,8 +1207,6 @@ QImage QImage::copy(const QRect& r) const } } - image.d->colortable = d->colortable; - int pixels_to_copy = qMax(w - dx, 0); if (x > d->width) pixels_to_copy = 0; @@ -1260,9 +1260,10 @@ QImage QImage::copy(const QRect& r) const } } - image.d->dpmx = dotsPerMeterX(); - image.d->dpmy = dotsPerMeterY(); - image.d->offset = offset(); + image.d->colortable = d->colortable; + image.d->dpmx = d->dpmx; + image.d->dpmy = d->dpmy; + image.d->offset = d->offset; image.d->has_alpha_clut = d->has_alpha_clut; return image; } @@ -4049,8 +4050,8 @@ QImage QImage::rgbSwapped() const QIMAGE_SANITYCHECK_MEMORY(res); for (int i = 0; i < d->height; i++) { uint *q = (uint*)res.scanLine(i); - uint *p = (uint*)constScanLine(i); - uint *end = p + d->width; + const uint *p = (const uint*)constScanLine(i); + const uint *end = p + d->width; while (p < end) { *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00); p++;