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

ICNS plugin: allow loading images over the network without warnings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.4.0
    • 5.3.1
    • Image formats
    • None
    • OSX

      If you try this QML code

      import QtQuick 2.1
      
      Rectangle {
          width: 360
          height: 360
      
          AnimatedImage {
              anchors.centerIn: parent
              source: "http://libmng.com/MNGsuite/images/T01SCRL.mng"
          }
      }
      

      it works, but it displays the warning

      QICNSHandler::canRead() called on a sequential device

      That's coming from here

      bool QICNSHandler::canRead(QIODevice *device)
      {
          if (!device || !device->isReadable()) {
              qWarning("QICNSHandler::canRead() called without a readable device");
              return false;
          }
      
          if (device->isSequential()) {
              qWarning("QICNSHandler::canRead() called on a sequential device");
              return false;
          }
      
          return device->peek(4) == QByteArrayLiteral("icns");
      }
      

      If the goal is just to read the first 4 bytes, it should be possible to do that even on a sequential device, and find some way to cache them for later. Perhaps a caching wrapper stream of some sort. Then the warning would not be necessary.

      It's interesting that the ICNS plugin got invoked for MNG images though, isn't it? I guess it just checks to see if it canRead() and then tries another plugin. But you could put an icns file on a web server if you like, so this could maybe come up somewhere legitimately...

      But if a lot of plugins will need to read some bytes in their canRead() functions, it's inefficient to query the first few bytes from the server repeatedly. Maybe we need another solution then.

        For Gerrit Dashboard: QTBUG-39838
        # Subject Branch Project Status CR V

            preveder Alex Char
            srutledg Shawn Rutledge
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes