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

QBrush.setStyle(Qt::Dense4Pattern) causes app crash when printing

    XMLWordPrintable

Details

    • macOS
    • e71b640f3cde7e748f962240489888325accbfeb (qt/qtbase/5.12)

    Description

      Setting the QBrush.style to Qt:Dense4Pattern, using the brush, and painting to a QPrinter device (save to PDF or use printer driver), causes apps to crash.
      QPrinter* printer = new QPrinter(QPrinter::ScreenResolution);
      if( !printer )

      { return; }

      printer->setDocName("test");
      printer->setOutputFileName(QString());
      printer->setFromTo(0, 0);

      QPrintDialog dlg(printer, nullptr);
      if( dlg.exec() != QDialog::Accepted ){ return; }

      QPainter p(printer);
      if( !p.isActive() )

      { return; }

      QBrush checkerBrush;
      checkerBrush.setColor(Qt::white);
      //QT BUG: The next line causes the program to crash
      // during printing (PDF or printer device).
      // Behavior observed on MacOS 10.14.1 Mojave
      // under Qt 5.9.6
      checkerBrush.setStyle(Qt::Dense4Pattern);
      p.setBrush(checkerBrush);
      p.setRenderHint(QPainter::Antialiasing, true);

      QRect rect(10, 20, 80, 60);
      p.drawRect(rect);

      I've provided source code for the Basic Drawing app, tweaked to include the above code in RenderArea::setBrush.

      Attachments

        For Gerrit Dashboard: QTBUG-71934
        # Subject Branch Project Status CR V

        Activity

          People

            vgt Eirik Aavitsland
            craig_kaufman Craig Kaufman
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes