Bug 30104

Summary: Qt5 GUI Library update from 5.15.2-4.3 to 5.15.2-4.4 broke dot/dash lines
Product: Mageia Reporter: Ethan Merritt <sfeam>
Component: RPM PackagesAssignee: KDE maintainers <kde>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Normal CC: mageia
Version: 8   
Target Milestone: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Source RPM: qtbase5-5.15.2-4.4.mga8.src.rpm CVE:
Status comment:

Description Ethan Merritt 2022-03-01 06:26:44 CET
Description of problem:

Horizontal and vertical dashed lines with linewidth > 1 come out solid.  This is true both for the predefined dash patterns set by currentPen.setStyle(Qt::PenStyle(style)) and custom dash patterns set by currentPen.setDashPattern(dashpattern).

Lines at other angles seem unaffected

Everything was fine in release lib64qt5gui-5.15.2-4.3 but the upgrade to 5.15.2-4.4 broke all application programs using dashed lines. In my case this is gnuplot but the issue is clearly a library problem. It is still broken in the lastest update 5.15.2-4.5 in both Mageia 8 and in Cauldren.


Version-Release number of selected component (if applicable):


How reproducible:  100%


Steps to Reproduce:
1.  downgrade to lib64qt5gui-5.15.2-4.3 or earlier

2.  run application program (gnuplot in my case) that draw dashed lines.
    E.g.   plot 0 with lines linewidth 2 dashtype '.-'
      or   plot sin(x) with impulse linewidth 3 dashtype 3

    this will produce a plot with a horizontal line .-.-.-.-.- at y=0
    or a set of vertical dotted lines 

3.  upgrade to lib64qt5gui-5.15.2-4.4
    run the application again, same test commands

    test 1 produces a solid horizontal line 
    test 2 produces a set of vertical solid lines
Comment 1 David Walser 2022-03-01 17:17:01 CET
It looks like the last update was the timezone detection fix in Bug 29591.

Assignee: bugsquad => kde
CC: (none) => mageia

Comment 2 Ethan Merritt 2022-03-01 23:08:19 CET
Having now downloaded and looked into the source rpm
  qtbase5-5.15.2-4.4.mga8.src.rpm

I wonder if the error was introduced by this patch
  CVE-2021-38593-2.patch

I do not know the context or motivation for this patch but I can see that under some conditions it replaces a dashed line with a solid line.  The condition that it adds is 

           if (qFuzzyIsNull(extent) ||  ...previous test here...)

which means nothing to me but perhaps qFuzzyIsNull is not the right test.
Comment 4 sturmvogel 2022-03-01 23:33:03 CET
This is an upstream decision. Quote:

"Avoid processing-intensive painting of high number of tiny dashes

When stroking a dashed path, an unnecessary amount of processing would
be spent if there is a huge number of dashes visible, e.g. because of
scaling. Since the dashes are too small to be indivdually visible
anyway, just replace with a semi-transparent solid line for such
cases.
"
Comment 5 Ethan Merritt 2022-03-01 23:50:18 CET
Yes, I understand the intent.  But the test is apparently triggering incorrectly in some well-defined cases.

I have not tracked back through the history of the changes involved, but I suspect the test is incorrectly assuming that an extent of zero is invalid.  This would be incorrect. The dash pattern is defined as an even number of extent values, signifying a sequence of alternating draw/not-draw components.   If the final extent is zero, this means that there is no gap between the final "draw" component of this pattern instance and the first "draw" component of the next pattern instance.  So a final zero is legal.

As I said, I have not tracked back through the changes to pin this down completely.  The patch as included in that source rpm does not apply to the base source file, so there must have been intervening patches applied?  I don't know exactly how your source rpms are set up.  Would I have to download and apply patches in qtbase5-5.15.2-4.1   qtbase5-5.15.2-4.2  qtbase5-5.15.2-4.3 before this?
Comment 6 Ethan Merritt 2022-03-02 20:10:00 CET
The buggy fix was reverted and replaced with a better fix in qtbase5-5.15.2-18.mga9.src.rpm

I can confirm that version works in Cauldron.  The newer fix is

0218-Refix-for-avoiding-huge-number-of-tiny-dashes.patch

>From 427df34efdcb56582a9ae9f7d2d1f39eeff70328 Mon Sep 17 00:00:00 2001
>From: Eirik Aavitsland <eirik.aavitsland@qt.io>
>Date: Fri, 30 Jul 2021 13:03:49 +0200
>Subject: [PATCH 218/255] Refix for avoiding huge number of tiny dashes
>
>Previous fix hit too widely so some valid horizontal and vertical
>lines were affected; the root problem being that such lines have an
>empty control point rect (width or height is 0). Fix by caculating in
>the pen width.

It would be nice to have a working version in Mageia8 also.

   thanks,
             Ethan
Comment 7 Oleg Bosis 2022-03-02 20:25:29 CET
The fix is available for 6 months in KDE's qt5 repo:

https://invent.kde.org/qt/qt/qtbase/-/commit/427df34efdcb56582a9ae9f7d2d1f39eeff70328

Why Qt5 is not yet switched to KDE's branch? Do you really like to cherry pick every single patch manually? Are there any drawbacks of such switching?
Comment 8 Nicolas Lécureuil 2022-03-02 21:29:09 CET
Qt from cauldron with with KDE branch. 

We should do this for mga8 too.