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

SVG image plugin does not implement CanRead

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.7.0
    • Image formats, SVG Support
    • None
    • 2fe059c863377befdcf65084a07a7f4841beef0d

    Description

      According to the comment in the code, it's "hard":

      QImageIOPlugin::Capabilities QSvgPlugin::capabilities(QIODevice *device, const QByteArray &format) const
      {
          //### canRead disabled for now because it's hard to detect
          //    whether the file is actually svg without parsing it
          //if (device->isReadable() && QSvgIOHandler::canRead(device))
      
          if (format == "svg")
              return Capabilities(CanRead);
          else
              return 0;
          ...
      }
      

      Consequence is that SVGs cannot be read from non-files (eg. QNetworkReply). (QImage has a backdoor QIODevice access to the filename, but fortunately not the QNetworkReply::url().

      QDeclarativeImageRequestHandler, and everyone else has to work around this bug. All SVGs start with <?xml ...><comments><svg ...>. This doesn't require "hard" parsing.

      The main purpose of CanRead is to detect WHICH handler to use, not to give a totally authoritative "yes this is definitely this format". The PNG loader for example, which claim to be able to read most corrupted PNG files.

      Blocks requirement QT-3128.

      Attachments

        Issue Links

          Activity

            People

              vgt Eirik Aavitsland
              wallison Warwick Allison (closed Nokia identity) (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: