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

QImage generates warnings that can not be muted when opening JPEGs

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • Not Evaluated
    • None
    • 5.12
    • Image formats
    • None
    • All

    Description

      When I try to load a corrupted jpeg file using QImage, QT prints the warnings through the MessageHandler. It makes it hard to catch the message in the caller's code. Also, it can pollute the console or the screen (since I redirect these warnings to a QDialog). Unfortunately there is no way to test the JPEG before opening or mute these messages.

      I think the code responsible for this issue is located in qjpeghandler.cpp: my_error_exit().

      One workaround would be to filter these messages in a custom MessageHandler and save them. This approach is detailed in:
      https://stackoverflow.com/a/33452293/6050364
      But it also has its own issues when doing it concurrently. Also, the developer needs to be aware of all the possible messages that need to be filtered.

      I think QImage::loadFromData() should return the error text in a new argument, raise an exception, or save it temporarily to be accessed using another function, similarly as in ifstream.

      Attachments

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

        Activity

          People

            vgt Eirik Aavitsland
            ahi Adriel Jr.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes