diff options
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/forkfd_qt.cpp | 29 | ||||
-rw-r--r-- | src/corelib/io/qfileinfo.cpp | 64 | ||||
-rw-r--r-- | src/corelib/io/qfileinfo.h | 2 | ||||
-rw-r--r-- | src/corelib/io/qfileselector.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_win.cpp | 13 | ||||
-rw-r--r-- | src/corelib/io/qloggingregistry.cpp | 7 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 3 | ||||
-rw-r--r-- | src/corelib/io/qresource.cpp | 26 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 41 |
9 files changed, 114 insertions, 77 deletions
diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp index 80d1cd54d7..cf44874153 100644 --- a/src/corelib/io/forkfd_qt.cpp +++ b/src/corelib/io/forkfd_qt.cpp @@ -37,37 +37,12 @@ ** ****************************************************************************/ -// these might be defined via precompiled headers -#include <QtCore/qatomic.h> +#include <QtCore/qglobal.h> #define FORKFD_NO_SPAWNFD - #if defined(QT_NO_DEBUG) && !defined(NDEBUG) # define NDEBUG #endif -typedef QT_PREPEND_NAMESPACE(QBasicAtomicInt) ffd_atomic_int; -#define ffd_atomic_pointer(type) QT_PREPEND_NAMESPACE(QBasicAtomicPointer<type>) - -QT_BEGIN_NAMESPACE - -#define FFD_ATOMIC_INIT(val) Q_BASIC_ATOMIC_INITIALIZER(val) - -#define FFD_ATOMIC_RELAXED Relaxed -#define FFD_ATOMIC_ACQUIRE Acquire -#define FFD_ATOMIC_RELEASE Release - -#define FFD_CONCAT(x, y) x ## y - -#define ffd_atomic_load(ptr,order) (ptr)->FFD_CONCAT(load, order)() -#define ffd_atomic_store(ptr,val,order) (ptr)->FFD_CONCAT(store, order)(val) -#define ffd_atomic_exchange(ptr,val,order) (ptr)->FFD_CONCAT(fetchAndStore, order)(val) -#define ffd_atomic_compare_exchange(ptr,expected,desired,order1,order2) \ - (ptr)->FFD_CONCAT(testAndSet, order1)(*expected, desired, *expected) -#define ffd_atomic_add_fetch(ptr,val,order) ((ptr)->FFD_CONCAT(fetchAndAdd, order)(val) + val) - -QT_END_NAMESPACE - -extern "C" { +#include <forkfd.h> #include "../../3rdparty/forkfd/forkfd.c" -} diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index a5a3bc8b3e..a6f8b45ea3 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -256,10 +256,9 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) \snippet code/src_corelib_io_qfileinfo.cpp 0 - On Windows, symlinks (shortcuts) are \c .lnk files. The reported - size() is that of the symlink (not the link's target), and - opening a symlink using QFile opens the \c .lnk file. For - example: + On Windows, shortcuts are \c .lnk files. The reported size() is that of + the shortcut (not the link's target), and opening a shortcut using QFile + opens the \c .lnk file. For example: \snippet code/src_corelib_io_qfileinfo.cpp 1 @@ -1036,7 +1035,7 @@ bool QFileInfo::isBundle() const } /*! - Returns \c true if this object points to a symbolic link; + Returns \c true if this object points to a symbolic link or shortcut; otherwise returns \c false. Symbolic links exist on Unix (including \macos and iOS) and Windows @@ -1066,6 +1065,61 @@ bool QFileInfo::isSymLink() const } /*! + Returns \c true if this object points to a symbolic link; + otherwise returns \c false. + + Symbolic links exist on Unix (including \macos and iOS) and Windows + (NTFS-symlink) and are typically created by the \c{ln -s} or \c{mklink} + commands, respectively. + + Unix handles symlinks transparently. Opening a symbolic link effectively + opens the \l{symLinkTarget()}{link's target}. + + In contrast to isSymLink(), false will be returned for shortcuts + (\c *.lnk files) on Windows. Use QFileInfo::isShortcut() instead. + + \note If the symlink points to a non existing file, exists() returns + false. + + \sa isFile(), isDir(), isShortcut(), symLinkTarget() +*/ + +bool QFileInfo::isSymbolicLink() const +{ + Q_D(const QFileInfo); + return d->checkAttribute<bool>( + QFileSystemMetaData::LegacyLinkType, + [d]() { return d->metaData.isLink(); }, + [d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); }); +} + +/*! + Returns \c true if this object points to a shortcut; + otherwise returns \c false. + + Shortcuts only exist on Windows and are typically \c .lnk files. + For instance, true will be returned for shortcuts (\c *.lnk files) on + Windows, but false will be returned on Unix (including \macos and iOS). + + The shortcut (.lnk) files are treated as regular files. Opening those will + open the \c .lnk file itself. In order to open the file a shortcut + references to, it must uses symLinkTarget() on a shortcut. + + \note Even if a shortcut (broken shortcut) points to a non existing file, + isShortcut() returns true. + + \sa isFile(), isDir(), isSymbolicLink(), symLinkTarget() +*/ +bool QFileInfo::isShortcut() const +{ + Q_D(const QFileInfo); + return d->checkAttribute<bool>( + QFileSystemMetaData::LegacyLinkType, + [d]() { return d->metaData.isLnkFile(); }, + [d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); }); +} + +/*! Returns \c true if the object points to a directory or to a symbolic link to a directory, and that directory is the root directory; otherwise returns \c false. diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index 111517325d..3ac028085a 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -111,6 +111,8 @@ public: bool isFile() const; bool isDir() const; bool isSymLink() const; + bool isSymbolicLink() const; + bool isShortcut() const; bool isRoot() const; bool isBundle() const; diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index b1c2d84cdb..7adaafea18 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -44,7 +44,7 @@ #include <QtCore/QFile> #include <QtCore/QDir> #include <QtCore/QMutex> -#include <QtCore/QMutexLocker> +#include <QtCore/private/qlocking_p.h> #include <QtCore/QUrl> #include <QtCore/QFileInfo> #include <QtCore/QLocale> @@ -312,7 +312,7 @@ void QFileSelector::setExtraSelectors(const QStringList &list) QStringList QFileSelector::allSelectors() const { Q_D(const QFileSelector); - QMutexLocker locker(&sharedDataMutex); + const auto locker = qt_scoped_lock(sharedDataMutex); QFileSelectorPrivate::updateSelectors(); return d->extras + sharedData->staticSelectors; } @@ -364,7 +364,7 @@ QStringList QFileSelectorPrivate::platformSelectors() void QFileSelectorPrivate::addStatics(const QStringList &statics) { - QMutexLocker locker(&sharedDataMutex); + const auto locker = qt_scoped_lock(sharedDataMutex); sharedData->preloadedStatics << statics; sharedData->staticSelectors.clear(); } diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index bdbd3ba868..1d42dbfc70 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -48,6 +48,7 @@ #include <qdatetime.h> #include <qdir.h> #include <qtextstream.h> +#include <private/qlocking_p.h> #include <qt_windows.h> @@ -423,7 +424,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, end = threads.constEnd(); for(jt = threads.constBegin(); jt != end; ++jt) { thread = *jt; - QMutexLocker locker(&(thread->mutex)); + const auto locker = qt_scoped_lock(thread->mutex); const auto hit = thread->handleForDir.find(QFileSystemWatcherPathKey(absolutePath)); if (hit != thread->handleForDir.end() && hit.value().flags < flags) { @@ -478,7 +479,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, // now look for a thread to insert bool found = false; for (QWindowsFileSystemWatcherEngineThread *thread : qAsConst(threads)) { - QMutexLocker locker(&(thread->mutex)); + const auto locker = qt_scoped_lock(thread->mutex); if (thread->handles.count() < MAXIMUM_WAIT_OBJECTS) { DEBUG() << "Added handle" << handle.handle << "for" << absolutePath << "to watch" << fileInfo.absoluteFilePath() << "to existing thread " << thread; @@ -554,7 +555,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path if (*jt == 0) continue; - QMutexLocker locker(&(thread->mutex)); + auto locker = qt_unique_lock(thread->mutex); QWindowsFileSystemWatcherEngine::Handle handle = thread->handleForDir.value(QFileSystemWatcherPathKey(absolutePath)); if (handle.handle == INVALID_HANDLE_VALUE) { @@ -587,7 +588,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path locker.unlock(); thread->stop(); thread->wait(); - locker.relock(); + locker.lock(); // We can't delete the thread until the mutex locker is // out of scope } @@ -652,13 +653,13 @@ static QString msgFindNextFailed(const QWindowsFileSystemWatcherEngineThread::Pa void QWindowsFileSystemWatcherEngineThread::run() { - QMutexLocker locker(&mutex); + auto locker = qt_unique_lock(mutex); forever { QVector<HANDLE> handlesCopy = handles; locker.unlock(); DEBUG() << "QWindowsFileSystemWatcherThread" << this << "waiting on" << handlesCopy.count() << "handles"; DWORD r = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, INFINITE); - locker.relock(); + locker.lock(); do { if (r == WAIT_OBJECT_0) { int m = msg; diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 7849dfd14c..e8eb18b4c1 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -41,6 +41,7 @@ #include <QtCore/qfile.h> #include <QtCore/qlibraryinfo.h> +#include <QtCore/private/qlocking_p.h> #include <QtCore/qstandardpaths.h> #include <QtCore/qtextstream.h> #include <QtCore/qdir.h> @@ -356,7 +357,7 @@ void QLoggingRegistry::initializeRules() */ void QLoggingRegistry::registerCategory(QLoggingCategory *cat, QtMsgType enableForLevel) { - QMutexLocker locker(®istryMutex); + const auto locker = qt_scoped_lock(registryMutex); if (!categories.contains(cat)) { categories.insert(cat, enableForLevel); @@ -370,7 +371,7 @@ void QLoggingRegistry::registerCategory(QLoggingCategory *cat, QtMsgType enableF */ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat) { - QMutexLocker locker(®istryMutex); + const auto locker = qt_scoped_lock(registryMutex); categories.remove(cat); } @@ -413,7 +414,7 @@ void QLoggingRegistry::updateRules() QLoggingCategory::CategoryFilter QLoggingRegistry::installFilter(QLoggingCategory::CategoryFilter filter) { - QMutexLocker locker(®istryMutex); + const auto locker = qt_scoped_lock(registryMutex); if (!filter) filter = defaultCategoryFilter; diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 951fc4ccaa..0c80daa024 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -89,6 +89,7 @@ QT_END_NAMESPACE #include "qprocess_p.h" #include "qstandardpaths.h" #include "private/qcore_unix_p.h" +#include "private/qlocking_p.h" #ifdef Q_OS_MAC #include <private/qcore_mac_p.h> @@ -404,7 +405,7 @@ void QProcessPrivate::startProcess() // CFBundle is not reentrant, since CFBundleCreate might return a reference // to a cached bundle object. Protect the bundle calls with a mutex lock. static QBasicMutex cfbundleMutex; - QMutexLocker lock(&cfbundleMutex); + const auto locker = qt_scoped_lock(cfbundleMutex); QCFType<CFBundleRef> bundle = CFBundleCreate(0, url); // 'executableURL' can be either relative or absolute ... QCFType<CFURLRef> executableURL = CFBundleCopyExecutableURL(bundle); diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 52b746d04a..22c22ce711 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -42,7 +42,7 @@ #include "qresource_p.h" #include "qresource_iterator_p.h" #include "qset.h" -#include "qmutex.h" +#include <private/qlocking_p.h> #include "qdebug.h" #include "qlocale.h" #include "qglobal.h" @@ -203,8 +203,8 @@ struct QResourceGlobalData }; Q_GLOBAL_STATIC(QResourceGlobalData, resourceGlobalData) -static inline QRecursiveMutex *resourceMutex() -{ return &resourceGlobalData->resourceMutex; } +static inline QRecursiveMutex &resourceMutex() +{ return resourceGlobalData->resourceMutex; } static inline ResourceList *resourceList() { return &resourceGlobalData->resourceList; } @@ -337,7 +337,7 @@ bool QResourcePrivate::load(const QString &file) { related.clear(); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); const ResourceList *list = resourceList(); QString cleaned = cleanPath(file); for(int i = 0; i < list->size(); ++i) { @@ -392,7 +392,7 @@ QResourcePrivate::ensureInitialized() const if(path.startsWith(QLatin1Char('/'))) { that->load(path.toString()); } else { - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); QStringList searchPaths = *resourceSearchPaths(); searchPaths << QLatin1String(""); for(int i = 0; i < searchPaths.size(); ++i) { @@ -688,7 +688,7 @@ QResource::addSearchPath(const QString &path) path.toLocal8Bit().data()); return; } - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); resourceSearchPaths()->prepend(path); } @@ -706,7 +706,7 @@ QResource::addSearchPath(const QString &path) QStringList QResource::searchPaths() { - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); return *resourceSearchPaths(); } #endif @@ -950,7 +950,7 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree, { if (resourceGlobalData.isDestroyed()) return false; - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); ResourceList *list = resourceList(); if (version >= 0x01 && version <= 0x3) { bool found = false; @@ -977,7 +977,7 @@ Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tre if (resourceGlobalData.isDestroyed()) return false; - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); if (version >= 0x01 && version <= 0x3) { QResourceRoot res(version, tree, name, data); ResourceList *list = resourceList(); @@ -1198,7 +1198,7 @@ QResource::registerResource(const QString &rccFilename, const QString &resourceR QDynamicFileResourceRoot *root = new QDynamicFileResourceRoot(r); if(root->registerSelf(rccFilename)) { root->ref.ref(); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); resourceList()->append(root); return true; } @@ -1222,7 +1222,7 @@ QResource::unregisterResource(const QString &rccFilename, const QString &resourc { QString r = qt_resource_fixResourceRoot(resourceRoot); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); ResourceList *list = resourceList(); for(int i = 0; i < list->size(); ++i) { QResourceRoot *res = list->at(i); @@ -1269,7 +1269,7 @@ QResource::registerResource(const uchar *rccData, const QString &resourceRoot) QDynamicBufferResourceRoot *root = new QDynamicBufferResourceRoot(r); if (root->registerSelf(rccData, -1)) { root->ref.ref(); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); resourceList()->append(root); return true; } @@ -1293,7 +1293,7 @@ QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot) { QString r = qt_resource_fixResourceRoot(resourceRoot); - QMutexLocker lock(resourceMutex()); + const auto locker = qt_scoped_lock(resourceMutex()); ResourceList *list = resourceList(); for(int i = 0; i < list->size(); ++i) { QResourceRoot *res = list->at(i); diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index accde01f16..4a119a1e2f 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -47,6 +47,7 @@ #include "qdir.h" #include "qfileinfo.h" #include "qmutex.h" +#include "private/qlocking_p.h" #include "qlibraryinfo.h" #include "qtemporaryfile.h" #include "qstandardpaths.h" @@ -210,7 +211,7 @@ QConfFile *QConfFile::fromName(const QString &fileName, bool _userPerms) ConfFileCache *unusedCache = unusedCacheFunc(); QConfFile *confFile = 0; - QMutexLocker locker(&settingsGlobalMutex); + const auto locker = qt_scoped_lock(settingsGlobalMutex); if (!(confFile = usedHash->value(absPath))) { if ((confFile = unusedCache->take(absPath))) @@ -225,7 +226,7 @@ QConfFile *QConfFile::fromName(const QString &fileName, bool _userPerms) void QConfFile::clearCache() { - QMutexLocker locker(&settingsGlobalMutex); + const auto locker = qt_scoped_lock(settingsGlobalMutex); unusedCacheFunc()->clear(); } @@ -937,7 +938,7 @@ void QConfFileSettingsPrivate::initFormat() #endif if (format > QSettings::IniFormat) { - QMutexLocker locker(&settingsGlobalMutex); + const auto locker = qt_scoped_lock(settingsGlobalMutex); const CustomFormatVector *customFormatVector = customFormatVectorFunc(); int i = (int)format - (int)QSettings::CustomFormat1; @@ -1052,11 +1053,11 @@ static QString make_user_path() } #endif // !Q_OS_WIN -static void initDefaultPaths(QMutexLocker *locker) +static std::unique_lock<QBasicMutex> initDefaultPaths(std::unique_lock<QBasicMutex> locker) { PathHash *pathHash = pathHashFunc(); - locker->unlock(); + locker.unlock(); /* QLibraryInfo::location() uses QSettings, so in order to @@ -1065,7 +1066,7 @@ static void initDefaultPaths(QMutexLocker *locker) */ QString systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath) + QLatin1Char('/'); - locker->relock(); + locker.lock(); if (pathHash->isEmpty()) { /* Lazy initialization of pathHash. We initialize the @@ -1096,6 +1097,8 @@ static void initDefaultPaths(QMutexLocker *locker) #endif #endif // Q_OS_WIN } + + return locker; } static Path getPath(QSettings::Format format, QSettings::Scope scope) @@ -1103,10 +1106,10 @@ static Path getPath(QSettings::Format format, QSettings::Scope scope) Q_ASSERT((int)QSettings::NativeFormat == 0); Q_ASSERT((int)QSettings::IniFormat == 1); - QMutexLocker locker(&settingsGlobalMutex); + auto locker = qt_unique_lock(settingsGlobalMutex); PathHash *pathHash = pathHashFunc(); if (pathHash->isEmpty()) - initDefaultPaths(&locker); + locker = initDefaultPaths(std::move(locker)); Path result = pathHash->value(pathHashKey(format, scope)); if (!result.path.isEmpty()) @@ -1120,7 +1123,7 @@ static Path getPath(QSettings::Format format, QSettings::Scope scope) // Note: Suitable only for autotests. void Q_AUTOTEST_EXPORT clearDefaultPaths() { - QMutexLocker locker(&settingsGlobalMutex); + const auto locker = qt_scoped_lock(settingsGlobalMutex); pathHashFunc()->clear(); } #endif // QT_BUILD_INTERNAL && Q_XDG_PLATFORM && !QT_NO_STANDARDPATHS @@ -1200,7 +1203,7 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(const QString &fileName, QConfFileSettingsPrivate::~QConfFileSettingsPrivate() { - QMutexLocker locker(&settingsGlobalMutex); + const auto locker = qt_scoped_lock(settingsGlobalMutex); ConfFileHash *usedHash = usedHashFunc(); ConfFileCache *unusedCache = unusedCacheFunc(); @@ -1239,7 +1242,7 @@ void QConfFileSettingsPrivate::remove(const QString &key) QSettingsKey theKey(key, caseSensitivity); QSettingsKey prefix(key + QLatin1Char('/'), caseSensitivity); - QMutexLocker locker(&confFile->mutex); + const auto locker = qt_scoped_lock(confFile->mutex); ensureSectionParsed(confFile, theKey); ensureSectionParsed(confFile, prefix); @@ -1267,7 +1270,7 @@ void QConfFileSettingsPrivate::set(const QString &key, const QVariant &value) QConfFile *confFile = confFiles.at(0); QSettingsKey theKey(key, caseSensitivity, nextPosition++); - QMutexLocker locker(&confFile->mutex); + const auto locker = qt_scoped_lock(confFile->mutex); confFile->removedKeys.remove(theKey); confFile->addedKeys.insert(theKey, value); } @@ -1279,7 +1282,7 @@ bool QConfFileSettingsPrivate::get(const QString &key, QVariant *value) const bool found = false; for (auto confFile : qAsConst(confFiles)) { - QMutexLocker locker(&confFile->mutex); + const auto locker = qt_scoped_lock(confFile->mutex); if (!confFile->addedKeys.isEmpty()) { j = confFile->addedKeys.constFind(theKey); @@ -1312,7 +1315,7 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec int startPos = prefix.size(); for (auto confFile : qAsConst(confFiles)) { - QMutexLocker locker(&confFile->mutex); + const auto locker = qt_scoped_lock(confFile->mutex); if (thePrefix.isEmpty()) ensureAllSectionsParsed(confFile); @@ -1351,7 +1354,7 @@ void QConfFileSettingsPrivate::clear() // Note: First config file is always the most specific. QConfFile *confFile = confFiles.at(0); - QMutexLocker locker(&confFile->mutex); + const auto locker = qt_scoped_lock(confFile->mutex); ensureAllSectionsParsed(confFile); confFile->addedKeys.clear(); confFile->removedKeys = confFile->originalKeys; @@ -1363,7 +1366,7 @@ void QConfFileSettingsPrivate::sync() // error we just try to go on and make the best of it for (auto confFile : qAsConst(confFiles)) { - QMutexLocker locker(&confFile->mutex); + const auto locker = qt_scoped_lock(confFile->mutex); syncConfFile(confFile); } } @@ -3521,10 +3524,10 @@ void QSettings::setUserIniPath(const QString &dir) */ void QSettings::setPath(Format format, Scope scope, const QString &path) { - QMutexLocker locker(&settingsGlobalMutex); + auto locker = qt_unique_lock(settingsGlobalMutex); PathHash *pathHash = pathHashFunc(); if (pathHash->isEmpty()) - initDefaultPaths(&locker); + locker = initDefaultPaths(std::move(locker)); pathHash->insert(pathHashKey(format, scope), Path(path + QDir::separator(), true)); } @@ -3604,7 +3607,7 @@ QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc r Q_ASSERT(caseSensitivity == Qt::CaseSensitive); #endif - QMutexLocker locker(&settingsGlobalMutex); + const auto locker = qt_scoped_lock(settingsGlobalMutex); CustomFormatVector *customFormatVector = customFormatVectorFunc(); int index = customFormatVector->size(); if (index == 16) // the QSettings::Format enum has room for 16 custom formats |