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

QImageWriter insufficiently supports QSaveFile

    XMLWordPrintable

Details

    • f0510d5bd2f1ed1dc76f6f89fb24566045d9ade7 (qt/qtbase/dev) eafd0106178fe0129f6260007dad6e521f30681d (qt/qtbase/6.2)

    Description

      The problem: When constructed with a filename or a QFile object, QImageWriter is able to determine the desired format from the filename. For safety, it should be easy to use QSaveFile in place of QFile, but this is not the case here: When constructed with a QSaveFile device, the format must be set explicitly.

      By locality, the documentation gives the impression that the format is determined at construction time when given a filename. But at construction time, the filename is used only to construct a QFile object. If setting a QSaveFile device after QImageWriter construction, the ability to determine the format is lost.

      The cause: The format is determined lazily in createWriteHandlerHelper() from the filename only if it the device can be cast to a QFile.

      However, the filename() property comes from QFileDevice, the common base class of QFile and QSaveFile.

      The proposal: Use QFileDevice, not QFile, to determine the format from the filename.

      Attachments

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

        Activity

          People

            vgt Eirik Aavitsland
            dg0yt Kai Pastor
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes