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

Invalid dash array processing on a path with multiple subpaths

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.15.0 Beta3
    • 5.14.0
    • GUI: Painting
    • None
    • All
    • 533f7d7ca328e81804c8f52818f9d39172694f94 (qt/qtbase/5.15)

    Description

      #include <QGuiApplication>
      #include <QPainter>
      
      int main(int argc, char *argv[])
      {
          QGuiApplication a(argc, argv);
      
          QImage img(200, 200, QImage::Format_RGB32);
          img.fill(Qt::white);
      
          QPainter p(&img);
      
          {
              QPainterPath path;
              path.moveTo(100.0, 30.0);
              path.lineTo(100.0, 80.0);
      
              QPen pen(Qt::red, 5);
              pen.setDashPattern({ 3, 3 });
      
              p.setPen(pen);
              p.drawPath(path);
          }
      
          {
              QPainterPath path;
              path.moveTo(20.0, 20.0);
              path.lineTo(160.0, 20.0);
              // This subpath's dash patter offset is incorrect.
              path.moveTo(100.0, 30.0);
              path.lineTo(100.0, 80.0);
      
              QPen pen(Qt::green, 5);
              pen.setDashPattern({ 3, 3 });
      
              p.setPen(pen);
              p.drawPath(path);
          }
      
          p.end();
      
          img.save("test.png");
      
          return 0;
      }
      

      This mainly affect the SVG rendering, so I've added a comparison with other SVG rendering applications (the input SVG is a bit different, but the idea is the same).

      Attachments

        1. comparison.png
          comparison.png
          18 kB
        2. test.png
          test.png
          0.3 kB
        For Gerrit Dashboard: QTBUG-83048
        # Subject Branch Project Status CR V

        Activity

          People

            vgt Eirik Aavitsland
            razrfalcon Evgeniy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes