Apply Q_CONSTINIT across the codebase
Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
9578a3f72f
commit
32692667a6
@ -2826,7 +2826,7 @@ MakefileGenerator::writeMakeQmake(QTextStream &t, bool noDummyQmakeAll)
|
||||
QFileInfo
|
||||
MakefileGenerator::fileInfo(QString file) const
|
||||
{
|
||||
static QHash<FileInfoCacheKey, QFileInfo> *cache = nullptr;
|
||||
Q_CONSTINIT static QHash<FileInfoCacheKey, QFileInfo> *cache = nullptr;
|
||||
static QFileInfo noInfo = QFileInfo();
|
||||
if(!cache) {
|
||||
cache = new QHash<FileInfoCacheKey, QFileInfo>;
|
||||
|
@ -326,7 +326,7 @@ SubdirsMetaMakefileGenerator::init()
|
||||
if(!thispwd.endsWith('/'))
|
||||
thispwd += '/';
|
||||
const ProStringList &subdirs = project->values("SUBDIRS");
|
||||
static int recurseDepth = -1;
|
||||
Q_CONSTINIT static int recurseDepth = -1;
|
||||
++recurseDepth;
|
||||
for(int i = 0; i < subdirs.size(); ++i) {
|
||||
Subdir *sub = new Subdir;
|
||||
|
@ -336,14 +336,12 @@ static QString vcCommandSeparator()
|
||||
// of the custom commands into it, and putting an "if errorlevel goto" statement behind it.
|
||||
// As we want every sub-command to be error-checked (as is done by makefile-based
|
||||
// backends), we insert the checks ourselves, using the undocumented jump target.
|
||||
static QString cmdSep =
|
||||
QLatin1String("
if errorlevel 1 goto VCReportError
");
|
||||
return cmdSep;
|
||||
return QStringLiteral("
if errorlevel 1 goto VCReportError
");
|
||||
}
|
||||
|
||||
static void unknownOptionWarning(const char *tool, const char *option)
|
||||
{
|
||||
static bool firstCall = true;
|
||||
Q_CONSTINIT static bool firstCall = true;
|
||||
warn_msg(WarnLogic, "Could not parse %s option '%s'; added to AdditionalOptions.", tool, option);
|
||||
if (firstCall) {
|
||||
firstCall = false;
|
||||
|
@ -631,7 +631,7 @@ public:
|
||||
*data = nullptr;
|
||||
}
|
||||
};
|
||||
static QList<QMakeCacheClearItem*> cache_items;
|
||||
Q_CONSTINIT static QList<QMakeCacheClearItem*> cache_items;
|
||||
|
||||
void
|
||||
qmakeClearCaches()
|
||||
|
@ -293,7 +293,7 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState,
|
||||
auto locker = qt_unique_lock(mutex);
|
||||
typedef QPair<QObject *, QByteArray> QPropertyAnimationPair;
|
||||
typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash;
|
||||
static QPropertyAnimationHash hash;
|
||||
Q_CONSTINIT static QPropertyAnimationHash hash;
|
||||
|
||||
// in case the targetObject gets deleted, the following happens:
|
||||
// 1. targetObject's destroyed signal calls our targetObjectDestroyed.
|
||||
|
@ -287,7 +287,7 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
|
||||
localProgress);
|
||||
qSwap(currentValue, ret);
|
||||
q->updateCurrentValue(currentValue);
|
||||
static QBasicAtomicInt changedSignalIndex = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_CONSTINIT static QBasicAtomicInt changedSignalIndex = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
if (!changedSignalIndex.loadRelaxed()) {
|
||||
//we keep the mask so that we emit valueChanged only when needed (for performance reasons)
|
||||
changedSignalIndex.testAndSetRelaxed(0, signalIndex("valueChanged(QVariant)"));
|
||||
|
@ -1568,7 +1568,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
|
||||
static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &buf);
|
||||
|
||||
// pointer to QtMessageHandler debug handler (with context)
|
||||
static QBasicAtomicPointer<void (QtMsgType, const QMessageLogContext &, const QString &)> messageHandler = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
|
||||
Q_CONSTINIT static QBasicAtomicPointer<void (QtMsgType, const QMessageLogContext &, const QString &)> messageHandler = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
|
||||
|
||||
// ------------------------ Alternate logging sinks -------------------------
|
||||
|
||||
@ -1873,7 +1873,7 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
|
||||
|
||||
#if defined(Q_COMPILER_THREAD_LOCAL)
|
||||
|
||||
static thread_local bool msgHandlerGrabbed = false;
|
||||
Q_CONSTINIT static thread_local bool msgHandlerGrabbed = false;
|
||||
|
||||
static bool grabMessageHandler()
|
||||
{
|
||||
|
@ -229,7 +229,7 @@ static void fallback_fill(quint32 *ptr, qsizetype left) noexcept
|
||||
arc4random_buf(ptr, left * sizeof(*ptr));
|
||||
}
|
||||
#else
|
||||
static QBasicAtomicInteger<unsigned> seed = Q_BASIC_ATOMIC_INITIALIZER(0U);
|
||||
Q_CONSTINIT static QBasicAtomicInteger<unsigned> seed = Q_BASIC_ATOMIC_INITIALIZER(0U);
|
||||
static void fallback_update_seed(unsigned value)
|
||||
{
|
||||
// Update the seed to be used for the fallback mechanism, if we need to.
|
||||
@ -379,7 +379,7 @@ struct QRandomGenerator::SystemAndGlobalGenerators
|
||||
|
||||
static SystemAndGlobalGenerators *self()
|
||||
{
|
||||
static SystemAndGlobalGenerators g;
|
||||
Q_CONSTINIT static SystemAndGlobalGenerators g;
|
||||
static_assert(sizeof(g) > sizeof(QRandomGenerator64));
|
||||
return &g;
|
||||
}
|
||||
|
@ -101,14 +101,14 @@ QT_BEGIN_NAMESPACE
|
||||
\sa QAbstractFileEngine, QAbstractFileEngine::create()
|
||||
*/
|
||||
|
||||
static QBasicAtomicInt qt_file_engine_handlers_in_use = Q_BASIC_ATOMIC_INITIALIZER(false);
|
||||
Q_CONSTINIT static QBasicAtomicInt qt_file_engine_handlers_in_use = Q_BASIC_ATOMIC_INITIALIZER(false);
|
||||
|
||||
/*
|
||||
All application-wide handlers are stored in this list. The mutex must be
|
||||
acquired to ensure thread safety.
|
||||
*/
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QReadWriteLock, fileEngineHandlerMutex, (QReadWriteLock::Recursive))
|
||||
static bool qt_abstractfileenginehandlerlist_shutDown = false;
|
||||
Q_CONSTINIT static bool qt_abstractfileenginehandlerlist_shutDown = false;
|
||||
class QAbstractFileEngineHandlerList : public QList<QAbstractFileEngineHandler *>
|
||||
{
|
||||
public:
|
||||
|
@ -2434,7 +2434,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
|
||||
# include <crt_externs.h>
|
||||
# define environ (*_NSGetEnviron())
|
||||
#elif defined(QT_PLATFORM_UIKIT)
|
||||
static char *qt_empty_environ[] = { 0 };
|
||||
Q_CONSTINIT static char *qt_empty_environ[] = { 0 };
|
||||
#define environ qt_empty_environ
|
||||
#elif !defined(Q_OS_WIN)
|
||||
extern char **environ;
|
||||
|
@ -134,7 +134,7 @@ Q_GLOBAL_STATIC(CustomFormatVector, customFormatVectorFunc)
|
||||
|
||||
Q_CONSTINIT static QBasicMutex settingsGlobalMutex;
|
||||
|
||||
static QSettings::Format globalDefaultFormat = QSettings::NativeFormat;
|
||||
Q_CONSTINIT static QSettings::Format globalDefaultFormat = QSettings::NativeFormat;
|
||||
|
||||
QConfFile::QConfFile(const QString &fileName, bool _userPerms)
|
||||
: name(fileName), size(0), ref(1), userPerms(_userPerms)
|
||||
|
@ -611,7 +611,7 @@ QString QStandardPaths::displayName(StandardLocation type)
|
||||
\include standardpath/functiondocs.qdocinc setTestModeEnabled
|
||||
*/
|
||||
|
||||
static bool qsp_testMode = false;
|
||||
Q_CONSTINIT static bool qsp_testMode = false;
|
||||
|
||||
void QStandardPaths::setTestModeEnabled(bool testMode)
|
||||
{
|
||||
|
@ -352,7 +352,7 @@ static constexpr auto idn_whitelist = qOffsetStringArray(
|
||||
"xn--xkc2al3hye2a" // Sri Lanka
|
||||
);
|
||||
|
||||
static QStringList *user_idn_whitelist = nullptr;
|
||||
Q_CONSTINIT static QStringList *user_idn_whitelist = nullptr;
|
||||
|
||||
static bool lessThan(const QChar *a, int l, const char *c)
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ enum {
|
||||
Size5 = QtTimerIdFreeListConstants::MaxIndex - Offset5
|
||||
};
|
||||
|
||||
const int QtTimerIdFreeListConstants::Sizes[QtTimerIdFreeListConstants::BlockCount] = {
|
||||
Q_CONSTINIT const int QtTimerIdFreeListConstants::Sizes[QtTimerIdFreeListConstants::BlockCount] = {
|
||||
Size0,
|
||||
Size1,
|
||||
Size2,
|
||||
|
@ -53,9 +53,9 @@ template <typename QAS> struct ApplicationHolder
|
||||
using Type = typename QAS::QAS_Type;
|
||||
using PlainType = std::remove_cv_t<Type>;
|
||||
|
||||
static inline std::aligned_union_t<1, PlainType> storage;
|
||||
static inline QBasicAtomicInteger<qint8> guard = { QtGlobalStatic::Uninitialized };
|
||||
static inline QBasicMutex mutex {};
|
||||
Q_CONSTINIT static inline std::aligned_union_t<1, PlainType> storage = {};
|
||||
Q_CONSTINIT static inline QBasicAtomicInteger<qint8> guard = { QtGlobalStatic::Uninitialized };
|
||||
Q_CONSTINIT static inline QBasicMutex mutex {};
|
||||
|
||||
static constexpr bool MutexLockIsNoexcept = noexcept(mutex.lock());
|
||||
static constexpr bool ConstructionIsNoexcept = noexcept(QAS::innerFunction(nullptr));
|
||||
|
@ -162,7 +162,7 @@ inline timeval timespecToTimeval(const timespec &ts)
|
||||
inline void qt_ignore_sigpipe()
|
||||
{
|
||||
// Set to ignore SIGPIPE once only.
|
||||
static QBasicAtomicInt atom = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_CONSTINIT static QBasicAtomicInt atom = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
if (!atom.loadRelaxed()) {
|
||||
// More than one thread could turn off SIGPIPE at the same time
|
||||
// But that's acceptable because they all would be doing the same
|
||||
|
@ -148,9 +148,9 @@ extern QString qAppFileName();
|
||||
# error "Bump QCoreApplicatoinPrivate::app_compile_version to QT_VERSION_CHECK(7, 0, 0)"
|
||||
#endif
|
||||
// We don't know exactly, but it's at least 6.0.0:
|
||||
int QCoreApplicationPrivate::app_compile_version = QT_VERSION_CHECK(6, 0, 0);
|
||||
Q_CONSTINIT int QCoreApplicationPrivate::app_compile_version = QT_VERSION_CHECK(6, 0, 0);
|
||||
|
||||
bool QCoreApplicationPrivate::setuidAllowed = false;
|
||||
Q_CONSTINIT bool QCoreApplicationPrivate::setuidAllowed = false;
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
#ifdef Q_OS_DARWIN
|
||||
@ -207,7 +207,7 @@ QString QCoreApplicationPrivate::appVersion() const
|
||||
}
|
||||
#endif // !Q_OS_WIN
|
||||
|
||||
QString *QCoreApplicationPrivate::cachedApplicationFilePath = nullptr;
|
||||
Q_CONSTINIT QString *QCoreApplicationPrivate::cachedApplicationFilePath = nullptr;
|
||||
|
||||
bool QCoreApplicationPrivate::checkInstance(const char *function)
|
||||
{
|
||||
@ -353,9 +353,9 @@ void Q_CORE_EXPORT qt_call_post_routines()
|
||||
#ifndef QT_NO_QOBJECT
|
||||
|
||||
// app starting up if false
|
||||
bool QCoreApplicationPrivate::is_app_running = false;
|
||||
Q_CONSTINIT bool QCoreApplicationPrivate::is_app_running = false;
|
||||
// app closing down if true
|
||||
bool QCoreApplicationPrivate::is_app_closing = false;
|
||||
Q_CONSTINIT bool QCoreApplicationPrivate::is_app_closing = false;
|
||||
|
||||
Q_CORE_EXPORT uint qGlobalPostedEventsCount()
|
||||
{
|
||||
@ -363,12 +363,12 @@ Q_CORE_EXPORT uint qGlobalPostedEventsCount()
|
||||
return currentThreadData->postEventList.size() - currentThreadData->postEventList.startOffset;
|
||||
}
|
||||
|
||||
QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = nullptr;
|
||||
Q_CONSTINIT QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = nullptr;
|
||||
|
||||
#endif // QT_NO_QOBJECT
|
||||
|
||||
QCoreApplication *QCoreApplication::self = nullptr;
|
||||
uint QCoreApplicationPrivate::attribs =
|
||||
Q_CONSTINIT QCoreApplication *QCoreApplication::self = nullptr;
|
||||
Q_CONSTINIT uint QCoreApplicationPrivate::attribs =
|
||||
(1 << Qt::AA_SynthesizeMouseForUnhandledTouchEvents) |
|
||||
(1 << Qt::AA_SynthesizeMouseForUnhandledTabletEvents);
|
||||
|
||||
@ -403,7 +403,7 @@ struct QCoreApplicationData {
|
||||
Q_GLOBAL_STATIC(QCoreApplicationData, coreappdata)
|
||||
|
||||
#ifndef QT_NO_QOBJECT
|
||||
static bool quitLockEnabled = true;
|
||||
Q_CONSTINIT static bool quitLockEnabled = true;
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
@ -536,7 +536,7 @@ void QCoreApplicationPrivate::eventDispatcherReady()
|
||||
{
|
||||
}
|
||||
|
||||
QBasicAtomicPointer<QThread> QCoreApplicationPrivate::theMainThread = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
|
||||
Q_CONSTINIT QBasicAtomicPointer<QThread> QCoreApplicationPrivate::theMainThread = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
|
||||
QThread *QCoreApplicationPrivate::mainThread()
|
||||
{
|
||||
Q_ASSERT(theMainThread.loadRelaxed() != nullptr);
|
||||
@ -592,7 +592,7 @@ QString qAppName()
|
||||
void QCoreApplicationPrivate::initLocale()
|
||||
{
|
||||
#if defined(Q_OS_UNIX) && !defined(QT_BOOTSTRAPPED)
|
||||
static bool qt_locale_initialized = false;
|
||||
Q_CONSTINIT static bool qt_locale_initialized = false;
|
||||
if (qt_locale_initialized)
|
||||
return;
|
||||
qt_locale_initialized = true;
|
||||
|
@ -499,7 +499,7 @@ struct QBasicAtomicBitField {
|
||||
|
||||
typedef QBasicAtomicBitField<QEvent::MaxUser - QEvent::User + 1> UserEventTypeRegistry;
|
||||
|
||||
static UserEventTypeRegistry userEventTypeRegistry {};
|
||||
Q_CONSTINIT static UserEventTypeRegistry userEventTypeRegistry {};
|
||||
|
||||
static inline int registerEventTypeZeroBased(int id) noexcept
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ static gboolean socketNotifierSourceDispatch(GSource *source, GSourceFunc, gpoin
|
||||
return true; // ??? don't remove, right?
|
||||
}
|
||||
|
||||
static GSourceFuncs socketNotifierSourceFuncs = {
|
||||
Q_CONSTINIT static GSourceFuncs socketNotifierSourceFuncs = {
|
||||
socketNotifierSourcePrepare,
|
||||
socketNotifierSourceCheck,
|
||||
socketNotifierSourceDispatch,
|
||||
@ -186,7 +186,7 @@ static gboolean timerSourceDispatch(GSource *source, GSourceFunc, gpointer)
|
||||
return true; // ??? don't remove, right again?
|
||||
}
|
||||
|
||||
static GSourceFuncs timerSourceFuncs = {
|
||||
Q_CONSTINIT static GSourceFuncs timerSourceFuncs = {
|
||||
timerSourcePrepare,
|
||||
timerSourceCheck,
|
||||
timerSourceDispatch,
|
||||
@ -233,7 +233,7 @@ static gboolean idleTimerSourceDispatch(GSource *source, GSourceFunc, gpointer)
|
||||
return true;
|
||||
}
|
||||
|
||||
static GSourceFuncs idleTimerSourceFuncs = {
|
||||
Q_CONSTINIT static GSourceFuncs idleTimerSourceFuncs = {
|
||||
idleTimerSourcePrepare,
|
||||
idleTimerSourceCheck,
|
||||
idleTimerSourceDispatch,
|
||||
@ -281,7 +281,7 @@ static gboolean postEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
|
||||
return true; // i dunno, george...
|
||||
}
|
||||
|
||||
static GSourceFuncs postEventSourceFuncs = {
|
||||
Q_CONSTINIT static GSourceFuncs postEventSourceFuncs = {
|
||||
postEventSourcePrepare,
|
||||
postEventSourceCheck,
|
||||
postEventSourceDispatch,
|
||||
|
@ -118,11 +118,12 @@ bool qt_asyncify_yield()
|
||||
|
||||
#endif // QT_HAVE_EMSCRIPTEN_ASYNCIFY
|
||||
|
||||
QEventDispatcherWasm *QEventDispatcherWasm::g_mainThreadEventDispatcher = nullptr;
|
||||
Q_CONSTINIT QEventDispatcherWasm *QEventDispatcherWasm::g_mainThreadEventDispatcher = nullptr;
|
||||
#if QT_CONFIG(thread)
|
||||
QVector<QEventDispatcherWasm *> QEventDispatcherWasm::g_secondaryThreadEventDispatchers;
|
||||
std::mutex QEventDispatcherWasm::g_secondaryThreadEventDispatchersMutex;
|
||||
Q_CONSTINIT QVector<QEventDispatcherWasm *> QEventDispatcherWasm::g_secondaryThreadEventDispatchers;
|
||||
Q_CONSTINIT std::mutex QEventDispatcherWasm::g_secondaryThreadEventDispatchersMutex;
|
||||
#endif
|
||||
// ### dynamic initialization:
|
||||
std::multimap<int, QSocketNotifier *> QEventDispatcherWasm::g_socketNotifiers;
|
||||
|
||||
QEventDispatcherWasm::QEventDispatcherWasm()
|
||||
|
@ -1548,8 +1548,8 @@ static const struct : QMetaTypeModuleHelper
|
||||
}
|
||||
} metatypeHelper = {};
|
||||
|
||||
Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeGuiHelper = nullptr;
|
||||
Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeWidgetsHelper = nullptr;
|
||||
Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeGuiHelper = nullptr;
|
||||
Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeWidgetsHelper = nullptr;
|
||||
|
||||
static const QMetaTypeModuleHelper *qModuleHelperForType(int type)
|
||||
{
|
||||
|
@ -1323,7 +1323,7 @@ struct QMetaTypeIdQObject<T*, QMetaType::PointerToQObject>
|
||||
|
||||
static int qt_metatype_id()
|
||||
{
|
||||
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
if (const int id = metatype_id.loadAcquire())
|
||||
return id;
|
||||
const char *const cName = T::staticMetaObject.className();
|
||||
@ -1345,7 +1345,7 @@ struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
|
||||
|
||||
static int qt_metatype_id()
|
||||
{
|
||||
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
if (const int id = metatype_id.loadAcquire())
|
||||
return id;
|
||||
const char *const cName = T::staticMetaObject.className();
|
||||
@ -1364,7 +1364,7 @@ struct QMetaTypeIdQObject<T*, QMetaType::PointerToGadget>
|
||||
|
||||
static int qt_metatype_id()
|
||||
{
|
||||
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
if (const int id = metatype_id.loadAcquire())
|
||||
return id;
|
||||
const char *const cName = T::staticMetaObject.className();
|
||||
@ -1386,7 +1386,7 @@ struct QMetaTypeIdQObject<T, QMetaType::IsEnumeration>
|
||||
|
||||
static int qt_metatype_id()
|
||||
{
|
||||
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
if (const int id = metatype_id.loadAcquire())
|
||||
return id;
|
||||
const char *eName = qt_getEnumName(T());
|
||||
@ -1421,7 +1421,7 @@ struct QMetaTypeIdQObject<T, QMetaType::IsEnumeration>
|
||||
enum { Defined = 1 }; \
|
||||
static int qt_metatype_id() \
|
||||
{ \
|
||||
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
|
||||
Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
|
||||
if (const int id = metatype_id.loadAcquire()) \
|
||||
return id; \
|
||||
constexpr auto arr = QtPrivate::typenameHelper<TYPE>(); \
|
||||
@ -1469,7 +1469,7 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
|
||||
}; \
|
||||
static int qt_metatype_id() \
|
||||
{ \
|
||||
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
|
||||
Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
|
||||
if (const int id = metatype_id.loadRelaxed()) \
|
||||
return id; \
|
||||
const char *tName = QMetaType::fromType<T>().name(); \
|
||||
@ -1497,7 +1497,7 @@ struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
|
||||
}; \
|
||||
static int qt_metatype_id() \
|
||||
{ \
|
||||
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
|
||||
Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
|
||||
if (const int id = metatype_id.loadAcquire()) \
|
||||
return id; \
|
||||
const char *tName = QMetaType::fromType<T>().name(); \
|
||||
@ -1545,7 +1545,7 @@ struct SharedPointerMetaTypeIdHelper<SMART_POINTER<T>, true> \
|
||||
}; \
|
||||
static int qt_metatype_id() \
|
||||
{ \
|
||||
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
|
||||
Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
|
||||
if (const int id = metatype_id.loadAcquire()) \
|
||||
return id; \
|
||||
const char * const cName = T::staticMetaObject.className(); \
|
||||
|
@ -198,7 +198,7 @@ struct QPropertyDelayedNotifications
|
||||
}
|
||||
};
|
||||
|
||||
static thread_local QBindingStatus bindingStatus;
|
||||
Q_CONSTINIT static thread_local QBindingStatus bindingStatus;
|
||||
|
||||
/*!
|
||||
\since 6.2
|
||||
|
@ -89,6 +89,7 @@ QMimeDatabasePrivate::~QMimeDatabasePrivate()
|
||||
{
|
||||
}
|
||||
|
||||
Q_CONSTINIT
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
Q_CORE_EXPORT
|
||||
#else
|
||||
|
@ -50,7 +50,7 @@
|
||||
|
||||
//#define PARSER_DEBUG
|
||||
#ifdef PARSER_DEBUG
|
||||
static int indent = 0;
|
||||
Q_CONSTINIT static int indent = 0;
|
||||
#define BEGIN qDebug() << QByteArray(4*indent++, ' ').constData() << "pos=" << current
|
||||
#define END --indent
|
||||
#define DEBUG qDebug() << QByteArray(4*indent, ' ').constData()
|
||||
|
@ -70,7 +70,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
const char QByteArray::_empty = '\0';
|
||||
Q_CONSTINIT const char QByteArray::_empty = '\0';
|
||||
|
||||
// ASCII case system, used by QByteArray::to{Upper,Lower}() and qstr(n)icmp():
|
||||
static constexpr inline uchar asciiUpper(uchar c)
|
||||
|
@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
#ifndef QT_NO_SYSTEMLOCALE
|
||||
static QSystemLocale *_systemLocale = nullptr;
|
||||
Q_CONSTINIT static QSystemLocale *_systemLocale = nullptr;
|
||||
class QSystemLocaleSingleton: public QSystemLocale
|
||||
{
|
||||
public:
|
||||
@ -95,7 +95,7 @@ public:
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(QSystemLocaleSingleton, QSystemLocale_globalSystemLocale)
|
||||
static QLocaleData systemLocaleData;
|
||||
Q_CONSTINIT static QLocaleData systemLocaleData = {};
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
@ -695,7 +695,7 @@ int qt_repeatCount(QStringView s)
|
||||
return int(j);
|
||||
}
|
||||
|
||||
static const QLocaleData *default_data = nullptr;
|
||||
Q_CONSTINIT static const QLocaleData *default_data = nullptr;
|
||||
|
||||
static const QLocaleData *const c_data = locale_data;
|
||||
static QLocalePrivate *c_private()
|
||||
@ -852,7 +852,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
|
||||
|
||||
static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1;
|
||||
|
||||
QBasicAtomicInt QLocalePrivate::s_generation = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_CONSTINIT QBasicAtomicInt QLocalePrivate::s_generation = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate,
|
||||
(new QLocalePrivate(defaultData(), defaultIndex())))
|
||||
|
||||
|
@ -1404,12 +1404,12 @@ typedef int (*th_brk_def) (const unsigned char*, int*, size_t);
|
||||
typedef size_t (*th_next_cell_def) (const unsigned char *, size_t, struct thcell_t *, int);
|
||||
|
||||
/* libthai related function handles */
|
||||
static th_brk_def th_brk = nullptr;
|
||||
static th_next_cell_def th_next_cell = nullptr;
|
||||
Q_CONSTINIT static th_brk_def th_brk = nullptr;
|
||||
Q_CONSTINIT static th_next_cell_def th_next_cell = nullptr;
|
||||
|
||||
static int init_libthai() {
|
||||
#if QT_CONFIG(library)
|
||||
static bool initialized = false;
|
||||
Q_CONSTINIT static bool initialized = false;
|
||||
if (!initialized && (!th_brk || !th_next_cell)) {
|
||||
th_brk = reinterpret_cast<th_brk_def>(QLibrary::resolve("thai"_L1, static_cast<int>(LIBTHAI_MAJOR), "th_brk"));
|
||||
th_next_cell = (th_next_cell_def)QLibrary::resolve("thai"_L1, LIBTHAI_MAJOR, "th_next_cell");
|
||||
|
@ -835,7 +835,7 @@ struct FreeListConstants : QFreeListDefaultConstants {
|
||||
enum { BlockCount = 4, MaxIndex=0xffff };
|
||||
static const int Sizes[BlockCount];
|
||||
};
|
||||
const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {
|
||||
Q_CONSTINIT const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {
|
||||
16,
|
||||
128,
|
||||
1024,
|
||||
@ -844,7 +844,7 @@ const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {
|
||||
|
||||
typedef QFreeList<QMutexPrivate, FreeListConstants> FreeList;
|
||||
// We cannot use Q_GLOBAL_STATIC because it uses QMutex
|
||||
static FreeList freeList_;
|
||||
Q_CONSTINIT static FreeList freeList_;
|
||||
FreeList *freelist()
|
||||
{
|
||||
return &freeList_;
|
||||
|
@ -619,7 +619,7 @@ struct FreeListConstants : QFreeListDefaultConstants {
|
||||
enum { BlockCount = 4, MaxIndex=0xffff };
|
||||
static const int Sizes[BlockCount];
|
||||
};
|
||||
const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {
|
||||
Q_CONSTINIT const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {
|
||||
16,
|
||||
128,
|
||||
1024,
|
||||
|
@ -176,7 +176,7 @@ QThreadPrivate::QThreadPrivate(QThreadData *d)
|
||||
#ifdef Q_OS_INTEGRITY
|
||||
stackSize = 128 * 1024;
|
||||
#elif defined(Q_OS_RTEMS)
|
||||
static bool envStackSizeOk = false;
|
||||
Q_CONSTINIT static bool envStackSizeOk = false;
|
||||
static const int envStackSize = qEnvironmentVariableIntValue("QT_DEFAULT_THREAD_STACK_SIZE", &envStackSizeOk);
|
||||
if (envStackSizeOk)
|
||||
stackSize = envStackSize;
|
||||
@ -923,7 +923,7 @@ bool QThread::isRunning() const
|
||||
}
|
||||
|
||||
// No threads: so we can just use static variables
|
||||
static QThreadData *data = nullptr;
|
||||
Q_CONSTINIT static QThreadData *data = nullptr;
|
||||
|
||||
QThreadData *QThreadData::current(bool createIfNecessary)
|
||||
{
|
||||
|
@ -113,10 +113,10 @@ static_assert(sizeof(pthread_t) <= sizeof(Qt::HANDLE));
|
||||
enum { ThreadPriorityResetFlag = 0x80000000 };
|
||||
|
||||
|
||||
static thread_local QThreadData *currentThreadData = nullptr;
|
||||
Q_CONSTINIT static thread_local QThreadData *currentThreadData = nullptr;
|
||||
|
||||
static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT;
|
||||
static pthread_key_t current_thread_data_key;
|
||||
Q_CONSTINIT static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT;
|
||||
Q_CONSTINIT static pthread_key_t current_thread_data_key;
|
||||
|
||||
static void destroy_current_thread_data(void *p)
|
||||
{
|
||||
|
@ -1389,7 +1389,7 @@ QByteArray QTzTimeZonePrivate::staticSystemTimeZoneId()
|
||||
ianaId = ianaId.mid(1);
|
||||
|
||||
if (ianaId.isEmpty()) {
|
||||
thread_local static ZoneNameReader reader;
|
||||
Q_CONSTINIT thread_local static ZoneNameReader reader;
|
||||
ianaId = reader.name();
|
||||
}
|
||||
|
||||
|
@ -79,17 +79,17 @@ typedef HashReturn (SHA3Final)(hashState *state, BitSequence *hashval);
|
||||
|
||||
#include "../../3rdparty/sha3/KeccakF-1600-opt64.c"
|
||||
|
||||
static SHA3Init * const sha3Init = Init;
|
||||
static SHA3Update * const sha3Update = Update;
|
||||
static SHA3Final * const sha3Final = Final;
|
||||
Q_CONSTINIT static SHA3Init * const sha3Init = Init;
|
||||
Q_CONSTINIT static SHA3Update * const sha3Update = Update;
|
||||
Q_CONSTINIT static SHA3Final * const sha3Final = Final;
|
||||
|
||||
#else // 32 bit optimised fallback
|
||||
|
||||
#include "../../3rdparty/sha3/KeccakF-1600-opt32.c"
|
||||
|
||||
static SHA3Init * const sha3Init = Init;
|
||||
static SHA3Update * const sha3Update = Update;
|
||||
static SHA3Final * const sha3Final = Final;
|
||||
Q_CONSTINIT static SHA3Init * const sha3Init = Init;
|
||||
Q_CONSTINIT static SHA3Update * const sha3Update = Update;
|
||||
Q_CONSTINIT static SHA3Final * const sha3Final = Final;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -54,7 +54,7 @@ enum {
|
||||
Size3 = QFreeListDefaultConstants::MaxIndex - Offset3
|
||||
};
|
||||
|
||||
const int QFreeListDefaultConstants::Sizes[QFreeListDefaultConstants::BlockCount] = {
|
||||
Q_CONSTINIT const int QFreeListDefaultConstants::Sizes[QFreeListDefaultConstants::BlockCount] = {
|
||||
Size0,
|
||||
Size1,
|
||||
Size2,
|
||||
|
@ -204,6 +204,8 @@ inline HashSeedStorage::StateResult HashSeedStorage::state(int which)
|
||||
*/
|
||||
#ifdef Q_DECL_INIT_PRIORITY
|
||||
Q_DECL_INIT_PRIORITY(05)
|
||||
#else
|
||||
Q_CONSTINIT
|
||||
#endif
|
||||
static HashSeedStorage qt_qhash_seed;
|
||||
|
||||
|
@ -56,7 +56,7 @@ void (*qdbus_resolve_me(const char *name))();
|
||||
#if !defined QT_LINKED_LIBDBUS
|
||||
|
||||
#if QT_CONFIG(library)
|
||||
static QLibrary *qdbus_libdbus = nullptr;
|
||||
Q_CONSTINIT static QLibrary *qdbus_libdbus = nullptr;
|
||||
|
||||
void qdbus_unloadLibDBus()
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ struct TraceDBusCall
|
||||
|
||||
static inline ThreadData &td()
|
||||
{
|
||||
static thread_local ThreadData value;
|
||||
Q_CONSTINIT static thread_local ThreadData value;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ QT_BEGIN_NAMESPACE
|
||||
}
|
||||
|
||||
Q_CORE_EXPORT void qt_call_post_routines();
|
||||
Q_GUI_EXPORT bool qt_is_tty_app = false;
|
||||
Q_CONSTINIT Q_GUI_EXPORT bool qt_is_tty_app = false;
|
||||
|
||||
Q_CONSTINIT Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
|
||||
Q_CONSTINIT Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier;
|
||||
|
Loading…
Reference in New Issue
Block a user