Commit aad3c089 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

Clean up QLibraryInfoPrivate::findConfiguration()


The QFile::exists() check in the end was redundant if one of the
!QFile::exists() had returned false before. By always doing the
positive check we can get rid of it and also avoid excessive
nesting.

Also, on OSX the isEmpty() clause probably never evaluated
to true, with the effect that qt.conf in an applicationDirPath was
never found.

Change-Id: I750735741b707d3e98c4bf6c6b9558618e1fcc59
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
parent 8eaddf83
No related merge requests found
Showing with 22 additions and 22 deletions
...@@ -158,35 +158,35 @@ void QLibrarySettings::load() ...@@ -158,35 +158,35 @@ void QLibrarySettings::load()
QSettings *QLibraryInfoPrivate::findConfiguration() QSettings *QLibraryInfoPrivate::findConfiguration()
{ {
QString qtconfig = QStringLiteral(":/qt/etc/qt.conf"); QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
#ifdef QT_BUILD_QMAKE #ifdef QT_BUILD_QMAKE
if(!QFile::exists(qtconfig)) qtconfig = qmake_libraryInfoFile();
qtconfig = qmake_libraryInfoFile(); if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
#else #else
if (!QFile::exists(qtconfig)) {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
CFBundleRef bundleRef = CFBundleGetMainBundle(); CFBundleRef bundleRef = CFBundleGetMainBundle();
if (bundleRef) { if (bundleRef) {
QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef, QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef,
QCFString(QLatin1String("qt.conf")), QCFString(QLatin1String("qt.conf")),
0, 0,
0); 0);
if (urlRef) { if (urlRef) {
QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle); QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
qtconfig = QDir::cleanPath(path); qtconfig = QDir::cleanPath(path);
} if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
} }
if (qtconfig.isEmpty()) }
#endif #endif
{ if (QCoreApplication::instance()) {
if (QCoreApplication::instance()) { QDir pwd(QCoreApplication::applicationDirPath());
QDir pwd(QCoreApplication::applicationDirPath()); qtconfig = pwd.filePath(QLatin1String("qt.conf"));
qtconfig = pwd.filePath(QLatin1String("qt.conf")); if (QFile::exists(qtconfig))
} return new QSettings(qtconfig, QSettings::IniFormat);
}
} }
#endif #endif
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
return 0; //no luck return 0; //no luck
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment