diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-03-10 13:31:57 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-03-11 09:10:18 +0000 |
commit | aad3c089023652844a3898fa0b7cbf1db966ef3c (patch) | |
tree | 283a003d15c2e2c2d40a7b1811b1f949d2be2fad /src | |
parent | 8eaddf8343242caa9e9dde562107ece8d0785680 (diff) |
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: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 484c7869a6..5db2e94602 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -158,35 +158,35 @@ void QLibrarySettings::load() QSettings *QLibraryInfoPrivate::findConfiguration() { QString qtconfig = QStringLiteral(":/qt/etc/qt.conf"); + if (QFile::exists(qtconfig)) + return new QSettings(qtconfig, QSettings::IniFormat); #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 - if (!QFile::exists(qtconfig)) { #ifdef Q_OS_MAC - CFBundleRef bundleRef = CFBundleGetMainBundle(); - if (bundleRef) { - QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef, - QCFString(QLatin1String("qt.conf")), - 0, - 0); - if (urlRef) { - QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle); - qtconfig = QDir::cleanPath(path); - } + CFBundleRef bundleRef = CFBundleGetMainBundle(); + if (bundleRef) { + QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef, + QCFString(QLatin1String("qt.conf")), + 0, + 0); + if (urlRef) { + QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle); + qtconfig = QDir::cleanPath(path); + if (QFile::exists(qtconfig)) + return new QSettings(qtconfig, QSettings::IniFormat); } - if (qtconfig.isEmpty()) + } #endif - { - if (QCoreApplication::instance()) { - QDir pwd(QCoreApplication::applicationDirPath()); - qtconfig = pwd.filePath(QLatin1String("qt.conf")); - } - } + if (QCoreApplication::instance()) { + QDir pwd(QCoreApplication::applicationDirPath()); + qtconfig = pwd.filePath(QLatin1String("qt.conf")); + if (QFile::exists(qtconfig)) + return new QSettings(qtconfig, QSettings::IniFormat); } #endif - if (QFile::exists(qtconfig)) - return new QSettings(qtconfig, QSettings::IniFormat); return 0; //no luck } |