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

Scalable image formats not rendered at correct DPR when extension is left out

    XMLWordPrintable

Details

    Description

      See https://codereview.qt-project.org/c/qt/qtdoc/+/470732/12#message-5f7ce2f108a4bc25d4a78445f2eb1fb3fb43a788:

      I had forgotten to add the .svg extension in iconSource()... of course I had no feedback of that because of https://bugreports.qt.io/browse/QTBUG-66127. existingImageFileForPath will loop through a list of supported file types and try each one with the path. So even if you forget the extension, if your image exists with a known extension, it will be found and successfully loaded.

      The problem is that isScalableImageFormat is called without that extension, so it doesn't see the svg extension and considers it not scalable. That causes QQuickImageBasePrivate::updateDevicePixelRatio to set setDevicePixelRatio to false, and devicePixelRatio is never set to the higher DPR (2).

      I'm not sure how this should be fixed, as it would in theory require the non-existent-file-extension lookup to be done twice if it can't be cached somehow, which seems really sub-optimal.

      Anyway, we can easily avoid it by fixing iconSource().

      To reproduce the issue, run the attached example (or any QML snippet with an Image that leaves out the extension for an SVG) on a display with a DPR > 1:

      import QtQuick
      import QtQuick.Window
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Image {
              source: "file-icon-round"
          }
      }
      

      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
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes