Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
4.8.1, 5.0.0 Beta 1
-
None
-
Mac OSX 10.7.5 and probably others
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