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

Regression in QtSvgTinyDocument: Runtime warnings logged to the console

    XMLWordPrintable

Details

    • Linux/Wayland
    • 82e70e320 (dev), 72763a4d6 (6.8), b83bde860 (6.7), 4f405e9c4 (tqtc/lts-6.5)

    Description

      It seems like a workaround introduced in 65d96953a, which seems to be to prevent a runtime warning about negative point sizes by calculating the point size from the pixel
      size, is causing a runtime warning about negative point sizes:

      QFont::setPointSizeF: Point size <= 0 (-0.720000), must be greater than 0
      

      Reverting the change, which was introduced in 6.5.6, removes the log output. The change seen below:

      diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
      index 78002ffd..26490d07 100644
      --- a/src/svg/qsvgtinydocument.cpp
      +++ b/src/svg/qsvgtinydocument.cpp
      @@ -240,6 +240,10 @@ void QSvgTinyDocument::draw(QPainter *p, const QRectF &bounds)
           p->setBrush(Qt::black);
           p->setRenderHint(QPainter::Antialiasing);
           p->setRenderHint(QPainter::SmoothPixmapTransform);
      +    QFont font(p->font());
      +    if (font.pointSize() < 0)
      +        font.setPointSizeF(font.pixelSize() * 72.0 / p->device()->logicalDpiY());
      +    p->setFont(font);
           QList<QSvgNode*>::iterator itr = m_renderers.begin();
           applyStyle(p, m_states);
           while (itr != m_renderers.end()) {
      

      Our debug output suggests that font.pixelSize() is 1, and p>device()->logicalDpiY() is 100. So the size ends up being < 0. Documentation suggests pointSize and pixelSize both return -1 if the size was set using the other property. But -1 is also the default value for both properties:

      #include <QDebug>
      #include <QFont>
      
      int main()
      {
          QFont f;
          qCritical() << f.pointSizeF() << f.pixelSize();
      }
      

      The example prints -1 -1.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vgt Eirik Aavitsland
              andrhans Andreas Aardal Hanssen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews