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

qt.conf ignored when QImageReader::supportedImageFormats is called in static scope

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 4.8.1, 5.0.0 Beta 1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Mac OSX 10.7.5 and probably others
    • Platform/s:
      macOS

      Description

      I'm not sure if this will ultimately be considered a bug but at the very least a warning should be added to the documentation on qt.conf as this is a very dangerous gotcha.

      An example is below. If this code is run, QLibraryInfo::location will report the installed location of the Qt libraries it was compiled against every time regardless of the contents of qt.conf. If QImageReader::supportedImageFormats() is not called, it will load properly from the qt.conf packaged in the resource system.

      I suspect there are other functions that could be called that would produce the same error.

      #include <QtGui/QApplication>
      
      #include <QFile>
      #include <QStringList>
      #include <QDebug>
      #include <QLibraryInfo>
      #include <QImageReader>
      
      QList<QByteArray> formats = QImageReader::supportedImageFormats();
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          qDebug() << "qt.conf " << QFile::exists(QLatin1String(":/qt/etc/qt.conf"));
          qDebug() << "LIBRARIES LOADED: " << QCoreApplication::libraryPaths();
          qDebug() << "PREFIX PATH" << QLibraryInfo::location(QLibraryInfo::PrefixPath);
          qDebug() << "PLUGINS PATH" << QLibraryInfo::location(QLibraryInfo::PluginsPath);
      
          qDebug() << formats.size() << " image formats supported";
      
          return 0;
      }
      

      Example bad output(same qt.conf file as the good output):

      qt.conf  true 
      LIBRARIES LOADED:  ("/Users/ebrenner/QtSDK/Desktop/Qt/4.8.1/gcc/plugins", "/Users/ebrenner/QtProjects/QtConfTest_Qt_4_8_1_release/QtConfTest.app/Contents/MacOS") 
      PREFIX PATH "/Users/ebrenner/QtSDK/Desktop/Qt/4.8.1/gcc" 
      PLUGINS PATH "/Users/ebrenner/QtSDK/Desktop/Qt/4.8.1/gcc/plugins" 
      17  image formats supported 
      

      Example good output(formats is initialized with the default constructor and qt.conf sets prefix to .):

      qt.conf  true 
      LIBRARIES LOADED:  ("/Users/ebrenner/QtProjects/QtConfTest_Qt_4_8_1_release/QtConfTest.app/Contents/MacOS") 
      PREFIX PATH "/Users/ebrenner/QtProjects/QtConfTest_Qt_4_8_1_release/QtConfTest.app/Contents" 
      PLUGINS PATH "/Users/ebrenner/QtProjects/QtConfTest_Qt_4_8_1_release/QtConfTest.app/Contents/plugins" 
      0  image formats supported 
      

        Attachments

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

          Activity

            People

            Assignee:
            vertries Nico Vertriest (Inactive)
            Reporter:
            eabbottbrenner Eric Abbott-Brenner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes