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>
This commit is contained in:
parent
48c5780d5f
commit
4906b43b00
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -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
|
@ -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 <QtCore/private/qglobal_p.h>
|
||||
#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<QString, QStringList> dirSearchPaths;
|
||||
QReadWriteLock dirSearchPathsLock;
|
||||
|
||||
static QCoreGlobalData *instance();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif // QCOREGLOBALDATA_P_H
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user