diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/doc/src/cpp20-overview.qdoc | 10 | ||||
-rw-r--r-- | src/corelib/io/qdebug.cpp | 18 | ||||
-rw-r--r-- | src/corelib/platform/windows/qcomobject_p.h | 18 | ||||
-rw-r--r-- | src/corelib/serialization/qtextstream.cpp | 6 | ||||
-rw-r--r-- | src/corelib/serialization/qtextstream_p.h | 2 | ||||
-rw-r--r-- | src/dbus/qdbusargument.h | 6 | ||||
-rw-r--r-- | src/dbus/qdbusconnectionmanager.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 4 | ||||
-rw-r--r-- | src/network/kernel/qnetworkproxy_android.cpp | 3 |
9 files changed, 46 insertions, 25 deletions
diff --git a/src/corelib/doc/src/cpp20-overview.qdoc b/src/corelib/doc/src/cpp20-overview.qdoc index ed48e10f94a..1231394c161 100644 --- a/src/corelib/doc/src/cpp20-overview.qdoc +++ b/src/corelib/doc/src/cpp20-overview.qdoc @@ -12,6 +12,16 @@ This page gives a brief overview of C++20 features available in Qt. + \section1 WebEngine and Module-Specific Requirements + + While Qt 6 only requires a C++17-compatible compiler in general, + the \l{Qt WebEngine} module requires a C++20-compatible compiler + due to its dependencies (such as Chromium). + + If you are building Qt WebEngine, ensure that your compiler fully supports C++20. + + See \l{qtwebengine-platform-notes.html}{Qt WebEngine Platform Notes} for detailed requirements. + \section1 Support for \c{std::chrono} Various classes related to date and time have support for \l diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 645f27798c4..5d6b5e06be6 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -200,7 +200,7 @@ template <typename Char> static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, size_t length, bool isUnicode = true) { QChar quote(u'"'); - d->write("e, 1); + d->write(quote); bool lastWasHexEscape = false; const Char *end = begin + length; @@ -227,8 +227,7 @@ static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, si continue; } } else if (isPrintable(*p) && *p != '\\' && *p != '"') { - QChar c = QLatin1Char(*p); - d->write(&c, 1); + d->write(char16_t{uchar(*p)}); continue; } @@ -302,7 +301,7 @@ static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, si d->write(reinterpret_cast<QChar *>(buf), buflen); } - d->write("e, 1); + d->write(quote); } /*! @@ -332,9 +331,14 @@ void QDebug::putByteArray(const char *begin, size_t length, Latin1Content conten if (stream->noQuotes) { // no quotes, write the string directly too (no pretty-printing) // this respects the QTextStream state, though - QString string = content == ContainsLatin1 ? QString::fromLatin1(begin, qsizetype(length)) - : QString::fromUtf8(begin, qsizetype(length)); - stream->ts.d_ptr->putString(string); + switch (content) { + case Latin1Content::ContainsLatin1: + stream->ts.d_ptr->putString(QLatin1StringView{begin, qsizetype(length)}); + break; + case Latin1Content::ContainsBinary: + stream->ts.d_ptr->putString(QUtf8StringView{begin, qsizetype(length)}); + break; + } } else { // we'll reset the QTextStream formatting mechanisms, so save the state QDebugStateSaver saver(*this); diff --git a/src/corelib/platform/windows/qcomobject_p.h b/src/corelib/platform/windows/qcomobject_p.h index bbf7796445d..bd6f81d1c28 100644 --- a/src/corelib/platform/windows/qcomobject_p.h +++ b/src/corelib/platform/windows/qcomobject_p.h @@ -80,18 +80,21 @@ public: return tryQueryInterface<TFirstInterface, TAdditionalInterfaces...>(riid, ppvObject); } - // clang-format off STDMETHODIMP_(ULONG) AddRef() override { - return ++m_referenceCount; + return m_referenceCount.fetch_add(1, std::memory_order_relaxed) + 1; } - // clang-format on STDMETHODIMP_(ULONG) Release() override { - const LONG referenceCount = --m_referenceCount; - if (referenceCount == 0) + const LONG referenceCount = m_referenceCount.fetch_sub(1, std::memory_order_release) - 1; + if (referenceCount == 0) { + // This acquire fence synchronizes with the release operation in other threads. + // It ensures that all memory writes made to this object by other threads + // are visible to this thread before we proceed to delete it. + std::atomic_thread_fence(std::memory_order_acquire); delete this; + } return referenceCount; } @@ -103,6 +106,9 @@ protected: // Derived class should make its destructor private to force this behavior. virtual ~QComObject() = default; + // allow derived classes to access the reference count + std::atomic<LONG> m_referenceCount = 1; + private: template <typename TInterface, typename... TRest> HRESULT tryQueryInterface(REFIID riid, void **ppvObject) @@ -121,8 +127,6 @@ private: return E_NOINTERFACE; } - - std::atomic<LONG> m_referenceCount = 1; }; QT_END_NAMESPACE diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index 5e0eff698f9..e4dc98af98b 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -711,7 +711,7 @@ void QTextStreamPrivate::write(const QChar *data, qsizetype len) /*! \internal */ -inline void QTextStreamPrivate::write(QChar ch) +void QTextStreamPrivate::write(QChar ch) { if (string) { // ### What about seek()?? @@ -845,7 +845,7 @@ void QTextStreamPrivate::putString(const QChar *data, qsizetype len, bool number const QChar sign = len > 0 ? data[0] : QChar(); if (sign == locale.negativeSign() || sign == locale.positiveSign()) { // write the sign before the padding, then skip it later - write(&sign, 1); + write(sign); ++data; --len; } @@ -874,7 +874,7 @@ void QTextStreamPrivate::putString(QLatin1StringView data, bool number) const QChar sign = data.size() > 0 ? QLatin1Char(*data.data()) : QChar(); if (sign == locale.negativeSign() || sign == locale.positiveSign()) { // write the sign before the padding, then skip it later - write(&sign, 1); + write(sign); data = QLatin1StringView(data.data() + 1, data.size() - 1); } } diff --git a/src/corelib/serialization/qtextstream_p.h b/src/corelib/serialization/qtextstream_p.h index 7227c29c8fe..bf3ce7b2ef7 100644 --- a/src/corelib/serialization/qtextstream_p.h +++ b/src/corelib/serialization/qtextstream_p.h @@ -145,7 +145,7 @@ public: bool getReal(double *f); inline void write(QStringView data) { write(data.begin(), data.size()); } - inline void write(QChar ch); + void write(QChar ch); void write(const QChar *data, qsizetype len); void write(QLatin1StringView data); void writePadding(qsizetype len); diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index 8370de74bb6..f04cbc1ed43 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -15,6 +15,8 @@ #include <QtCore/qvariant.h> #include <QtDBus/qdbusextratypes.h> +#include <tuple> + #ifndef QT_NO_DBUS QT_BEGIN_NAMESPACE @@ -324,7 +326,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, std::pair<T1, T template <typename... T> QDBusArgument &operator<<(QDBusArgument &argument, const std::tuple<T...> &tuple) { - static_assert(std::tuple_size_v<std::tuple<T...>> != 0, "D-Bus doesn't allow empty structs"); + static_assert(sizeof...(T) != 0, "D-Bus doesn't allow empty structs"); argument.beginStructure(); std::apply([&argument](const auto &...elements) { (argument << ... << elements); }, tuple); argument.endStructure(); @@ -334,7 +336,7 @@ QDBusArgument &operator<<(QDBusArgument &argument, const std::tuple<T...> &tuple template <typename... T> const QDBusArgument &operator>>(const QDBusArgument &argument, std::tuple<T...> &tuple) { - static_assert(std::tuple_size_v<std::tuple<T...>> != 0, "D-Bus doesn't allow empty structs"); + static_assert(sizeof...(T) != 0, "D-Bus doesn't allow empty structs"); argument.beginStructure(); std::apply([&argument](auto &...elements) { (argument >> ... >> elements); }, tuple); argument.endStructure(); diff --git a/src/dbus/qdbusconnectionmanager.cpp b/src/dbus/qdbusconnectionmanager.cpp index 73f11d82280..d41178b5c30 100644 --- a/src/dbus/qdbusconnectionmanager.cpp +++ b/src/dbus/qdbusconnectionmanager.cpp @@ -32,8 +32,8 @@ QDBusConnectionPrivate *QDBusConnectionManager::busConnection(QDBusConnection::B return nullptr; // we'll start in suspended delivery mode if we're in the main thread - // (the event loop will resume delivery) - bool suspendedDelivery = QThread::isMainThread(); + // (the event loop will resume delivery) and QCoreApplication already exists + bool suspendedDelivery = QThread::isMainThread() && qApp; const auto locker = qt_scoped_lock(defaultBusMutex); if (defaultBuses[type]) diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 59c469ae6b6..b53e1a63870 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -552,7 +552,7 @@ void QSurfaceFormat::setAlphaBufferSize(int size) and used choice is the former (16-bit), for example when high dynamic range rendering is desired. - \since 6.10 + \since 6.11 \sa colorComponentType() */ @@ -567,7 +567,7 @@ void QSurfaceFormat::setColorComponentType(ColorComponentType type) /*! \return the color component type. - \since 6.10 + \since 6.11 \sa setColorComponentType() */ diff --git a/src/network/kernel/qnetworkproxy_android.cpp b/src/network/kernel/qnetworkproxy_android.cpp index d5b56bba865..2261572fea7 100644 --- a/src/network/kernel/qnetworkproxy_android.cpp +++ b/src/network/kernel/qnetworkproxy_android.cpp @@ -3,6 +3,7 @@ #include "qnetworkproxy.h" +#include <QtCore/qapplicationstatic.h> #include <QtCore/qcoreapplication_platform.h> #include <QtCore/qjnienvironment.h> #include <QtCore/qjniobject.h> @@ -21,7 +22,7 @@ public: using namespace QNativeInterface; using namespace QtJniTypes; -Q_GLOBAL_STATIC(ProxyInfoObject, proxyInfoInstance) +Q_APPLICATION_STATIC(ProxyInfoObject, proxyInfoInstance) Q_DECLARE_JNI_CLASS(QtNetwork, "org/qtproject/qt/android/network/QtNetwork") Q_DECLARE_JNI_CLASS(ProxyInfo, "android/net/ProxyInfo") |