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

QPainterPath::united() produces unusual output with some input paths

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 4.7.2
    • GUI: Painting
    • None

    Description

      You can reproduce this by running the painter paths example with the following paths set:

      QPainterPath path0;
      	path0.moveTo(1.0000000000047748,177001.00000000000);
      	path0.lineTo(1.0000000000047748,113001.00000000000);
      	path0.moveTo(165001.00000000000,64001.000000000007);
      	path0.lineTo(165001.00000000000,1.0000000000047748);
      	path0.lineTo(1.0000000000047748,113001.00000000000);
      	path0.lineTo(1.0000000000047748,177001.00000000000);
      	path0.lineTo(165001.00000000000,64001.000000000007);
      	path0.moveTo(274001.00000000006,177001.00000000000);
      	path0.lineTo(274001.00000000006,113001.00000000000);
      	path0.lineTo(165001.00000000000,1.0000000000047748);
      	path0.lineTo(165001.00000000000,64001.000000000007);
      	path0.lineTo(274001.00000000006,177001.00000000000);
      
      	QPainterPath path1;
      	path1.moveTo(343001.00000000000,177001.00000000000);
      	path1.lineTo(343001.00000000000,113001.00000000000);
      	path1.lineTo(274001.00000000000,113001.00000000000);
      	path1.lineTo(274001.00000000000,177001.00000000000);
      	path1.lineTo(343001.00000000000,177001.00000000000);
      
      	QPainterPath path;
      	path = path0.united(path1);
      
      

      The resultant output does not correspond with the part of path0 that is the union of path1. The expected output is an almost identical shape to Path0 but extended on the bottom right with a small square.

      The proposed patch which appears to resolve this is to reimplement fuzzyIsNull in qpathclipper.cpp like this:

      static inline bool fuzzyIsNull(qreal d)
       {
          return qAbs(d) <= 0.01;
       }
      

      The result of this can be seen in the attached screen shots, showing pre and post patch.

      Attachments

        1. without-patch.jpg
          without-patch.jpg
          450 kB
        2. with-patch.jpg
          with-patch.jpg
          381 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            cattell Matthew Cattell (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes