From bc7a9c32acece4ec343ee7d42317409eb55a3bf9 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 9 Sep 2021 20:47:53 +0300 Subject: [PATCH] do not detach source image in write_xpm_image() Signed-off-by: Ivailo Monev --- src/gui/image/qxpmhandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 8b5f22056..14ccf9592 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1032,7 +1032,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const // build color table for(int y = 0; y < h; y++) { - QRgb * yp = (QRgb *)image.scanLine(y); + const QRgb * yp = (const QRgb *)image.constScanLine(y); for(int x = 0; x < w; x++) { QRgb color = *(yp + x); if (!colorMap.contains(color)) @@ -1078,7 +1078,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(int y = 0; y < h; y++) { - QRgb * yp = (QRgb *) image.scanLine(y); + const QRgb * yp = (const QRgb *) image.constScanLine(y); int cc = 0; for(int x = 0; x < w; x++) { int color = (int)(*(yp + x)); -- 2.11.0