diff options
Diffstat (limited to 'src/corelib/global/qlibraryinfo.cpp')
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 122 |
1 files changed, 71 insertions, 51 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 62b49da316..27fe10a79e 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -163,14 +163,14 @@ 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 - qtconfig = qmake_libraryInfoFile(); + QString qtconfig = qmake_libraryInfoFile(); if (QFile::exists(qtconfig)) return new QSettings(qtconfig, QSettings::IniFormat); #else + QString qtconfig = QStringLiteral(":/qt/etc/qt.conf"); + if (QFile::exists(qtconfig)) + return new QSettings(qtconfig, QSettings::IniFormat); #ifdef Q_OS_DARWIN CFBundleRef bundleRef = CFBundleGetMainBundle(); if (bundleRef) { @@ -229,30 +229,30 @@ QLibraryInfo::QLibraryInfo() { } /*! - Returns the person to whom this build of Qt is licensed. - - \sa licensedProducts() + \deprecated + This function used to return the person to whom this build of Qt is licensed, now returns an empty string. */ +#if QT_DEPRECATED_SINCE(5, 8) QString QLibraryInfo::licensee() { - const char * volatile str = QT_CONFIGURE_LICENSEE; - return QString::fromLocal8Bit(str); + return QString(); } +#endif /*! - Returns the products that the license for this build of Qt has access to. - - \sa licensee() + \deprecated + This function used to return the products that the license for this build of Qt has access to, now returns an empty string. */ +#if QT_DEPRECATED_SINCE(5, 8) QString QLibraryInfo::licensedProducts() { - const char * volatile str = QT_CONFIGURE_LICENSED_PRODUCTS; - return QString::fromLatin1(str); + return QString(); } +#endif /*! \since 4.6 @@ -368,6 +368,19 @@ QLibraryInfo::isDebugBuild() #endif } +#ifndef QT_BOOTSTRAPPED +/*! + \since 5.8 + Returns the version of the Qt library. + + \sa qVersion() +*/ +QVersionNumber QLibraryInfo::version() Q_DECL_NOTHROW +{ + return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH); +} +#endif // QT_BOOTSTRAPPED + #endif // QT_BUILD_QMAKE /* @@ -438,6 +451,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) { #endif // QT_BUILD_QMAKE, started inside location ! QString ret; + bool fromConf = false; +#ifndef QT_NO_SETTINGS #ifdef QT_BUILD_QMAKE // Logic for choosing the right data source: if EffectivePaths are requested // and qt.conf with that section is present, use it, otherwise fall back to @@ -446,40 +461,18 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) // EffectiveSourcePaths falls back to EffectivePaths. // DevicePaths falls back to FinalPaths. PathGroup orig_group = group; - if (!QLibraryInfoPrivate::haveGroup(group) - && !(group == EffectiveSourcePaths - && (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group))) - && !((group == EffectivePaths || group == DevicePaths) - && (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group))) - && (group = orig_group, true)) -#elif !defined(QT_NO_SETTINGS) - if (!QLibraryInfoPrivate::configuration()) + if (QLibraryInfoPrivate::haveGroup(group) + || (group == EffectiveSourcePaths + && (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group))) + || ((group == EffectivePaths || group == DevicePaths) + && (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group))) + || (group = orig_group, false)) +#else + if (QLibraryInfoPrivate::configuration()) #endif { - const char * volatile path = 0; - if (loc == PrefixPath) { - path = -#ifdef QT_BUILD_QMAKE - (group != DevicePaths) ? - QT_CONFIGURE_EXT_PREFIX_PATH : -#endif - QT_CONFIGURE_PREFIX_PATH; - } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) { - path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; -#ifndef Q_OS_WIN // On Windows we use the registry - } else if (loc == SettingsPath) { - path = QT_CONFIGURE_SETTINGS_PATH; -#endif -#ifdef QT_BUILD_QMAKE - } else if (loc == HostPrefixPath) { - path = QT_CONFIGURE_HOST_PREFIX_PATH; -#endif - } + fromConf = true; - if (path) - ret = QString::fromLocal8Bit(path); -#ifndef QT_NO_SETTINGS - } else { QString key; QString defaultValue; if (unsigned(loc) < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) { @@ -511,7 +504,9 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key), QLatin1String(qtConfEntries[PrefixPath].value)).toString(); else if (loc == TargetSpecPath || loc == HostSpecPath) - ret = QString::fromLocal8Bit(qt_configure_strs + qt_configure_str_offsets[loc - 1]); + fromConf = false; + // The last case here is SysrootPath, which can be legitimately empty. + // All other keys have non-empty fallbacks to start with. } #endif @@ -521,7 +516,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) reg_var.setMinimal(true); while((rep = reg_var.indexIn(ret)) != -1) { ret.replace(rep, reg_var.matchedLength(), - QString::fromLocal8Bit(qgetenv(ret.mid(rep + 2, + QString::fromLocal8Bit(qgetenv(ret.midRef(rep + 2, reg_var.matchedLength() - 3).toLatin1().constData()).constData())); } @@ -529,7 +524,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) ret = QDir::fromNativeSeparators(ret); } + } #endif // QT_NO_SETTINGS + + if (!fromConf) { + const char * volatile path = 0; + if (loc == PrefixPath) { + path = +#ifdef QT_BUILD_QMAKE + (group != DevicePaths) ? + QT_CONFIGURE_EXT_PREFIX_PATH : +#endif + QT_CONFIGURE_PREFIX_PATH; + } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) { + path = qt_configure_strs + qt_configure_str_offsets[loc - 1]; +#ifndef Q_OS_WIN // On Windows we use the registry + } else if (loc == SettingsPath) { + path = QT_CONFIGURE_SETTINGS_PATH; +#endif +#ifdef QT_BUILD_QMAKE + } else if (loc == HostPrefixPath) { + path = QT_CONFIGURE_HOST_PREFIX_PATH; +#endif + } + + if (path) + ret = QString::fromLocal8Bit(path); } #ifdef QT_BUILD_QMAKE @@ -605,10 +625,10 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) #if !defined(QT_BUILD_QMAKE) && !defined(QT_NO_SETTINGS) QScopedPointer<const QSettings> settings(QLibraryInfoPrivate::findConfiguration()); if (!settings.isNull()) { - QString key = QLatin1String(platformsSection); - key += QLatin1Char('/'); - key += platformName; - key += QLatin1String("Arguments"); + const QString key = QLatin1String(platformsSection) + + QLatin1Char('/') + + platformName + + QLatin1String("Arguments"); return settings->value(key).toStringList(); } #endif // !QT_BUILD_QMAKE && !QT_NO_SETTINGS |