diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-04-21 01:00:10 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-04-22 15:28:01 +0200 |
commit | efd7757154e1fb946a51c7d90b8cbf56b4df8b6d (patch) | |
tree | f757e14770d82ee8376fa10006973c0e750b1e16 /src/corelib | |
parent | 1c80d056e4f45b4ee7c4863cd792e83c889513c5 (diff) | |
parent | e10e5318bc02a48a866b76b6f0b7f268d16af642 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
src/widgets/widgets/qabstractbutton.cpp
src/widgets/widgets/qbuttongroup.cpp
src/widgets/widgets/qbuttongroup.h
src/widgets/widgets/qsplashscreen.cpp
tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
tests/benchmarks/opengl/main.cpp
Needed update:
src/plugins/platforms/cocoa/CMakeLists.txt
Change-Id: I7be4baebb63844ec2b3e0de859ca9de1bc730bb5
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp | 24 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 8 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 2 | ||||
-rw-r--r-- | src/corelib/global/qsystemdetection.h | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_inotify.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_kqueue.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 8 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_win.cpp | 57 | ||||
-rw-r--r-- | src/corelib/itemmodels/qsortfilterproxymodel.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 9 | ||||
-rw-r--r-- | src/corelib/kernel/qsocketnotifier.cpp | 89 | ||||
-rw-r--r-- | src/corelib/kernel/qsocketnotifier.h | 61 | ||||
-rw-r--r-- | src/corelib/serialization/qcborvalue.h | 5 | ||||
-rw-r--r-- | src/corelib/time/qtimezoneprivate_android.cpp | 42 | ||||
-rw-r--r-- | src/corelib/tools/qline.cpp | 11 |
17 files changed, 283 insertions, 49 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index 43bcc22720..fddda64b19 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -403,20 +403,28 @@ public: //! [39] -class QLibrary : public QObject +class QItemSelectionModel : public QObject { Q_OBJECT public: ... - - enum LoadHint { - ResolveAllSymbolsHint = 0x01, - ExportExternalSymbolsHint = 0x02, - LoadArchiveMemberHint = 0x04 + enum SelectionFlag { + NoUpdate = 0x0000, + Clear = 0x0001, + Select = 0x0002, + Deselect = 0x0004, + Toggle = 0x0008, + Current = 0x0010, + Rows = 0x0020, + Columns = 0x0040, + SelectCurrent = Select | Current, + ToggleCurrent = Toggle | Current, + ClearAndSelect = Clear | Select }; - Q_DECLARE_FLAGS(LoadHints, LoadHint) - Q_FLAG(LoadHint) + + Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) + Q_FLAG(SelectionFlags) ... } //! [39] diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 99a30e941b..075d7c5c65 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1292,6 +1292,14 @@ # define QT_WARNING_DISABLE_DEPRECATED #endif +#ifndef QT_IGNORE_DEPRECATIONS +#define QT_IGNORE_DEPRECATIONS(statement) \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_DEPRECATED \ + statement \ + QT_WARNING_POP +#endif + /* Proper for-scoping in MIPSpro CC */ diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 4faeaeb213..73c3f8c483 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -285,7 +285,7 @@ application on supported platforms, use of a session manager may be redundant for system services. This attribute must be set before QGuiApplication is constructed. - This value was added in 5.13 + This value was added in 5.14 \value AA_DisableNativeVirtualKeyboard When this attribute is set, the native on-screen virtual keyboard will not be shown automatically when a diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index a020788b11..fe7d7d880b 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -76,6 +76,8 @@ The following operating systems have variants: LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android - only Q_OS_LINUX is defined if building for other Linux systems + MACOS - both Q_OS_BSD4 and Q_OS_IOS are defined when building for iOS + - both Q_OS_BSD4 and Q_OS_MACOS are defined when building for macOS FREEBSD - Q_OS_FREEBSD is defined only when building for FreeBSD with a BSD userland - Q_OS_FREEBSD_KERNEL is always defined on FreeBSD, even if the userland is from GNU */ diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index 888af998a5..94d9d06bcb 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -253,7 +253,7 @@ QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd, QObject notifier(fd, QSocketNotifier::Read, this) { fcntl(inotifyFd, F_SETFD, FD_CLOEXEC); - connect(¬ifier, SIGNAL(activated(int)), SLOT(readFromInotify())); + connect(¬ifier, SIGNAL(activated(QSocketDescriptor)), SLOT(readFromInotify())); } QInotifyFileSystemWatcherEngine::~QInotifyFileSystemWatcherEngine() diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp index c2028e3641..06383a103a 100644 --- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp +++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp @@ -77,7 +77,7 @@ QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(int kqfd, QObject kqfd(kqfd), notifier(kqfd, QSocketNotifier::Read, this) { - connect(¬ifier, SIGNAL(activated(int)), SLOT(readFromKqueue())); + connect(¬ifier, SIGNAL(activated(QSocketDescriptor)), SLOT(readFromKqueue())); fcntl(kqfd, F_SETFD, FD_CLOEXEC); } diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 930007ff04..e8efe6481f 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -251,7 +251,7 @@ bool QProcessPrivate::openChannel(Channel &channel) channel.notifier = new QSocketNotifier(channel.pipe[1], QSocketNotifier::Write, q); channel.notifier->setEnabled(false); - QObject::connect(channel.notifier, SIGNAL(activated(int)), + QObject::connect(channel.notifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_canWrite())); } else { channel.notifier = new QSocketNotifier(channel.pipe[0], @@ -261,7 +261,7 @@ bool QProcessPrivate::openChannel(Channel &channel) receiver = SLOT(_q_canReadStandardOutput()); else receiver = SLOT(_q_canReadStandardError()); - QObject::connect(channel.notifier, SIGNAL(activated(int)), + QObject::connect(channel.notifier, SIGNAL(activated(QSocketDescriptor)), q, receiver); } } @@ -380,7 +380,7 @@ void QProcessPrivate::startProcess() if (threadData.loadRelaxed()->hasEventDispatcher()) { startupSocketNotifier = new QSocketNotifier(childStartedPipe[0], QSocketNotifier::Read, q); - QObject::connect(startupSocketNotifier, SIGNAL(activated(int)), + QObject::connect(startupSocketNotifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_startupNotification())); } @@ -531,7 +531,7 @@ void QProcessPrivate::startProcess() if (threadData.loadRelaxed()->eventDispatcher.loadAcquire()) { deathNotifier = new QSocketNotifier(forkfd, QSocketNotifier::Read, q); - QObject::connect(deathNotifier, SIGNAL(activated(int)), + QObject::connect(deathNotifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_processDied())); } } diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 6c66d1097d..6840b9686c 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1675,14 +1675,16 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, int sectionPosition = 0; bool ok = true; -#if QT_CONFIG(textcodec) // detect utf8 BOM const uchar *dd = (const uchar *)data.constData(); if (data.size() >= 3 && dd[0] == 0xef && dd[1] == 0xbb && dd[2] == 0xbf) { +#if QT_CONFIG(textcodec) iniCodec = QTextCodec::codecForName("UTF-8"); +#else + ok = false; +#endif dataPos = 3; } -#endif while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) { char ch = data.at(lineStart); diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index c2c3b2702b..5055f4020c 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -50,6 +50,7 @@ #include <qt_windows.h> #include <shlobj.h> #include <intshcut.h> +#include <qvarlengtharray.h> #ifndef QT_NO_STANDARDPATHS @@ -92,9 +93,36 @@ static inline void appendTestMode(QString &path) path += QLatin1String("/qttest"); } +static bool isProcessLowIntegrity() { +#ifdef Q_CC_MINGW + // GetCurrentProcessToken was introduced in MinGW w64 in v7 + // Disable function until Qt CI is updated + return false; +#else + HANDLE process_token = GetCurrentProcessToken(); // non-leaking pseudo-handle + + QVarLengthArray<char,256> token_info_buf(256); + auto* token_info = reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_info_buf.data()); + DWORD token_info_length = token_info_buf.size(); + if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_info, token_info_length, &token_info_length)) { + // grow bufer and retry GetTokenInformation + token_info_buf.resize(token_info_length); + token_info = reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_info_buf.data()); + if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_info, token_info_length, &token_info_length)) + return false; // assume "normal" process + } + + // The GetSidSubAuthorityCount return-code is undefined on failure, so + // there's no point in checking before dereferencing + DWORD integrity_level = *GetSidSubAuthority(token_info->Label.Sid, *GetSidSubAuthorityCount(token_info->Label.Sid) - 1); + return (integrity_level < SECURITY_MANDATORY_MEDIUM_RID); +#endif +} + // Map QStandardPaths::StandardLocation to KNOWNFOLDERID of SHGetKnownFolderPath() static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type) { + // folders for medium & high integrity processes static const GUID folderIds[] = { FOLDERID_Desktop, // DesktopLocation FOLDERID_Documents, // DocumentsLocation @@ -114,9 +142,34 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type) FOLDERID_RoamingAppData,// AppDataLocation ("Roaming" path) FOLDERID_LocalAppData, // AppConfigLocation ("Local" path) }; - Q_STATIC_ASSERT(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1)); - return size_t(type) < sizeof(folderIds) / sizeof(folderIds[0]) ? folderIds[type] : GUID(); + + // folders for low integrity processes + static const GUID folderIds_li[] = { + FOLDERID_Desktop, // DesktopLocation + FOLDERID_Documents, // DocumentsLocation + FOLDERID_Fonts, // FontsLocation + FOLDERID_Programs, // ApplicationsLocation + FOLDERID_Music, // MusicLocation + FOLDERID_Videos, // MoviesLocation + FOLDERID_Pictures, // PicturesLocation + GUID(), GUID(), // TempLocation/HomeLocation + FOLDERID_LocalAppDataLow,// AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation + GUID(), // CacheLocation + FOLDERID_LocalAppDataLow,// GenericDataLocation ("Local" path) + GUID(), // RuntimeLocation + FOLDERID_LocalAppDataLow,// ConfigLocation ("Local" path) + GUID(), GUID(), // DownloadLocation/GenericCacheLocation + FOLDERID_LocalAppDataLow,// GenericConfigLocation ("Local" path) + FOLDERID_RoamingAppData, // AppDataLocation ("Roaming" path) + FOLDERID_LocalAppDataLow,// AppConfigLocation ("Local" path) + }; + Q_STATIC_ASSERT(sizeof(folderIds_li) == sizeof(folderIds)); + + static bool low_integrity_process = isProcessLowIntegrity(); + if (size_t(type) < sizeof(folderIds) / sizeof(folderIds[0])) + return low_integrity_process ? folderIds_li[type] : folderIds[type]; + return GUID(); } // Convenience for SHGetKnownFolderPath(). diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index bc01c26b64..79a9875073 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -2768,7 +2768,7 @@ void QSortFilterProxyModel::setFilterRole(int role) /*! \since 5.15 - \fn void QSortFilterProxyModel::recursiveFilteringEnabledChanged(int recursiveFilteringEnabled) + \fn void QSortFilterProxyModel::recursiveFilteringEnabledChanged(bool recursiveFilteringEnabled) \brief This signal is emitted when the recursive filter setting is changed to \a recursiveFilteringEnabled. */ diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index bb83080f62..819112dc45 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -261,7 +261,7 @@ public: bool isScriptable(const QObject *obj = nullptr) const; bool isStored(const QObject *obj = nullptr) const; #if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED bool isEditable(const QObject *obj = nullptr) const; + QT_DEPRECATED_VERSION_5_15 bool isEditable(const QObject *obj = nullptr) const; #endif bool isUser(const QObject *obj = nullptr) const; bool isConstant() const; diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 4cb0133e2f..efa71470d4 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4376,16 +4376,15 @@ QDebug operator<<(QDebug dbg, const QObject *o) that values of a given enum can be used as flags and combined using the bitwise OR operator. For namespaces use \l Q_FLAG_NS() instead. - The macro must be placed after the enum declaration. + The macro must be placed after the enum declaration. The declaration of + the flags type is done using the \l Q_DECLARE_FLAGS() macro. - For example, in QLibrary, the \l{QLibrary::LoadHints}{LoadHints} flag is + For example, in QItemSelectionModel, the + \l{QItemSelectionModel::SelectionFlags}{SelectionFlags} flag is declared in the following way: \snippet code/src_corelib_kernel_qobject.cpp 39 - The declaration of the flags themselves is performed in the public section - of the QLibrary class itself, using the \l Q_DECLARE_FLAGS() macro. - \note The Q_FLAG macro takes care of registering individual flag values with the meta-object system, so it is unnecessary to use Q_ENUM() in addition to this macro. diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp index 78269ee605..6e1d2103bd 100644 --- a/src/corelib/kernel/qsocketnotifier.cpp +++ b/src/corelib/kernel/qsocketnotifier.cpp @@ -37,23 +37,32 @@ ** ****************************************************************************/ +#define BUILDING_QSOCKETNOTIFIER #include "qsocketnotifier.h" +#undef BUILDING_QSOCKETNOTIFIER #include "qplatformdefs.h" #include "qabstracteventdispatcher.h" #include "qcoreapplication.h" +#include "qmetatype.h" + #include "qobject_p.h" #include <private/qthread_p.h> +#include <QtCore/QLoggingCategory> + QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcSocketNotifierDeprecation) +Q_LOGGING_CATEGORY(lcSocketNotifierDeprecation, "qt.core.socketnotifier_deprecation"); + class QSocketNotifierPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QSocketNotifier) public: - qintptr sockfd; + QSocketDescriptor sockfd; QSocketNotifier::Type sntype; bool snenabled; }; @@ -143,13 +152,17 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent) : QObject(*new QSocketNotifierPrivate, parent) { Q_D(QSocketNotifier); + + qRegisterMetaType<QSocketDescriptor>(); + qRegisterMetaType<QSocketNotifier::Type>(); + d->sockfd = socket; d->sntype = type; d->snenabled = true; auto thisThreadData = d->threadData.loadRelaxed(); - if (socket < 0) + if (!d->sockfd.isValid()) qWarning("QSocketNotifier: Invalid socket specified"); else if (!thisThreadData->hasEventDispatcher()) qWarning("QSocketNotifier: Can only be used with threads started with QThread"); @@ -169,6 +182,11 @@ QSocketNotifier::~QSocketNotifier() /*! \fn void QSocketNotifier::activated(int socket) + \obsolete To avoid unintended truncation of the descriptor, use + the QSocketDescriptor overload of this function. If you need + compatibility with versions older than 5.15 you need to change + the slot to accept qintptr if it currently accepts an int, and + then connect using Functor-Based Connection. This signal is emitted whenever the socket notifier is enabled and a socket event corresponding to its \l {Type}{type} occurs. @@ -178,6 +196,18 @@ QSocketNotifier::~QSocketNotifier() \sa type(), socket() */ +/*! + \fn void QSocketNotifier::activated(QSocketDescriptor socket, QSocketNotifier::Type type) + \since 5.15 + + This signal is emitted whenever the socket notifier is enabled and + a socket event corresponding to its \a type occurs. + + The socket identifier is passed in the \a socket parameter. + + \sa type(), socket() +*/ + /*! Returns the socket identifier specified to the constructor. @@ -187,7 +217,7 @@ QSocketNotifier::~QSocketNotifier() qintptr QSocketNotifier::socket() const { Q_D(const QSocketNotifier); - return d->sockfd; + return qintptr(d->sockfd); } /*! @@ -230,7 +260,7 @@ bool QSocketNotifier::isEnabled() const void QSocketNotifier::setEnabled(bool enable) { Q_D(QSocketNotifier); - if (d->sockfd < 0) + if (!d->sockfd.isValid()) return; if (d->snenabled == enable) // no change return; @@ -268,12 +298,61 @@ bool QSocketNotifier::event(QEvent *e) } QObject::event(e); // will activate filters if ((e->type() == QEvent::SockAct) || (e->type() == QEvent::SockClose)) { - emit activated(d->sockfd, QPrivateSignal()); + QPointer<QSocketNotifier> alive(this); + emit activated(d->sockfd, d->sntype, QPrivateSignal()); + // ### Qt7: Remove emission if the activated(int) signal is removed + if (alive) + emit activated(int(qintptr(d->sockfd)), QPrivateSignal()); + return true; } return false; } +/*! + \class QSocketDescriptor + \inmodule QtCore + \brief A class which holds a native socket descriptor. + \internal + + \ingroup network + \ingroup io + + \since 5.15 + + QSocketDescriptor makes it easier to handle native socket + descriptors in cross-platform code. + + On Windows it holds a \c {Qt::HANDLE} and on Unix it holds an \c int. + The class will implicitly convert between the class and the + native descriptor type. +*/ + +/*! + \fn QSocketDescriptor::QSocketDescriptor(DescriptorType descriptor) + \internal + + Construct a QSocketDescriptor from a native socket \a descriptor. +*/ + +/*! + \fn QSocketDescriptor::QSocketDescriptor(qintptr descriptor) + \internal + + Construct a QSocketDescriptor from a native socket \a descriptor. + + \note This constructor is only available on Windows. +*/ + +/*! + \fn Qt::HANDLE QSocketDescriptor::winHandle() const noexcept + \internal + + Returns the internal handle. + + \note This function is only available on Windows. +*/ + QT_END_NAMESPACE #include "moc_qsocketnotifier.cpp" diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h index 38e5f27247..528f58a1e1 100644 --- a/src/corelib/kernel/qsocketnotifier.h +++ b/src/corelib/kernel/qsocketnotifier.h @@ -44,6 +44,7 @@ QT_BEGIN_NAMESPACE +class QSocketDescriptor; class QSocketNotifierPrivate; class Q_CORE_EXPORT QSocketNotifier : public QObject { @@ -65,7 +66,23 @@ public Q_SLOTS: void setEnabled(bool); Q_SIGNALS: +#if defined(Q_MOC_RUN) + // Add default arguments during Q_MOC_RUN which makes moc generate "signals" which takes less + // parameters, but we won't actually allow emitting without all 3. This lets users use the + // string-based connect without specifying QSocketNotifier::Type as one of the parameters. + void activated(QSocketDescriptor socket, QSocketNotifier::Type activationEvent = Read, + QPrivateSignal = {}); +#else + void activated(QSocketDescriptor socket, QSocketNotifier::Type activationEvent, QPrivateSignal); +#endif + + // ### Qt7: consider removing it. + // The old signal is compiled internally, but hidden outside of this class. + // This means the PMF-based connect(..) will automatically, on recompile, pick up the new + // version while the old-style connect(..) can query the metaobject system for this version. +#if defined(Q_MOC_RUN) || defined(BUILDING_QSOCKETNOTIFIER) || defined(Q_QDOC) void activated(int socket, QPrivateSignal); +#endif protected: bool event(QEvent *) override; @@ -74,6 +91,50 @@ private: Q_DISABLE_COPY(QSocketNotifier) }; +class QSocketDescriptor +{ +public: +#if defined(Q_OS_WIN) || defined(Q_QDOC) + using DescriptorType = Qt::HANDLE; +#define Q_DECL_CONSTEXPR_NOT_WIN +#else + using DescriptorType = int; +#define Q_DECL_CONSTEXPR_NOT_WIN Q_DECL_CONSTEXPR +#endif + + /* implicit */ Q_DECL_CONSTEXPR_NOT_WIN + QSocketDescriptor(DescriptorType descriptor = DescriptorType(-1)) noexcept : sockfd(descriptor) + { + } + +#if defined(Q_OS_WIN) || defined(Q_QDOC) + /* implicit */ QSocketDescriptor(qintptr desc) noexcept : sockfd(DescriptorType(desc)) {} + operator qintptr() const noexcept { return qintptr(sockfd); } + Q_DECL_CONSTEXPR Qt::HANDLE winHandle() const noexcept { return sockfd; } +#endif + Q_DECL_CONSTEXPR operator DescriptorType() const noexcept { return sockfd; } + + Q_DECL_CONSTEXPR_NOT_WIN bool isValid() const noexcept { return *this != QSocketDescriptor(); } + + friend Q_DECL_CONSTEXPR_NOT_WIN bool operator==(QSocketDescriptor lhs, + QSocketDescriptor rhs) noexcept + { + return lhs.sockfd == rhs.sockfd; + } + friend Q_DECL_CONSTEXPR_NOT_WIN bool operator!=(QSocketDescriptor lhs, + QSocketDescriptor rhs) noexcept + { + return lhs.sockfd != rhs.sockfd; + } + +#undef Q_DECL_CONSTEXPR_NOT_WIN + +private: + DescriptorType sockfd; +}; + QT_END_NAMESPACE +Q_DECLARE_METATYPE(QSocketNotifier::Type) +Q_DECLARE_METATYPE(QSocketDescriptor) #endif // QSOCKETNOTIFIER_H diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index 9923710eaa..3fd03301a1 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -188,9 +188,8 @@ public: QCborValue &operator=(const QCborValue &other); QCborValue &operator=(QCborValue &&other) noexcept { - QCborValue tmp; - qSwap(*this, tmp); - qSwap(other, *this); + QCborValue tmp(std::move(other)); + swap(tmp); return *this; } diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp index fc3653752a..ba87cf79fe 100644 --- a/src/corelib/time/qtimezoneprivate_android.cpp +++ b/src/corelib/time/qtimezoneprivate_android.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2014 Drew Parsons <dparsons@emerall.com> ** Contact: https://www.qt.io/licensing/ ** @@ -78,6 +78,26 @@ QAndroidTimeZonePrivate::~QAndroidTimeZonePrivate() { } +static QJNIObjectPrivate getDisplayName(QJNIObjectPrivate zone, jint style, jboolean dst, + const QLocale &locale) +{ + QJNIObjectPrivate jlanguage + = QJNIObjectPrivate::fromString(QLocale::languageToString(locale.language())); + QJNIObjectPrivate jcountry + = QJNIObjectPrivate::fromString(QLocale::countryToString(locale.country())); + QJNIObjectPrivate + jvariant = QJNIObjectPrivate::fromString(QLocale::scriptToString(locale.script())); + QJNIObjectPrivate jlocale("java.util.Locale", + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", + static_cast<jstring>(jlanguage.object()), + static_cast<jstring>(jcountry.object()), + static_cast<jstring>(jvariant.object())); + + return zone.callObjectMethod("getDisplayName", + "(ZILjava/util/Locale;)Ljava/lang/String;", + dst, style, jlocale.object()); +} + void QAndroidTimeZonePrivate::init(const QByteArray &ianaId) { const QString iana = QString::fromUtf8(ianaId); @@ -99,10 +119,13 @@ void QAndroidTimeZonePrivate::init(const QByteArray &ianaId) // the zone object we got and ignore the zone if not. // Try checking ianaId against getID(), getDisplayName(): m_id = match(androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;")); - for (int style = 1; m_id.isEmpty() && style-- > 0;) { - for (int dst = 1; m_id.isEmpty() && dst-- > 0;) { - m_id = match(androidTimeZone.callObjectMethod( - "getDisplayName", "(ZI)Ljava/lang/String;", bool(dst), style)); + for (int style = 1; m_id.isEmpty() && style >= 0; --style) { + for (int dst = 1; m_id.isEmpty() && dst >= 0; --dst) { + for (int pick = 2; m_id.isEmpty() && pick >= 0; --pick) { + QLocale locale = (pick == 0 ? QLocale::system() + : pick == 1 ? QLocale() : QLocale::c()); + m_id = match(getDisplayName(androidTimeZone, style, jboolean(dst), locale)); + } } } } @@ -124,14 +147,7 @@ QString QAndroidTimeZonePrivate::displayName(QTimeZone::TimeType timeType, QTime // treat all NameTypes as java TimeZone style LONG (value 1), except of course QTimeZone::ShortName which is style SHORT (value 0); jint style = (nameType == QTimeZone::ShortName ? 0 : 1); - QJNIObjectPrivate jlanguage = QJNIObjectPrivate::fromString(QLocale::languageToString(locale.language())); - QJNIObjectPrivate jcountry = QJNIObjectPrivate::fromString(QLocale::countryToString(locale.country())); - QJNIObjectPrivate jvariant = QJNIObjectPrivate::fromString(QLocale::scriptToString(locale.script())); - QJNIObjectPrivate jlocale("java.util.Locale", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", static_cast<jstring>(jlanguage.object()), static_cast<jstring>(jcountry.object()), static_cast<jstring>(jvariant.object())); - - QJNIObjectPrivate jname = androidTimeZone.callObjectMethod("getDisplayName", "(ZILjava/util/Locale;)Ljava/lang/String;", daylightTime, style, jlocale.object()); - - name = jname.toString(); + name = getDisplayName(androidTimeZone, style, daylightTime, locale).toString(); } return name; diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 3afd23d76b..40a69173c4 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -370,11 +370,18 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) /*! \enum QLineF::IntersectType - \obsolete Use QLineF::IntersectionType instead + \obsolete Use QLineF::IntersectionType instead. + + \value NoIntersection + Lines do not intersect. + \value UnboundedIntersection + Lines intersect, but not within the range defined by their lengths. + \value BoundedIntersection + Lnes intersect within the range defined by their lengths. */ /*! - \enum QLineF::IntersectionType + \typealias QLineF::IntersectionType Describes the intersection between two lines. |