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

AnimatedImage: issues with loading web source

XMLWordPrintable

    • All
    • fec4ac12e (dev), a9b0aec18 (6.7), 4b4af2a02 (6.6), 9cb527ba1 (tqtc/lts-6.5)

      There are several issues with AnimatedImage when using web-source.

      1. Image loading may fail if you change some image properties such as fillMode, mipmap, etc. immediately after setting the source (see code sample for details).

      Code sample:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Window
      
      Window {
          width: 300
          height: 300
          visible: true
      
          AnimatedImage {
              id: image
              anchors.fill: parent
      
              function resetDefaults() {
                  source = ''
                  sourceSize = undefined // available only in Qt 6.6.0 and above
                  fillMode = Image.Stretch
                  mipmap = false
                  cache = true
              }
          }
      
          Button {
              text: "Press me!"
              onClicked: {
                  image.resetDefaults()
      
                  image.source = 'https://media.tenor.com/BDcB-euFv5IAAAAC/kermit-wat.gif'
      
                  // this triggers QQuickAnimatedImage::load() internally
                  image.fillMode = Image.PreserveAspectFit
                  // or
                  //image.mipmap = true
                  // or
                  //image.cache = false
                  // or (since Qt 6.6.0)
                  //image.sourceSize = Qt.size(200, 200)
              }
          }
      }
      

      Just launch it and press "Press me!" button.
      As a result you'll see that the image is failed to load and there is an error in debug output.

      qrc:/untitled/main.qml:10:5: QML AnimatedImage: Error Reading Animated Image File https://media.tenor.com/BDcB-euFv5IAAAAC/kermit-wat.gif
      

      2. There is possible memory leak on QQuickAnimatedImage::load().
      Every time when it's triggered not directly from setSource() we leak d->reply.

      #if QT_CONFIG(qml_network)
                  d->setStatus(Loading);
                  d->setProgress(0);
                  QNetworkRequest req(d->url);
                  req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
      
                  d->reply = qmlEngine(this)->networkAccessManager()->get(req);
                  connect(d->reply, &QNetworkReply::finished, this, &QQuickAnimatedImage::movieRequestFinished);
                  connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(requestProgress(qint64,qint64)));
      #endif
      

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            studiosus Vladimir Belyavsky
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes