diff options
Diffstat (limited to 'src/corelib')
59 files changed, 208 insertions, 398 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 04643aec33..5ee7888d4f 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -826,6 +826,12 @@ ], "output": [ "publicFeature", "feature" ] }, + "shortcut": { + "label": "QShortcut", + "purpose": "Provides keyboard accelerators and shortcuts.", + "section": "Kernel", + "output": [ "publicFeature", "feature" ] + }, "systemsemaphore": { "label": "QSystemSemaphore", "purpose": "Provides a general counting system semaphore.", diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e47f284a42..ad3d2be69b 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -91,8 +91,6 @@ # define Q_OUTOFLINE_TEMPLATE inline # define Q_COMPILER_MANGLES_RETURN_TYPE # define Q_FUNC_INFO __FUNCSIG__ -# define Q_ALIGNOF(type) __alignof(type) -# define Q_DECL_ALIGN(n) __declspec(align(n)) # define Q_ASSUME_IMPL(expr) __assume(expr) # define Q_UNREACHABLE_IMPL() __assume(0) # define Q_NORETURN __declspec(noreturn) @@ -222,10 +220,8 @@ # endif # define Q_FUNC_INFO __PRETTY_FUNCTION__ -# define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__)) -# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) # define Q_DECL_UNUSED __attribute__((__unused__)) # define Q_LIKELY(expr) __builtin_expect(!!(expr), true) # define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false) @@ -272,9 +268,7 @@ # if __xlC__ < 0x400 # error "Compiler not supported" # elif __xlC__ >= 0x0600 -# define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) -# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) # define Q_PACKED __attribute__((__packed__)) # endif @@ -352,7 +346,6 @@ # define Q_PACKED __attribute__ ((__packed__)) # define Q_FUNC_INFO __PRETTY_FUNCTION__ # define Q_TYPEOF(expr) __typeof__(expr) -# define Q_ALIGNOF(type) __alignof__(type) # define Q_UNREACHABLE_IMPL() # if defined(__cplusplus) # define Q_COMPILER_AUTO_TYPE @@ -450,9 +443,7 @@ # define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS /* see http://developers.sun.com/sunstudio/support/Ccompare.html */ # if __SUNPRO_CC >= 0x590 -# define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) -# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) # endif # if __SUNPRO_CC >= 0x550 # define Q_DECL_EXPORT __global @@ -489,9 +480,6 @@ # define Q_DECL_EXPORT __declspec(dllexport) # define Q_DECL_IMPORT __declspec(dllimport) # endif -# if __HP_aCC-0 >= 061200 -# define Q_DECL_ALIGN(n) __attribute__((aligned(n))) -# endif # if __HP_aCC-0 >= 062000 # define Q_DECL_EXPORT __attribute__((visibility("default"))) # define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) @@ -1128,14 +1116,12 @@ #endif #define Q_DECL_NOTHROW Q_DECL_NOEXCEPT -#if defined(Q_COMPILER_ALIGNOF) -# undef Q_ALIGNOF -# define Q_ALIGNOF(x) alignof(x) +#ifndef Q_ALIGNOF +# define Q_ALIGNOF(x) alignof(x) #endif -#if defined(Q_COMPILER_ALIGNAS) -# undef Q_DECL_ALIGN -# define Q_DECL_ALIGN(n) alignas(n) +#ifndef Q_DECL_ALIGN +# define Q_DECL_ALIGN(n) alignas(n) #endif #if QT_HAS_CPP_ATTRIBUTE(nodiscard) && !defined(Q_CC_CLANG) // P0188R1 diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 81bf6f95ce..c58dc56c42 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -111,6 +111,7 @@ # define QT_FEATURE_renameat2 -1 #endif #define QT_FEATURE_sharedmemory -1 +#define QT_FEATURE_shortcut -1 #define QT_FEATURE_signaling_nan -1 #define QT_FEATURE_slog2 -1 #ifdef __GLIBC_PREREQ diff --git a/src/corelib/global/qendian.cpp b/src/corelib/global/qendian.cpp index 7fd6e13d3b..c56a7ffbf7 100644 --- a/src/corelib/global/qendian.cpp +++ b/src/corelib/global/qendian.cpp @@ -765,7 +765,7 @@ QT_BEGIN_NAMESPACE #if defined(__SSSE3__) using ShuffleMask = uchar[16]; -Q_DECL_ALIGN(16) static const ShuffleMask shuffleMasks[3] = { +alignas(16) static const ShuffleMask shuffleMasks[3] = { // 16-bit {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}, // 32-bit diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 4ab5bd2edb..799d953c8d 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1203,11 +1203,14 @@ bool qSharedBuild() noexcept the application is compiled (32 or 64). */ +#if QT_DEPRECATED_SINCE(5, 9) /*! \deprecated \variable QSysInfo::WindowsVersion \brief the version of the Windows operating system on which the application is run. + + Use QOperatingSystemVersion::current() instead. */ /*! @@ -1215,6 +1218,8 @@ bool qSharedBuild() noexcept \fn QSysInfo::WindowsVersion QSysInfo::windowsVersion() \since 4.4 + Use QOperatingSystemVersion::current() instead. + Returns the version of the Windows operating system on which the application is run, or WV_None if the operating system is not Windows. @@ -1225,16 +1230,21 @@ bool qSharedBuild() noexcept \variable QSysInfo::MacintoshVersion \brief the version of the Macintosh operating system on which the application is run. + + Use QOperatingSystemVersion::current() instead. */ /*! \deprecated \fn QSysInfo::MacVersion QSysInfo::macVersion() + Use QOperatingSystemVersion::current() instead. + Returns the version of Darwin (\macos or iOS) on which the application is run, or MV_None if the operating system is not a version of Darwin. */ +#endif /*! \enum QSysInfo::Endian @@ -1245,10 +1255,13 @@ bool qSharedBuild() noexcept the platform's byte order. */ +#if QT_DEPRECATED_SINCE(5, 9) /*! \deprecated \enum QSysInfo::WinVersion + Use the versions defined in QOperatingSystemVersion instead. + This enum provides symbolic names for the various versions of the Windows operating system. On Windows, the QSysInfo::WindowsVersion variable gives the version of the system @@ -1306,6 +1319,8 @@ bool qSharedBuild() noexcept \deprecated \enum QSysInfo::MacVersion + Use the versions defined in QOperatingSystemVersion instead. + This enum provides symbolic names for the various versions of the Darwin operating system, covering both \macos and iOS. The QSysInfo::MacintoshVersion variable gives the version of the @@ -1376,6 +1391,7 @@ bool qSharedBuild() noexcept \sa WinVersion */ +#endif /*! \macro Q_OS_DARWIN diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1e26e9453a..1803b686b9 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -87,7 +87,8 @@ #define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not available.") #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) -# define QT_NO_UNSHARABLE_CONTAINERS +// ### Qt6: FIXME and get rid of unsharable containers +//# define QT_NO_UNSHARABLE_CONTAINERS # define QT6_VIRTUAL virtual # define QT6_NOT_VIRTUAL #else @@ -498,53 +499,6 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT; # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) #endif -namespace QtPrivate { - template <class T> - struct AlignOfHelper - { - char c; - T type; - - AlignOfHelper(); - ~AlignOfHelper(); - }; - - template <class T> - struct AlignOf_Default - { - enum { Value = sizeof(AlignOfHelper<T>) - sizeof(T) }; - }; - - template <class T> struct AlignOf : AlignOf_Default<T> { }; - template <class T> struct AlignOf<T &> : AlignOf<T> {}; - template <class T> struct AlignOf<T &&> : AlignOf<T> {}; - template <size_t N, class T> struct AlignOf<T[N]> : AlignOf<T> {}; - -#if defined(Q_PROCESSOR_X86_32) && !defined(Q_OS_WIN) - template <class T> struct AlignOf_WorkaroundForI386Abi { enum { Value = sizeof(T) }; }; - - // x86 ABI weirdness - // Alignment of naked type is 8, but inside struct has alignment 4. - template <> struct AlignOf<double> : AlignOf_WorkaroundForI386Abi<double> {}; - template <> struct AlignOf<qint64> : AlignOf_WorkaroundForI386Abi<qint64> {}; - template <> struct AlignOf<quint64> : AlignOf_WorkaroundForI386Abi<quint64> {}; -#ifdef Q_CC_CLANG - // GCC and Clang seem to disagree wrt to alignment of arrays - template <size_t N> struct AlignOf<double[N]> : AlignOf_Default<double> {}; - template <size_t N> struct AlignOf<qint64[N]> : AlignOf_Default<qint64> {}; - template <size_t N> struct AlignOf<quint64[N]> : AlignOf_Default<quint64> {}; -#endif -#endif -} // namespace QtPrivate - -#define QT_EMULATED_ALIGNOF(T) \ - (size_t(QT_PREPEND_NAMESPACE(QtPrivate)::AlignOf<T>::Value)) - -#ifndef Q_ALIGNOF -#define Q_ALIGNOF(T) QT_EMULATED_ALIGNOF(T) -#endif - - /* quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e. diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index aa83cf2bcc..2da5861ccf 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -419,7 +419,6 @@ static const struct { #endif { "Binaries", "bin" }, { "Plugins", "plugins" }, // should be ${ArchData}/plugins - { "Imports", "imports" }, // should be ${ArchData}/imports { "Qml2Imports", "qml" }, // should be ${ArchData}/qml { "ArchData", "." }, { "Data", "." }, @@ -856,7 +855,6 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) \value LibraryExecutablesPath The location of installed executables required by libraries at runtime. \value BinariesPath The location of installed Qt binaries (tools and applications). \value PluginsPath The location of installed Qt plugins. - \value ImportsPath The location of installed QML extensions to import (QML 1.x). \value Qml2ImportsPath The location of installed QML extensions to import (QML 2.x). \value ArchDataPath The location of general architecture-dependent Qt data. \value DataPath The location of general architecture-independent Qt data. diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index ed60b170a5..031dfe37e2 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -79,7 +79,6 @@ public: LibraryExecutablesPath, BinariesPath, PluginsPath, - ImportsPath, Qml2ImportsPath, ArchDataPath, DataPath, diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 17f2246082..3a9ff1651b 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1307,7 +1307,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount) QString function = m.captured(2); // skip the trace from QtCore that are because of the qDebug itself - if (!numberPrinted && library.contains(QLatin1String("Qt5Core")) + if (!numberPrinted && library.contains(QLatin1String("Qt6Core")) && (function.isEmpty() || function.contains(QLatin1String("Message"), Qt::CaseInsensitive) || function.contains(QLatin1String("QDebug")))) { continue; diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 3cbd40b772..563e5eb7ed 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -355,7 +355,7 @@ struct QRandomGenerator::SystemAndGlobalGenerators // the state in case another thread tries to lock the mutex. It's not // a common scenario, but since sizeof(QRandomGenerator) >= 2560, the // overhead is actually acceptable. - // 2) We use both Q_DECL_ALIGN and std::aligned_storage<..., 64> because + // 2) We use both alignas and std::aligned_storage<..., 64> because // some implementations of std::aligned_storage can't align to more // than a primitive type's alignment. // 3) We don't store the entire system QRandomGenerator, only the space @@ -364,7 +364,7 @@ struct QRandomGenerator::SystemAndGlobalGenerators QBasicMutex globalPRNGMutex; struct ShortenedSystem { uint type; } system_; SystemGenerator sys; - Q_DECL_ALIGN(64) std::aligned_storage<sizeof(QRandomGenerator64), 64>::type global_; + alignas(64) std::aligned_storage<sizeof(QRandomGenerator64), 64>::type global_; #ifdef Q_COMPILER_CONSTEXPR constexpr SystemAndGlobalGenerators() diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 445b520c76..e1494ab523 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -196,7 +196,7 @@ private: RandomEngine &engine() { return twister; } const RandomEngine &engine() const { return twister; } #else - std::aligned_storage<sizeof(RandomEngine), Q_ALIGNOF(RandomEngine)>::type buffer; + std::aligned_storage<sizeof(RandomEngine), alignof(RandomEngine)>::type buffer; RandomEngine &engine() { return reinterpret_cast<RandomEngine &>(buffer); } const RandomEngine &engine() const { return reinterpret_cast<const RandomEngine &>(buffer); } #endif diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index 31c490de66..7adaafea18 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -342,7 +342,6 @@ void QFileSelectorPrivate::updateSelectors() QStringList QFileSelectorPrivate::platformSelectors() { // similar, but not identical to QSysInfo::osType - // ### Qt6: remove macOS fallbacks to "mac" and the future compatibility QStringList ret; #if defined(Q_OS_WIN) ret << QStringLiteral("windows"); @@ -355,16 +354,10 @@ QStringList QFileSelectorPrivate::platformSelectors() # if !defined(Q_OS_ANDROID) && !defined(Q_OS_QNX) // we don't want "linux" for Android or two instances of "qnx" for QNX ret << QSysInfo::kernelType(); -# ifdef Q_OS_MAC - ret << QStringLiteral("mac"); // compatibility, since kernelType() is "darwin" -# endif # endif QString productName = QSysInfo::productType(); if (productName != QLatin1String("unknown")) ret << productName; // "opensuse", "fedora", "osx", "ios", "android" -# if defined(Q_OS_MACOS) - ret << QStringLiteral("macos"); // future compatibility -# endif #endif return ret; } diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp index 74b7e820d9..ad6dbaba11 100644 --- a/src/corelib/io/qfilesystemiterator_unix.cpp +++ b/src/corelib/io/qfilesystemiterator_unix.cpp @@ -86,6 +86,8 @@ static bool checkNameDecodable(const char *d_name, qsizetype len) return cs.invalidChars == 0 && cs.remainingChars == 0; #else // if we have no text codecs, then QString::fromLocal8Bit is fromLatin1 + Q_UNUSED(d_name) + Q_UNUSED(len) return true; #endif } diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 5f91ce5e3d..1d42dbfc70 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -81,7 +81,7 @@ static Qt::HANDLE createChangeNotification(const QString &path, uint flags) nativePath.append(QLatin1Char('\\')); const HANDLE result = FindFirstChangeNotification(reinterpret_cast<const wchar_t *>(nativePath.utf16()), FALSE, flags); - DEBUG() << __FUNCTION__ << nativePath << Qt::hex <<showbase << flags << "returns" << result; + DEBUG() << __FUNCTION__ << nativePath << Qt::hex << Qt::showbase << flags << "returns" << result; return result; } diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 22c22ce711..86d361b06a 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1109,14 +1109,8 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f) uchar *data = nullptr; qsizetype data_len = 0; -#ifdef QT_USE_MMAP - int fd = QT_OPEN(QFile::encodeName(f), O_RDONLY, -#if defined(Q_OS_WIN) - _S_IREAD | _S_IWRITE -#else - 0666 -#endif - ); +#if defined(QT_USE_MMAP) + int fd = QT_OPEN(QFile::encodeName(f), O_RDONLY, 0666); if (fd >= 0) { QT_STATBUF st; if (!QT_FSTAT(fd, &st) && st.st_size <= std::numeric_limits<qsizetype>::max()) { diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index fc7122d904..e485310e86 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -420,7 +420,10 @@ QString QSettingsPrivate::variantToString(const QVariant &v) case QVariant::UInt: case QVariant::Bool: case QVariant::Double: - case QVariant::KeySequence: { +#if QT_CONFIG(shortcut) + case QVariant::KeySequence: +#endif + { result = v.toString(); if (result.contains(QChar::Null)) result = QLatin1String("@String(") + result + QLatin1Char(')'); diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 3b5f2f97da..7874b854e4 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -345,6 +345,8 @@ QT_BEGIN_NAMESPACE \note On Android, applications with open files on the external storage (<USER> locations), will be killed if the external storage is unmounted. + \note On Android, reading/writing to GenericDataLocation needs the READ_EXTERNAL_STORAGE/WRITE_EXTERNAL_STORAGE permission granted. + \note On iOS, if you do pass \c {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()} as argument to \l{QFileDialog::setDirectory()}, a native image picker dialog will be used for accessing the user's photo album. diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 878e007fb0..a7650390f9 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -979,7 +979,7 @@ inline bool QUrlPrivate::setScheme(const QString &value, int len, bool doSetErro // validate it: int needsLowercasing = -1; - const ushort *p = reinterpret_cast<const ushort *>(value.constData()); + const ushort *p = value.utf16(); for (int i = 0; i < len; ++i) { if (p[i] >= 'a' && p[i] <= 'z') continue; diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 88555f9572..fc69e362c7 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3294,7 +3294,11 @@ void QAbstractItemModel::endResetModel() { Q_D(QAbstractItemModel); d->invalidatePersistentIndexes(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + resetInternalData(); +#else QMetaObject::invokeMethod(this, "resetInternalData"); +#endif emit modelReset(QPrivateSignal()); } diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 43649cf79b..2cc1bd8ce6 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -156,7 +156,6 @@ inline uint qHash(const QPersistentModelIndex &index, uint seed) noexcept Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &); #endif -template<typename T> class QList; typedef QList<QModelIndex> QModelIndexList; class QMimeData; diff --git a/src/corelib/itemmodels/qabstractproxymodel.h b/src/corelib/itemmodels/qabstractproxymodel.h index c9a73b6a31..f6f6e45c1a 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.h +++ b/src/corelib/itemmodels/qabstractproxymodel.h @@ -103,7 +103,11 @@ Q_SIGNALS: void sourceModelChanged(QPrivateSignal); protected Q_SLOTS: - void resetInternalData(); + void resetInternalData() +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + override +#endif + ; protected: QAbstractProxyModel(QAbstractProxyModelPrivate &, QObject *parent); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e25049f821..6531cd8e0c 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -156,10 +156,10 @@ private: extern QString qAppFileName(); #endif -#if QT_VERSION >= 0x060000 -# error "Bump QCoreApplicatoinPrivate::app_compile_version to 0x060000" +#if QT_VERSION >= 0x070000 +# error "Bump QCoreApplicatoinPrivate::app_compile_version to 0x070000" #endif -int QCoreApplicationPrivate::app_compile_version = 0x050000; //we don't know exactly, but it's at least 5.0.0 +int QCoreApplicationPrivate::app_compile_version = 0x060000; //we don't know exactly, but it's at least 6.0.0 bool QCoreApplicationPrivate::setuidAllowed = false; diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 961b96710e..37c43dee4f 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -772,7 +772,7 @@ QString decodeMSG(const MSG& msg) auto rect = reinterpret_cast<const RECT *>(lParam); QTextStream(¶meters) << "DPI: " << HIWORD(wParam) << ',' << LOWORD(wParam) << ' ' << (rect->right - rect->left) << 'x' - << (rect->bottom - rect->top) << forcesign << rect->left << rect->top; + << (rect->bottom - rect->top) << Qt::forcesign << rect->left << rect->top; } break; case WM_IME_NOTIFY: diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 5cb30a74ac..a8e8866339 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -3655,6 +3655,21 @@ const char* QMetaClassInfo::value() const } /*! + \class QMethodRawArguments + \internal + + A wrapper class for the void ** arguments array used by the meta + object system. If a slot uses a single argument of this type, + the meta object system will pass the raw arguments array directly + to the slot and set the arguments count in the slot description to + zero, so that any signal can connect to it. + + This is used internally to implement signal relay functionality in + our state machine and dbus. +*/ + + +/*! \macro QGenericArgument Q_ARG(Type, const Type &value) \relates QMetaObject diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index fcd92afd89..31fecd0b07 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -46,9 +46,6 @@ QT_BEGIN_NAMESPACE - -template <typename T> class QList; - #define Q_METAMETHOD_INVOKE_MAX_ARGS 10 class Q_CORE_EXPORT QMetaMethod diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index f77c4ce32f..aab9e05182 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1103,7 +1103,7 @@ int QMetaStringTable::enter(const QByteArray &value) int QMetaStringTable::preferredAlignment() { - return Q_ALIGNOF(QByteArrayData); + return alignof(QByteArrayData); } // Returns the size (in bytes) required for serializing this string table. diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index d41f7ee80e..d04f327223 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -151,6 +151,13 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); F(QVariantHash, 28, QVariantHash) \ F(QByteArrayList, 49, QByteArrayList) \ +#if QT_CONFIG(shortcut) +#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)\ + F(QKeySequence, 75, QKeySequence) +#else +#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F) +#endif + #define QT_FOR_EACH_STATIC_GUI_CLASS(F)\ F(QFont, 64, QFont) \ F(QPixmap, 65, QPixmap) \ @@ -163,7 +170,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); F(QRegion, 72, QRegion) \ F(QBitmap, 73, QBitmap) \ F(QCursor, 74, QCursor) \ - F(QKeySequence, 75, QKeySequence) \ + QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F) \ F(QPen, 76, QPen) \ F(QTextLength, 77, QTextLength) \ F(QTextFormat, 78, QTextFormat) \ @@ -500,7 +507,7 @@ public: typedef void (*Deleter)(void *); typedef void *(*Creator)(const void *); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if 1 || QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt6: fix this typedef void (*Destructor)(void *); typedef void *(*Constructor)(void *, const void *); // TODO Qt6: remove me #endif diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index bb1b48b0a6..d713555bb6 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -161,7 +161,6 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) #endif void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0; -void (*QAbstractDeclarativeData::destroyed_qml1)(QAbstractDeclarativeData *, QObject *) = 0; void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0; void (*QAbstractDeclarativeData::signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **) = 0; int (*QAbstractDeclarativeData::receivers)(QAbstractDeclarativeData *, const QObject *, int) = 0; @@ -233,10 +232,6 @@ QObjectPrivate::~QObjectPrivate() if (metaObject) metaObject->objectDestroyed(q_ptr); -#ifndef QT_NO_USERDATA - if (extraData) - qDeleteAll(extraData->userData); -#endif delete extraData; } @@ -995,15 +990,8 @@ QObject::~QObject() emit destroyed(this); } - if (d->declarativeData) { - if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) { - if (QAbstractDeclarativeData::destroyed_qml1) - QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); - } else { - if (QAbstractDeclarativeData::destroyed) - QAbstractDeclarativeData::destroyed(d->declarativeData, this); - } - } + if (d->declarativeData && QAbstractDeclarativeData::destroyed) + QAbstractDeclarativeData::destroyed(d->declarativeData, this); QObjectPrivate::ConnectionData *cd = d->connections.loadRelaxed(); if (cd) { @@ -4241,58 +4229,6 @@ void QObject::dumpObjectInfo() const } } -#ifndef QT_NO_USERDATA -static QBasicAtomicInteger<uint> user_data_registration = Q_BASIC_ATOMIC_INITIALIZER(0); - -/*! - \internal - */ -uint QObject::registerUserData() -{ - return user_data_registration.fetchAndAddRelaxed(1); -} - -/*! - \fn QObjectUserData::QObjectUserData() - \internal - */ - -/*! - \internal - */ -QObjectUserData::~QObjectUserData() -{ -} - -/*! - \internal - */ -void QObject::setUserData(uint id, QObjectUserData* data) -{ - Q_D(QObject); - if (!d->extraData) - d->extraData = new QObjectPrivate::ExtraData; - - if (d->extraData->userData.size() <= (int) id) - d->extraData->userData.resize((int) id + 1); - d->extraData->userData[id] = data; -} - -/*! - \internal - */ -QObjectUserData* QObject::userData(uint id) const -{ - Q_D(const QObject); - if (!d->extraData) - return 0; - if ((int)id < d->extraData->userData.size()) - return d->extraData->userData.at(id); - return 0; -} - -#endif // QT_NO_USERDATA - #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QObject *o) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 540b8b32c1..296552c2f2 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -78,12 +78,6 @@ class QRegExp; #if QT_CONFIG(regularexpression) class QRegularExpression; #endif -#if !QT_DEPRECATED_SINCE(5, 14) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -# define QT_NO_USERDATA -#endif -#ifndef QT_NO_USERDATA -class QObjectUserData; -#endif struct QDynamicMetaObjectData; typedef QList<QObject*> QObjectList; @@ -408,15 +402,6 @@ public: QList<QByteArray> dynamicPropertyNames() const; #endif // QT_NO_PROPERTIES -#ifndef QT_NO_USERDATA - QT_DEPRECATED_VERSION_5_14 - static uint registerUserData(); - QT_DEPRECATED_VERSION_X_5_14("Use setProperty()") - void setUserData(uint id, QObjectUserData* data); - QT_DEPRECATED_VERSION_X_5_14("Use property()") - QObjectUserData* userData(uint id) const; -#endif // QT_NO_USERDATA - Q_SIGNALS: void destroyed(QObject * = nullptr); void objectNameChanged(const QString &objectName, QPrivateSignal); @@ -485,15 +470,6 @@ inline QMetaObject::Connection QObject::connect(const QObject *asender, const ch inline const QMetaObject *qt_getQtMetaObject() noexcept { return &QObject::staticQtMetaObject; } -#ifndef QT_NO_USERDATA -class Q_CORE_EXPORT QObjectUserData { - Q_DISABLE_COPY(QObjectUserData) -public: - QObjectUserData() = default; - virtual ~QObjectUserData(); -}; -#endif - #if QT_DEPRECATED_SINCE(5, 0) template<typename T> inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 45fc27917d..db62c03b7a 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -89,7 +89,6 @@ class Q_CORE_EXPORT QAbstractDeclarativeData { public: static void (*destroyed)(QAbstractDeclarativeData *, QObject *); - static void (*destroyed_qml1)(QAbstractDeclarativeData *, QObject *); static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *); static void (*signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **); static int (*receivers)(QAbstractDeclarativeData *, const QObject *, int); @@ -97,14 +96,6 @@ public: static void (*setWidgetParent)(QObject *, QObject *); // Used by the QML engine to specify parents for widgets. Set by QtWidgets. }; -// This is an implementation of QAbstractDeclarativeData that is identical with -// the implementation in QtDeclarative and QtQml for the first bit -struct QAbstractDeclarativeDataImpl : public QAbstractDeclarativeData -{ - quint32 ownedByQml1:1; - quint32 unused: 31; -}; - class Q_CORE_EXPORT QObjectPrivate : public QObjectData { Q_DECLARE_PUBLIC(QObject) @@ -113,9 +104,6 @@ public: struct ExtraData { ExtraData() {} - #ifndef QT_NO_USERDATA - QVector<QObjectUserData *> userData; - #endif QList<QByteArray> propertyNames; QVector<QVariant> propertyValues; QVector<int> runningTimers; diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index dc2d832fe5..9f654b0318 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -285,6 +285,10 @@ class QMetaEnum; class QMetaProperty; class QMetaClassInfo; +struct QMethodRawArguments +{ + void **arguments; +}; class Q_CORE_EXPORT QGenericArgument { diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index ddb96ecad6..31c1277b03 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -58,11 +58,11 @@ #include "qendian.h" #include "qresource.h" -#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY) -#define QT_USE_MMAP -#include "private/qcore_unix_p.h" +#if defined(Q_OS_UNIX) && !defined(Q_OS_NACL) && !defined(Q_OS_INTEGRITY) +# define QT_USE_MMAP +# include "private/qcore_unix_p.h" // for mmap -#include <sys/mman.h> +# include <sys/mman.h> #endif #include <stdlib.h> diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 705cae6cf4..258da1a8d4 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1470,7 +1470,7 @@ static void customConstruct(QVariant::Private *d, const void *copy) } else { // Private::Data contains long long, and long double is the biggest standard type. const size_t maxAlignment = - qMax(Q_ALIGNOF(QVariant::Private::Data), Q_ALIGNOF(long double)); + qMax(alignof(QVariant::Private::Data), alignof(long double)); const size_t s = sizeof(QVariant::PrivateShared); const size_t offset = s + ((s * maxAlignment - s) % maxAlignment); void *data = operator new(offset + size); @@ -2469,7 +2469,9 @@ static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = QVariant::DateTime, QVariant::ByteArray, QVariant::BitArray, +#if QT_CONFIG(shortcut) QVariant::KeySequence, +#endif QVariant::Pen, QVariant::LongLong, QVariant::ULongLong, @@ -2574,7 +2576,11 @@ void QVariant::save(QDataStream &s) const typeId += 97; } else if (typeId == QMetaType::QSizePolicy) { typeId = 75; +#if QT_CONFIG(shortcut) } else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) { +#else + } else if (typeId >= QMetaType::QPen && typeId <= QMetaType::QQuaternion) { +#endif // and as a result these types received lower ids too typeId +=1; } else if (typeId == QMetaType::QPolygonF) { @@ -3647,9 +3653,11 @@ bool QVariant::canConvert(int targetTypeId) const if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) { switch (uint(targetTypeId)) { case QVariant::Int: +#if QT_CONFIG(shortcut) if (currentType == QVariant::KeySequence) return true; Q_FALLTHROUGH(); +#endif case QVariant::UInt: case QVariant::LongLong: case QVariant::ULongLong: @@ -3672,11 +3680,16 @@ bool QVariant::canConvert(int targetTypeId) const return currentType == QVariant::Color || currentType == QMetaType::Nullptr || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); case QVariant::String: - return currentType == QVariant::KeySequence || currentType == QVariant::Font - || currentType == QVariant::Color || currentType == QMetaType::Nullptr - || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); + return currentType == QVariant::Font + || currentType == QVariant::Color || currentType == QMetaType::Nullptr +#if QT_CONFIG(shortcut) + || currentType == QVariant::KeySequence +#endif + || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); +#if QT_CONFIG(shortcut) case QVariant::KeySequence: return currentType == QVariant::String || currentType == QVariant::Int; +#endif case QVariant::Font: return currentType == QVariant::String; case QVariant::Color: diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 86c7414704..331adea4e7 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -184,7 +184,9 @@ class Q_CORE_EXPORT QVariant Region = QMetaType::QRegion, Bitmap = QMetaType::QBitmap, Cursor = QMetaType::QCursor, +#if QT_CONFIG(shortcut) KeySequence = QMetaType::QKeySequence, +#endif Pen = QMetaType::QPen, TextLength = QMetaType::QTextLength, TextFormat = QMetaType::QTextFormat, diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 24a7a35ea5..ce84a15831 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -91,8 +91,8 @@ bool QMimeDatabasePrivate::shouldCheck() return true; } -#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY) -#define QT_USE_MMAP +#if defined(Q_OS_UNIX) && !defined(Q_OS_NACL) && !defined(Q_OS_INTEGRITY) +# define QT_USE_MMAP #endif void QMimeDatabasePrivate::loadProviders() diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h index d9cf446d44..831390de1f 100644 --- a/src/corelib/mimetypes/qmimedatabase_p.h +++ b/src/corelib/mimetypes/qmimedatabase_p.h @@ -63,6 +63,7 @@ QT_REQUIRE_CONFIG(mimetype); #include <QtCore/qmutex.h> #include <QtCore/qvector.h> +#include <vector> #include <memory> QT_BEGIN_NAMESPACE diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index eeaa3c18ec..39a170db3f 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -692,7 +692,7 @@ static bool qt_get_metadata(QLibraryPrivate *priv, QString *errMsg) }; #else auto getMetaData = [](QFunctionPointer fptr) { - auto f = reinterpret_cast<QPair<const char *, size_t> (*)()>(fptr); + auto f = reinterpret_cast<QPluginMetaData (*)()>(fptr); return f(); }; #endif @@ -702,7 +702,7 @@ static bool qt_get_metadata(QLibraryPrivate *priv, QString *errMsg) return false; auto metaData = getMetaData(pfn); - QJsonDocument doc = qJsonFromRawLibraryMetaData(metaData.first, metaData.second, errMsg); + QJsonDocument doc = qJsonFromRawLibraryMetaData(reinterpret_cast<const char *>(metaData.data), metaData.size, errMsg); if (doc.isNull()) return false; priv->metaData = doc.object(); diff --git a/src/corelib/serialization/qcborvalue_p.h b/src/corelib/serialization/qcborvalue_p.h index 590c2d6e05..38ad54047f 100644 --- a/src/corelib/serialization/qcborvalue_p.h +++ b/src/corelib/serialization/qcborvalue_p.h @@ -147,8 +147,8 @@ public: qptrdiff offset = data.size(); // align offset - offset += Q_ALIGNOF(QtCbor::ByteData) - 1; - offset &= ~(Q_ALIGNOF(QtCbor::ByteData) - 1); + offset += alignof(QtCbor::ByteData) - 1; + offset &= ~(alignof(QtCbor::ByteData) - 1); qptrdiff increment = qptrdiff(sizeof(QtCbor::ByteData)) + len; @@ -170,7 +170,7 @@ public: return nullptr; size_t offset = size_t(e.value); - Q_ASSERT((offset % Q_ALIGNOF(QtCbor::ByteData)) == 0); + Q_ASSERT((offset % alignof(QtCbor::ByteData)) == 0); Q_ASSERT(offset + sizeof(QtCbor::ByteData) <= size_t(data.size())); auto b = reinterpret_cast<const QtCbor::ByteData *>(data.constData() + offset); diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index cfcd89333b..bcfcd47ccf 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -43,6 +43,7 @@ #include <QtCore/qscopedpointer.h> #include <QtCore/qiodevice.h> #include <QtCore/qpair.h> +#include <QtCore/qcontainerfwd.h> #ifdef Status #error qdatastream.h must be included before any header file that defines Status @@ -54,12 +55,6 @@ class qfloat16; class QByteArray; class QIODevice; -template <typename T> class QList; -template <typename T> class QVector; -template <typename T> class QSet; -template <class Key, class T> class QHash; -template <class Key, class T> class QMap; - #if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED) class QDataStreamPrivate; namespace QtPrivate { diff --git a/src/corelib/serialization/qjsonarray.h b/src/corelib/serialization/qjsonarray.h index 22aa996a3e..9b7e10766f 100644 --- a/src/corelib/serialization/qjsonarray.h +++ b/src/corelib/serialization/qjsonarray.h @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE class QDebug; class QStringList; -template <typename T> class QList; typedef QList<QVariant> QVariantList; class Q_CORE_EXPORT QJsonArray diff --git a/src/corelib/statemachine/qsignaleventgenerator_p.h b/src/corelib/statemachine/qsignaleventgenerator_p.h index 72592b8731..a9d5b96920 100644 --- a/src/corelib/statemachine/qsignaleventgenerator_p.h +++ b/src/corelib/statemachine/qsignaleventgenerator_p.h @@ -62,13 +62,12 @@ class QStateMachine; class QSignalEventGenerator : public QObject { - Q_OBJECT_FAKE + Q_OBJECT public: QSignalEventGenerator(QStateMachine *parent); -private: -// slots - void execute(void **_a); +private Q_SLOTS: + void execute(QMethodRawArguments a); private: Q_DISABLE_COPY_MOVE(QSignalEventGenerator) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index a97700e5d0..3c03cf40e4 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -3045,102 +3045,14 @@ void QStateMachine::removeDefaultAnimation(QAbstractAnimation *animation) #endif // animation - -// Begin moc-generated code -- modify carefully (check "HAND EDIT" parts)! -struct qt_meta_stringdata_QSignalEventGenerator_t { - QByteArrayData data[3]; - char stringdata[32]; -}; -#define QT_MOC_LITERAL(idx, ofs, len) \ - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ - offsetof(qt_meta_stringdata_QSignalEventGenerator_t, stringdata) + ofs \ - - idx * sizeof(QByteArrayData) \ - ) -static const qt_meta_stringdata_QSignalEventGenerator_t qt_meta_stringdata_QSignalEventGenerator = { - { -QT_MOC_LITERAL(0, 0, 21), -QT_MOC_LITERAL(1, 22, 7), -QT_MOC_LITERAL(2, 30, 0) - }, - "QSignalEventGenerator\0execute\0\0" -}; -#undef QT_MOC_LITERAL - -static const uint qt_meta_data_QSignalEventGenerator[] = { - - // content: - 7, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: name, argc, parameters, tag, flags - 1, 0, 19, 2, 0x0a, - - // slots: parameters - QMetaType::Void, - - 0 // eod -}; - -void QSignalEventGenerator::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) -{ - if (_c == QMetaObject::InvokeMetaMethod) { - Q_ASSERT(staticMetaObject.cast(_o)); - QSignalEventGenerator *_t = static_cast<QSignalEventGenerator *>(_o); - switch (_id) { - case 0: _t->execute(_a); break; // HAND EDIT: add the _a parameter - default: ; - } - } - Q_UNUSED(_a); -} - -const QMetaObject QSignalEventGenerator::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_QSignalEventGenerator.data, - qt_meta_data_QSignalEventGenerator, qt_static_metacall, 0, 0 } -}; - -const QMetaObject *QSignalEventGenerator::metaObject() const -{ - return &staticMetaObject; -} - -void *QSignalEventGenerator::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_QSignalEventGenerator.stringdata)) - return static_cast<void*>(const_cast< QSignalEventGenerator*>(this)); - return QObject::qt_metacast(_clname); -} - -int QSignalEventGenerator::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 1) - qt_static_metacall(this, _c, _id, _a); - _id -= 1; - } - return _id; -} -// End moc-generated code - -void QSignalEventGenerator::execute(void **_a) +void QSignalEventGenerator::execute(QMethodRawArguments a) { auto machinePrivate = QStateMachinePrivate::get(qobject_cast<QStateMachine*>(parent())); if (machinePrivate->state != QStateMachinePrivate::Running) return; int signalIndex = senderSignalIndex(); Q_ASSERT(signalIndex != -1); - machinePrivate->handleTransitionSignal(sender(), signalIndex, _a); + machinePrivate->handleTransitionSignal(sender(), signalIndex, a.arguments); } QSignalEventGenerator::QSignalEventGenerator(QStateMachine *parent) diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 7c571706d8..03d842e9bc 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -44,6 +44,7 @@ #include <QtCore/qrefcount.h> #include <QtCore/qnamespace.h> #include <QtCore/qarraydata.h> +#include <QtCore/qcontainerfwd.h> #include <stdlib.h> #include <string.h> @@ -112,7 +113,6 @@ Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len, Qt::ChecksumType standa class QByteRef; class QString; class QDataStream; -template <typename T> class QList; typedef QArrayData QByteArrayData; diff --git a/src/corelib/text/qbytearraymatcher.h b/src/corelib/text/qbytearraymatcher.h index 0eedfc1d20..7cc5037095 100644 --- a/src/corelib/text/qbytearraymatcher.h +++ b/src/corelib/text/qbytearraymatcher.h @@ -85,7 +85,7 @@ private: class QStaticByteArrayMatcherBase { - Q_DECL_ALIGN(16) + alignas(16) struct Skiptable { uchar data[256]; } m_skiptable; diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 6430f38a3b..1303be10b1 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -424,12 +424,7 @@ void QFutureInterfaceBase::setProgressValueAndText(int progressValue, } } -QMutex *QFutureInterfaceBase::mutex() const -{ - return &d->m_mutex; -} - -QMutex &QFutureInterfaceBase::mutex(int) const +QMutex &QFutureInterfaceBase::mutex() const { return d->m_mutex; } diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index bcdae24833..43dfd6bac4 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -119,8 +119,7 @@ public: void waitForResult(int resultIndex); void waitForResume(); - QMutex *mutex() const; - QMutex &mutex(int) const; + QMutex &mutex() const; QtPrivate::ExceptionStore &exceptionStore(); QtPrivate::ResultStoreBase &resultStoreBase(); const QtPrivate::ResultStoreBase &resultStoreBase() const; @@ -191,7 +190,7 @@ public: template <typename T> inline void QFutureInterface<T>::reportResult(const T *result, int index) { - std::lock_guard<QMutex> locker(mutex(0)); + std::lock_guard<QMutex> locker{mutex()}; if (this->queryState(Canceled) || this->queryState(Finished)) { return; } @@ -217,7 +216,7 @@ inline void QFutureInterface<T>::reportResult(const T &result, int index) template <typename T> inline void QFutureInterface<T>::reportResults(const QVector<T> &_results, int beginIndex, int count) { - std::lock_guard<QMutex> locker(mutex(0)); + std::lock_guard<QMutex> locker{mutex()}; if (this->queryState(Canceled) || this->queryState(Finished)) { return; } @@ -245,14 +244,14 @@ inline void QFutureInterface<T>::reportFinished(const T *result) template <typename T> inline const T &QFutureInterface<T>::resultReference(int index) const { - std::lock_guard<QMutex> locker(mutex(0)); + std::lock_guard<QMutex> locker{mutex()}; return resultStoreBase().resultAt(index).template value<T>(); } template <typename T> inline const T *QFutureInterface<T>::resultPointer(int index) const { - std::lock_guard<QMutex> locker(mutex(0)); + std::lock_guard<QMutex> locker{mutex()}; return resultStoreBase().resultAt(index).template pointer<T>(); } @@ -266,7 +265,7 @@ inline QList<T> QFutureInterface<T>::results() QFutureInterfaceBase::waitForResult(-1); QList<T> res; - std::lock_guard<QMutex> locker(mutex(0)); + std::lock_guard<QMutex> locker{mutex()}; QtPrivate::ResultIteratorBase it = resultStoreBase().begin(); while (it != resultStoreBase().end()) { diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 9fd1dd059d..eeaec7f24d 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -844,7 +844,7 @@ bool QThread::event(QEvent* event) return QObject::event(event); } -Qt::HANDLE QThread::currentThreadId() noexcept +Qt::HANDLE QThread::currentThreadIdImpl() noexcept { return Qt::HANDLE(currentThread()); } diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index c7a6dc8f1a..8141f945b6 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -161,6 +161,7 @@ private: #if QT_CONFIG(cxx11_future) static QThread *createThreadImpl(std::future<void> &&future); #endif + static Qt::HANDLE currentThreadIdImpl() noexcept Q_DECL_PURE_FUNCTION; friend class QCoreApplication; friend class QThreadData; @@ -236,6 +237,38 @@ QThread *QThread::create(Function &&f) #endif // QT_CONFIG(cxx11_future) +/* + On architectures and platforms we know, interpret the thread control + block (TCB) as a unique identifier for a thread within a process. Otherwise, + fall back to a slower but safe implementation. + + As per the documentation of currentThreadId, we return an opaque handle + as a thread identifier, and application code is not supposed to use that + value for anything. In Qt we use the handle to check if threads are identical, + for which the TCB is sufficient. + + So we use the fastest possible way, rathern than spend time on returning + some pseudo-interoperable value. +*/ +inline Qt::HANDLE QThread::currentThreadId() noexcept +{ + Qt::HANDLE tid; // typedef to void* + Q_STATIC_ASSERT(sizeof(tid) == sizeof(void*)); + // See https://akkadia.org/drepper/tls.pdf for x86 ABI +#if defined(Q_PROCESSOR_X86_32) && defined(Q_OS_LINUX) // x86 32-bit always uses GS + __asm__("movl %%gs:0, %0" : "=r" (tid) : : ); +#elif defined(Q_PROCESSOR_X86_64) && defined(Q_OS_DARWIN64) + // 64bit macOS uses GS, see https://github.com/apple/darwin-xnu/blob/master/libsyscall/os/tsd.h + __asm__("movq %%gs:0, %0" : "=r" (tid) : : ); +#elif defined(Q_PROCESSOR_X86_64) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)) + // x86_64 Linux, BSD uses FS + __asm__("movq %%fs:0, %0" : "=r" (tid) : : ); +#else + tid = currentThreadIdImpl(); +#endif + return tid; +} + QT_END_NAMESPACE #endif // QTHREAD_H diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index cb3c0d6bb1..21abe372eb 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -415,16 +415,36 @@ void QThreadPrivate::finish(void *arg) } - - /************************************************************************** ** QThread *************************************************************************/ -Qt::HANDLE QThread::currentThreadId() noexcept +/* + Since each thread is guaranteed to have its own copy of + currenThreadData, the address is guaranteed to be unique for each + running thread (but likely to be reused for newly started threads). + + CI tests fails on ARM architectures if we try to use the assembler, + or the address of the thread_local (even with a recent gcc version), so + stick to the pthread version there. The assembler would be + + // http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344k/Babeihid.html + asm volatile ("mrc p15, 0, %0, c13, c0, 3" : "=r" (tid)); + + and + + // see glibc/sysdeps/aarch64/nptl/tls.h + asm volatile ("mrs %0, tpidr_el0" : "=r" (tid)); + + for 32 and 64bit versions, respectively. +*/ +Qt::HANDLE QThread::currentThreadIdImpl() noexcept { - // requires a C cast here otherwise we run into trouble on AIX +#if defined(Q_PROCESSOR_ARM) return to_HANDLE(pthread_self()); +#else + return ¤tThreadData; +#endif } #if defined(QT_LINUXBASE) && !defined(_SC_NPROCESSORS_ONLN) diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index a72df2fc40..996bcf0a71 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -449,7 +449,7 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway) noexcept ** QThread *************************************************************************/ -Qt::HANDLE QThread::currentThreadId() noexcept +Qt::HANDLE QThread::currentThreadIdImpl() noexcept { return reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId())); } diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index e9f1455380..d128e35ddc 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -77,7 +77,6 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QDateTimeParser { - Q_DECLARE_TR_FUNCTIONS(QDateTimeParser) public: enum Context { FromString, @@ -267,10 +266,11 @@ protected: // for the benefit of QDateTimeEditPrivate return skipToNextSection(section, current, QStringRef(§ionText)); } QString stateName(State s) const; + QString getAmPmText(AmPm ap, Case cs) const; + virtual QDateTime getMinimum() const; virtual QDateTime getMaximum() const; virtual int cursorPosition() const { return -1; } - virtual QString getAmPmText(AmPm ap, Case cs) const; virtual QLocale locale() const { return defaultLocale; } mutable int currentSectionIndex; diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 36a221f728..cc71a040fa 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -193,7 +193,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, size_t capacity, AllocationOptions options) noexcept { // Alignment is a power of two - Q_ASSERT(alignment >= Q_ALIGNOF(QArrayData) + Q_ASSERT(alignment >= alignof(QArrayData) && !(alignment & (alignment - 1))); // Don't allocate empty headers @@ -207,12 +207,12 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, size_t headerSize = sizeof(QArrayData); - // Allocate extra (alignment - Q_ALIGNOF(QArrayData)) padding bytes so we + // Allocate extra (alignment - alignof(QArrayData)) padding bytes so we // can properly align the data array. This assumes malloc is able to // provide appropriate alignment for the header -- as it should! // Padding is skipped when allocating a header for RawData. if (!(options & RawData)) - headerSize += (alignment - Q_ALIGNOF(QArrayData)); + headerSize += (alignment - alignof(QArrayData)); if (headerSize > size_t(MaxAllocSize)) return nullptr; @@ -256,7 +256,7 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize, size_t alignment) noexcept { // Alignment is a power of two - Q_ASSERT(alignment >= Q_ALIGNOF(QArrayData) + Q_ASSERT(alignment >= alignof(QArrayData) && !(alignment & (alignment - 1))); Q_UNUSED(objectSize) Q_UNUSED(alignment) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index dcd95924c1..695cc957d6 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -222,7 +222,7 @@ struct QTypedArrayData { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast<QTypedArrayData *>(QArrayData::allocate(sizeof(T), - Q_ALIGNOF(AlignmentDummy), capacity, options)); + alignof(AlignmentDummy), capacity, options)); } static QTypedArrayData *reallocateUnaligned(QTypedArrayData *data, size_t capacity, @@ -236,7 +236,7 @@ struct QTypedArrayData static void deallocate(QArrayData *data) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - QArrayData::deallocate(data, sizeof(T), Q_ALIGNOF(AlignmentDummy)); + QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy)); } static QTypedArrayData *fromRawData(const T *data, size_t n, @@ -295,7 +295,7 @@ struct QArrayDataPointerRef #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(type, size) \ Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size,\ - ((sizeof(QArrayData) + (Q_ALIGNOF(type) - 1)) & ~(Q_ALIGNOF(type) - 1) )) \ + ((sizeof(QArrayData) + (alignof(type) - 1)) & ~(alignof(type) - 1) )) \ /**/ //////////////////////////////////////////////////////////////////////////////// diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 7b74b4f526..3151c57b43 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -166,7 +166,7 @@ private: } int alignOfTypedData() const { - return qMax<int>(sizeof(void*), Q_ALIGNOF(Data)); + return qMax<int>(sizeof(void*), alignof(Data)); } }; diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 52c8d13fe3..d7f69d3e0a 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -1382,11 +1382,6 @@ void QEasingCurve::addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qre } /*! - \fn QList<QPointF> QEasingCurve::cubicBezierSpline() const - \obsolete Use toCubicSpline() instead. - */ - -/*! \since 5.0 Returns the cubicBezierSpline that defines a custom easing curve. diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index d3a468bb22..81833a758f 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -46,10 +46,6 @@ QT_REQUIRE_CONFIG(easingcurve); #include <QtCore/qobjectdefs.h> #include <QtCore/qvector.h> -#if QT_DEPRECATED_SINCE(5, 0) -# include <QtCore/qlist.h> -# include <QtCore/qpoint.h> -#endif QT_BEGIN_NAMESPACE @@ -105,9 +101,6 @@ public: void addCubicBezierSegment(const QPointF & c1, const QPointF & c2, const QPointF & endPoint); void addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qreal b); QVector<QPointF> toCubicSpline() const; -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED QList<QPointF> cubicBezierSpline() const { return toCubicSpline().toList(); } -#endif Type type() const; void setType(Type type); diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 236e433101..d915415893 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -235,7 +235,7 @@ class QHash return reinterpret_cast<Node *>(node); } - static inline int alignOfNode() { return qMax<int>(sizeof(void*), Q_ALIGNOF(Node)); } + static inline int alignOfNode() { return qMax<int>(sizeof(void*), alignof(Node)); } public: inline QHash() noexcept : d(const_cast<QHashData *>(&QHashData::shared_null)) { } diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 18c681581f..e1a78982fd 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -219,7 +219,7 @@ struct QMapData : public QMapDataBase Node *createNode(const Key &k, const T &v, Node *parent = nullptr, bool left = false) { - Node *n = static_cast<Node *>(QMapDataBase::createNode(sizeof(Node), Q_ALIGNOF(Node), + Node *n = static_cast<Node *>(QMapDataBase::createNode(sizeof(Node), alignof(Node), parent, left)); QT_TRY { new (&n->key) Key(k); @@ -243,7 +243,7 @@ struct QMapData : public QMapDataBase void destroy() { if (root()) { root()->destroySubTree(); - freeTree(header.left, Q_ALIGNOF(Node)); + freeTree(header.left, alignof(Node)); } freeData(this); } diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 879e2176f2..923411c34c 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -260,12 +260,6 @@ public: { QSet<T> result = *this; result -= other; return result; } QList<T> values() const; -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) - Q_DECL_DEPRECATED_X("Use values() instead.") - QList<T> toList() const { return values(); } - Q_DECL_DEPRECATED_X("Use QSet<T>(list.begin(), list.end()) instead.") - static QSet<T> fromList(const QList<T> &list); -#endif private: Hash q_hash; @@ -397,30 +391,6 @@ Q_OUTOFLINE_TEMPLATE QList<T> QSet<T>::values() const return result; } -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -template <typename T> -Q_OUTOFLINE_TEMPLATE QSet<T> QList<T>::toSet() const -{ - QSet<T> result; - result.reserve(size()); - for (int i = 0; i < size(); ++i) - result.insert(at(i)); - return result; -} - -template <typename T> -QSet<T> QSet<T>::fromList(const QList<T> &list) -{ - return list.toSet(); -} - -template <typename T> -QList<T> QList<T>::fromSet(const QSet<T> &set) -{ - return set.toList(); -} -#endif - Q_DECLARE_SEQUENTIAL_ITERATOR(Set) #if !defined(QT_NO_JAVA_STYLE_ITERATORS) |