OSDN Git Service

do not detach source image in write_xpm_image()
authorIvailo Monev <xakepa10@gmail.com>
Thu, 9 Sep 2021 17:47:53 +0000 (20:47 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Thu, 9 Sep 2021 17:47:53 +0000 (20:47 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/image/qxpmhandler.cpp

index 8b5f220..14ccf95 100644 (file)
@@ -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));