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

calling QImageReader::supportedImageFormats() before creating a QApplication caches an incomplete list of supported formats

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 4.7.4
    • 4.6.3
    • None
    • Windows XP (due to some image support being loaded dynamically)
    • 1e5a471645ea8c91b0a2dc0fe019f15fdc5f9127

      If you call QImageReader::supportedImageFormats() before creating an image, you get only a list of formats that are supported natively, without plugins, AND QImageReader remembers this list and does not support images supported by plugins even after you create a QApplication().

      (in Pythonesque syntax)

      formats1 = QImageReader.supportedImageFormats()
      app = QApplication([])
      formats2 = QImageReader.supportedImageFormats()
      p = QPixmap('something.jpg') # won't work

      In the above code, formats1 and formats2 will be the same incomplete list, without JPEG. If you comment out the "formats1" line, formats2 will include JPEG.

      The easiest fix is to document that QImageReader::supportedImageFormats() should not be called before QApplication() is called.

      This was previously mentioned years ago here: http://lists.trolltech.com/qt-interest/2005-11/thread00422-0.html, though no bug was filed as far as I can tell. I encountered this independently.

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

            dm Geir Vattekar
            dhalbert Dan Halbert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes