Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-64092

QPainter + QImage::Format_Grayscale8 bug + drawText

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.9.1
    • Fix Version/s: 5.9.2
    • Component/s: GUI: Painting
    • Labels:
      None
    • Environment:
      Ubuntu 16.10, x64

      Qt 5.9.1+dfsg-10ubuntu1

       

      Description

      Start from Qt 5.9.1, when i draw text, on QImage, in some resolutions (if one side of image >= 2051px), when it use Grayscale8 color space, and this text, still outside image region (intersect of one image side), i get crash:

      *** stack smashing detected ***: <unknown> terminated

      The program has unexpectedly finished.

       

      #include <QGuiApplication>
      #include <QCoreApplication>
      #include <QImage>
      #include <QPainter>

      int main(int argc, char *argv[])
      {
          QGuiApplication a(argc, argv);
          QImage img(2051, 100, QImage::Format_Grayscale8);
          QPainter p;    
          p.begin(&img);
          p.eraseRect(QRect(QPoint(0,0),img.size()));
          QFont f=p.font();
          f.setPointSize(10);
          p.setFont(f);

      //create rect, interset of one side image
          QRect textRect(img.width()-50,30,100,50);
          QString text("hello world!");

          p.setBrush(QBrush(QColor(0,0,0,200)));
          p.setPen(Qt::NoPen);
          p.drawRect(textRect);
          p.setPen(QColor(255,255,255,255));
          //at rhis point, i have crash:
          //*** stack smashing detected ***: <unknown> terminated
          //The program has unexpectedly finished.
          p.drawText(textRect, 0, text);

          p.end();
          img.save("/home/nick1710/testimage.png");
      }

      I upload sample program, to repeat bug. In Qt 5.6 all work fine.

        Attachments

        1. qtbug.tar.gz
          281 kB
        2. testimage.png
          testimage.png
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              vgt Eirik Aavitsland
              Reporter:
              lubagov Nikolay Lubyagoc
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes