diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2022-08-18 09:16:40 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2022-08-21 08:29:37 +0200 |
| commit | 4906b43b0055aef027a43044c22374a5fc31df44 (patch) | |
| tree | 68e3641d8d37f3f34ea5b09c7a4047c832b7ee89 /src/corelib/io/qdir.cpp | |
| parent | 48c5780d5f804fb001525438ef576f61897b196f (diff) | |
QCoreGlobalData: remove
Inline the data members into the only remaining user (qdir.cpp) and
remove the class.
As a drive-by, fix the non-idiomatic use of QT_BUILD_CORE_LIB to mean
!QT_BOOTSTRAPPED and apply the guard consistently to the declaration,
too.
Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-105747
Change-Id: If2c780dd96e2a2e331cabdc42fd920874e7737b0
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/io/qdir.cpp')
| -rw-r--r-- | src/corelib/io/qdir.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index dc0461a1e2c..694f0ef87dc 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -21,8 +21,8 @@ #include "qfilesystemengine_p.h" #include <qstringbuilder.h> -#ifdef QT_BUILD_CORE_LIB -# include "private/qcoreglobaldata_p.h" +#ifndef QT_BOOTSTRAPPED +# include "qreadwritelock.h" #endif #include <algorithm> @@ -1019,7 +1019,17 @@ void QDir::setNameFilters(const QStringList &nameFilters) d->nameFilters = nameFilters; } -#ifdef QT_BUILD_CORE_LIB +#ifndef QT_BOOTSTRAPPED + +namespace { +struct DirSearchPaths { + mutable QReadWriteLock mutex; + QHash<QString, QStringList> paths; +}; +} + +Q_GLOBAL_STATIC(DirSearchPaths, dirSearchPaths) + /*! \since 4.3 @@ -1054,12 +1064,12 @@ void QDir::setSearchPaths(const QString &prefix, const QStringList &searchPaths) } } - QWriteLocker lock(&QCoreGlobalData::instance()->dirSearchPathsLock); - QHash<QString, QStringList> &paths = QCoreGlobalData::instance()->dirSearchPaths; + DirSearchPaths &conf = *dirSearchPaths; + const QWriteLocker lock(&conf.mutex); if (searchPaths.isEmpty()) { - paths.remove(prefix); + conf.paths.remove(prefix); } else { - paths.insert(prefix, searchPaths); + conf.paths.insert(prefix, searchPaths); } } @@ -1075,8 +1085,9 @@ void QDir::addSearchPath(const QString &prefix, const QString &path) if (path.isEmpty()) return; - QWriteLocker lock(&QCoreGlobalData::instance()->dirSearchPathsLock); - QCoreGlobalData::instance()->dirSearchPaths[prefix] += path; + DirSearchPaths &conf = *dirSearchPaths; + const QWriteLocker lock(&conf.mutex); + conf.paths[prefix] += path; } /*! @@ -1088,11 +1099,15 @@ void QDir::addSearchPath(const QString &prefix, const QString &path) */ QStringList QDir::searchPaths(const QString &prefix) { - QReadLocker lock(&QCoreGlobalData::instance()->dirSearchPathsLock); - return QCoreGlobalData::instance()->dirSearchPaths.value(prefix); + if (!dirSearchPaths.exists()) + return QStringList(); + + const DirSearchPaths &conf = *dirSearchPaths; + const QReadLocker lock(&conf.mutex); + return conf.paths.value(prefix); } -#endif // QT_BUILD_CORE_LIB +#endif // QT_BOOTSTRAPPED /*! Returns the value set by setFilter() |
