diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index faaa0ff0210..5a12a07d891 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -133,7 +133,6 @@ qt_internal_add_module(Core kernel/qcoreapplication_platform.h kernel/qcorecmdlineargs_p.h kernel/qcoreevent.cpp kernel/qcoreevent.h - kernel/qcoreglobaldata.cpp kernel/qcoreglobaldata_p.h kernel/qdeadlinetimer.cpp kernel/qdeadlinetimer.h kernel/qdeadlinetimer_p.h kernel/qelapsedtimer.cpp kernel/qelapsedtimer.h kernel/qeventloop.cpp kernel/qeventloop.h kernel/qeventloop_p.h 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 -#ifdef QT_BUILD_CORE_LIB -# include "private/qcoreglobaldata_p.h" +#ifndef QT_BOOTSTRAPPED +# include "qreadwritelock.h" #endif #include @@ -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 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 &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() diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index ba03686f854..b516777fb8f 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -112,6 +112,7 @@ public: { return QtPrivate::toFilesystemPath(canonicalPath()); } #endif // QT_CONFIG(cxx17_filesystem) +#ifndef QT_BOOTSTRAPPED static void setSearchPaths(const QString &prefix, const QStringList &searchPaths); static void addSearchPath(const QString &prefix, const QString &path); #ifdef Q_CLANG_QDOC @@ -124,6 +125,7 @@ public: } #endif // QT_CONFIG(cxx17_filesystem) static QStringList searchPaths(const QString &prefix); +#endif // QT_BOOTSTRAPPED QString dirName() const; QString filePath(const QString &fileName) const; diff --git a/src/corelib/kernel/qcoreglobaldata.cpp b/src/corelib/kernel/qcoreglobaldata.cpp deleted file mode 100644 index d9ad6f27181..00000000000 --- a/src/corelib/kernel/qcoreglobaldata.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#include "qcoreglobaldata_p.h" - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QCoreGlobalData, globalInstance) - -QCoreGlobalData::QCoreGlobalData() -{ -} - -QCoreGlobalData::~QCoreGlobalData() -{ -} - -QCoreGlobalData *QCoreGlobalData::instance() -{ - return globalInstance(); -} - -QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcoreglobaldata_p.h b/src/corelib/kernel/qcoreglobaldata_p.h deleted file mode 100644 index 030f5ed2cbd..00000000000 --- a/src/corelib/kernel/qcoreglobaldata_p.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#ifndef QCOREGLOBALDATA_P_H -#define QCOREGLOBALDATA_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include "QtCore/qstringlist.h" -#include "QtCore/qreadwritelock.h" -#include "QtCore/qhash.h" -#include "QtCore/qbytearray.h" -#include "QtCore/qmutex.h" - -QT_BEGIN_NAMESPACE - -struct QCoreGlobalData -{ - QCoreGlobalData(); - ~QCoreGlobalData(); - - QHash dirSearchPaths; - QReadWriteLock dirSearchPathsLock; - - static QCoreGlobalData *instance(); -}; - -QT_END_NAMESPACE -#endif // QCOREGLOBALDATA_P_H diff --git a/src/tools/bootstrap/CMakeLists.txt b/src/tools/bootstrap/CMakeLists.txt index cac8689be31..4f0e1680bbf 100644 --- a/src/tools/bootstrap/CMakeLists.txt +++ b/src/tools/bootstrap/CMakeLists.txt @@ -44,7 +44,6 @@ qt_internal_extend_target(Bootstrap ../../corelib/io/qstandardpaths.cpp ../../corelib/io/qtemporaryfile.cpp ../../corelib/kernel/qcoreapplication.cpp - ../../corelib/kernel/qcoreglobaldata.cpp ../../corelib/kernel/qiterable.cpp ../../corelib/kernel/qmetacontainer.cpp ../../corelib/kernel/qmetatype.cpp