diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 8a4e3c345d8..4a774d9f92f 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -10,7 +10,6 @@ #endif #include "qlibraryinfo.h" #include "qlibraryinfo_p.h" -#include "qscopedpointer.h" #include "qcoreapplication.h" @@ -30,6 +29,8 @@ # include #endif +#include + QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; @@ -38,7 +39,7 @@ extern void qDumpCPUFeatures(); // in qsimd.cpp #if QT_CONFIG(settings) -static QSettings *findConfiguration(); +static std::unique_ptr findConfiguration(); struct QLibrarySettings { @@ -47,7 +48,7 @@ struct QLibrarySettings bool havePaths(); QSettings *configuration(); - QScopedPointer settings; + std::unique_ptr settings; bool paths; bool reloadOnQAppAvailable; }; @@ -62,7 +63,7 @@ QSettings *QLibrarySettings::configuration() { if (reloadOnQAppAvailable && QCoreApplication::instance() != nullptr) load(); - return settings.data(); + return settings.get(); } bool QLibrarySettings::havePaths() @@ -75,8 +76,8 @@ bool QLibrarySettings::havePaths() void QLibrarySettings::load() { // If we get any settings here, those won't change when the application shows up. - settings.reset(findConfiguration()); - reloadOnQAppAvailable = (settings.data() == nullptr && QCoreApplication::instance() == nullptr); + settings = findConfiguration(); + reloadOnQAppAvailable = !settings && !QCoreApplication::instance(); if (settings) { // This code needs to be in the regular library, as otherwise a qt.conf that @@ -96,14 +97,14 @@ void QLibraryInfoPrivate::setQtconfManualPath(const QString *path) qtconfManualPath = path; } -static QSettings *findConfiguration() +static std::unique_ptr findConfiguration() { if (qtconfManualPath) - return new QSettings(*qtconfManualPath, QSettings::IniFormat); + return std::make_unique(*qtconfManualPath, QSettings::IniFormat); QString qtconfig = QStringLiteral(":/qt/etc/qt.conf"); if (QFile::exists(qtconfig)) - return new QSettings(qtconfig, QSettings::IniFormat); + return std::make_unique(qtconfig, QSettings::IniFormat); #ifdef Q_OS_DARWIN CFBundleRef bundleRef = CFBundleGetMainBundle(); if (bundleRef) { @@ -115,7 +116,7 @@ static QSettings *findConfiguration() QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle); qtconfig = QDir::cleanPath(path); if (QFile::exists(qtconfig)) - return new QSettings(qtconfig, QSettings::IniFormat); + return std::make_unique(qtconfig, QSettings::IniFormat); } } #endif @@ -123,10 +124,10 @@ static QSettings *findConfiguration() QDir pwd(QCoreApplication::applicationDirPath()); qtconfig = pwd.filePath(u"qt" QT_STRINGIFY(QT_VERSION_MAJOR) ".conf"_s); if (QFile::exists(qtconfig)) - return new QSettings(qtconfig, QSettings::IniFormat); + return std::make_unique(qtconfig, QSettings::IniFormat); qtconfig = pwd.filePath("qt.conf"_L1); if (QFile::exists(qtconfig)) - return new QSettings(qtconfig, QSettings::IniFormat); + return std::make_unique(qtconfig, QSettings::IniFormat); } return nullptr; //no luck } @@ -688,8 +689,7 @@ QString QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath p, UsageMode usageMo QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) { #if QT_CONFIG(settings) - QScopedPointer settings(findConfiguration()); - if (!settings.isNull()) { + if (const auto settings = findConfiguration()) { const QString key = "Platforms/"_L1 + platformName + "Arguments"_L1;