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

QQuickImageProviderWithOptions::loadSize doesn't deal with options correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7
    • None

    Description

      As explained on QTBUG-122705:

      If you set only Image.sourceSize.width or Drag.imageSourceSize.width to a smaller value than the image's "natural" size, and then call QQuickImageProviderWithOptions::loadSize() with options having preserveAspectRatioFit(), you expect that it will return a size that fits into the width or the height, whichever makes the image smaller (as long as it's greater than zero); but instead, it returns an anamorphic size, where width is whatever you set and height is from the image's natural size.

      This has several causes / obstacles to deal with:

      • QQuickImageBase::sourceSize() and QQuickDragAttached::imageSourceSize() return the size from the pixmapLoader for each dimension that was not set. This is a way of providing information to a user who might want to get the natural size from the property; but if the pixmapLoader has already loaded the image with its "natural" size, and then you change sourceSize.width, to call the setter you have to first call the getter, change its width, and then set it back again. So you only changed the width, and by not mentioning the height, you didn't set it to 0. But if the image wasn't loaded, the height is not known, and therefore still 0. This is inconsistent.
      • QQuickImageProviderWithOptions::loadSize() treats preserveAspectRatioFit() and preserveAspectRatioCrop() exactly the same. That doesn't make sense IMO. One should be trying to minimize the size to fit both ways; the other should be trying to maximize it, to fit one dimension and crop the other. (Need to amend https://codereview.qt-project.org/c/qt/qtdeclarative/+/189379 )
      • In the case of the Drag attached property: if we want to fix it by delaying loading until component complete, to make the behavior independent of the order of setting properties (in case you set imageSource first and then imageSourceSize afterwards) and thereby avoid imageSourceSize() returning the "known" size too early, we run into QTBUG-39079: if there is a way to find out when the component is complete, it's harder than it is for an Item, to say the least.

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes