diff options
Diffstat (limited to 'src')
58 files changed, 362 insertions, 220 deletions
diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp index 3afa1324837..a2597faa93c 100644 --- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp +++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp @@ -448,6 +448,17 @@ QSize QConcatenateTablesProxyModel::span(const QModelIndex &index) const } /*! + Returns a list of models that were added as source models for this proxy model. + + \since 5.15 +*/ +QList<QAbstractItemModel *> QConcatenateTablesProxyModel::sourceModels() const +{ + Q_D(const QConcatenateTablesProxyModel); + return d->m_models.toList(); +} + +/*! Adds a source model \a sourceModel, below all previously added source models. The ownership of \a sourceModel is not affected by this. diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.h b/src/corelib/itemmodels/qconcatenatetablesproxymodel.h index 69b3a2ba097..1fa84d5f519 100644 --- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.h +++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.h @@ -56,6 +56,7 @@ public: explicit QConcatenateTablesProxyModel(QObject *parent = nullptr); ~QConcatenateTablesProxyModel(); + QList<QAbstractItemModel *> sourceModels() const; Q_SCRIPTABLE void addSourceModel(QAbstractItemModel *sourceModel); Q_SCRIPTABLE void removeSourceModel(QAbstractItemModel *sourceModel); diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 31ecc8b20dc..aed50d6c5a4 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -285,11 +285,15 @@ namespace QtPrivate { { }; + template <typename T> + using is_bool = std::is_same<bool, typename std::decay<T>::type>; + template<typename From, typename To> struct AreArgumentsNarrowedBase<From, To, typename std::enable_if<sizeof(From) && sizeof(To)>::type> : std::integral_constant<bool, (std::is_floating_point<From>::value && std::is_integral<To>::value) || (std::is_floating_point<From>::value && std::is_floating_point<To>::value && sizeof(From) > sizeof(To)) || + ((std::is_pointer<From>::value || std::is_member_pointer<From>::value) && QtPrivate::is_bool<To>::value) || ((std::is_integral<From>::value || std::is_enum<From>::value) && std::is_floating_point<To>::value) || (std::is_integral<From>::value && std::is_integral<To>::value && (sizeof(From) > sizeof(To) diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h index 0629df8a950..c4e712b318c 100644 --- a/src/corelib/mimetypes/qmimeprovider_p.h +++ b/src/corelib/mimetypes/qmimeprovider_p.h @@ -140,7 +140,7 @@ public: enum : bool { InternalDatabaseAvailable = false }; QMimeXMLProvider(QMimeDatabasePrivate *db, InternalDatabaseEnum) : QMimeProviderBase(db, QString()) - { Q_UNREACHABLE() }; + { Q_UNREACHABLE(); }; #endif QMimeXMLProvider(QMimeDatabasePrivate *db, const QString &directory); ~QMimeXMLProvider(); diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 7ff87885a53..d7fb0d0d418 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -2041,6 +2041,42 @@ QStringRef QXmlStreamReader::dtdSystemId() const return QStringRef(); } +/*! + \since 5.15 + + Returns the maximum amount of characters a single entity is + allowed to expand into. If a single entity expands past the + given limit, the document is not considered well formed. + + \sa setEntityExpansionLimit +*/ +int QXmlStreamReader::entityExpansionLimit() const +{ + Q_D(const QXmlStreamReader); + return d->entityExpansionLimit; +} + +/*! + \since 5.15 + + Sets the maximum amount of characters a single entity is + allowed to expand into to \a limit. If a single entity expands + past the given limit, the document is not considered well formed. + + The limit is there to prevent DoS attacks when loading unknown + XML documents where recursive entity expansion could otherwise + exhaust all available memory. + + The default value for this property is 4096 characters. + + \sa entityExpansionLimit +*/ +void QXmlStreamReader::setEntityExpansionLimit(int limit) +{ + Q_D(QXmlStreamReader); + d->entityExpansionLimit = limit; +} + /*! If the tokenType() is \l StartElement, this function returns the element's namespace declarations. Otherwise an empty vector is returned. diff --git a/src/corelib/serialization/qxmlstream.g b/src/corelib/serialization/qxmlstream.g index 12ecc9bdb2a..b623de95056 100644 --- a/src/corelib/serialization/qxmlstream.g +++ b/src/corelib/serialization/qxmlstream.g @@ -285,9 +285,19 @@ public: QHash<QStringView, Entity> entityHash; QHash<QStringView, Entity> parameterEntityHash; QXmlStreamSimpleStack<Entity *>entityReferenceStack; + int entityExpansionLimit = 4096; + int entityLength = 0; inline bool referenceEntity(Entity &entity) { if (entity.isCurrentlyReferenced) { - raiseWellFormedError(QXmlStream::tr("Recursive entity detected.")); + raiseWellFormedError(QXmlStream::tr("Self-referencing entity detected.")); + return false; + } + // entityLength represents the amount of additional characters the + // entity expands into (can be negative for e.g. &). It's used to + // avoid DoS attacks through recursive entity expansions + entityLength += entity.value.size() - entity.name.size() - 2; + if (entityLength > entityExpansionLimit) { + raiseWellFormedError(QXmlStream::tr("Entity expands to more characters than the entity expansion limit.")); return false; } entity.isCurrentlyReferenced = true; @@ -838,6 +848,8 @@ entity_done ::= ENTITY_DONE; /. case $rule_number: entityReferenceStack.pop()->isCurrentlyReferenced = false; + if (entityReferenceStack.isEmpty()) + entityLength = 0; clearSym(); break; ./ diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h index 7d0aa64570e..c8647e04658 100644 --- a/src/corelib/serialization/qxmlstream.h +++ b/src/corelib/serialization/qxmlstream.h @@ -426,6 +426,8 @@ public: QStringRef dtdPublicId() const; QStringRef dtdSystemId() const; + int entityExpansionLimit() const; + void setEntityExpansionLimit(int limit); enum Error { NoError, diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h index 9c94e6d4346..103b123b10c 100644 --- a/src/corelib/serialization/qxmlstream_p.h +++ b/src/corelib/serialization/qxmlstream_p.h @@ -774,9 +774,19 @@ public: QHash<QStringView, Entity> entityHash; QHash<QStringView, Entity> parameterEntityHash; QXmlStreamSimpleStack<Entity *>entityReferenceStack; + int entityExpansionLimit = 4096; + int entityLength = 0; inline bool referenceEntity(Entity &entity) { if (entity.isCurrentlyReferenced) { - raiseWellFormedError(QXmlStream::tr("Recursive entity detected.")); + raiseWellFormedError(QXmlStream::tr("Self-referencing entity detected.")); + return false; + } + // entityLength represents the amount of additional characters the + // entity expands into (can be negative for e.g. &). It's used to + // avoid DoS attacks through recursive entity expansions + entityLength += entity.value.size() - entity.name.size() - 2; + if (entityLength > entityExpansionLimit) { + raiseWellFormedError(QXmlStream::tr("Entity expands to more characters than the entity expansion limit.")); return false; } entity.isCurrentlyReferenced = true; @@ -1308,6 +1318,8 @@ bool QXmlStreamReaderPrivate::parse() case 10: entityReferenceStack.pop()->isCurrentlyReferenced = false; + if (entityReferenceStack.isEmpty()) + entityLength = 0; clearSym(); break; diff --git a/src/corelib/thread/qrunnable.cpp b/src/corelib/thread/qrunnable.cpp index 5b883a05da3..32f3cd657eb 100644 --- a/src/corelib/thread/qrunnable.cpp +++ b/src/corelib/thread/qrunnable.cpp @@ -115,29 +115,29 @@ QRunnable::~QRunnable() class FunctionRunnable : public QRunnable { - std::function<void()> m_functor; + std::function<void()> m_functionToRun; public: - FunctionRunnable(std::function<void()> functor) : m_functor(std::move(functor)) + FunctionRunnable(std::function<void()> functionToRun) : m_functionToRun(std::move(functionToRun)) { } void run() override { - m_functor(); + m_functionToRun(); } }; /*! \since 5.15 - Creates a QRunnable that calls \a fun in run(). + Creates a QRunnable that calls \a functionToRun in run(). Auto-deletion is enabled by default. \sa run(), autoDelete() */ -QRunnable *QRunnable::create(std::function<void()> fun) +QRunnable *QRunnable::create(std::function<void()> functionToRun) { - return new FunctionRunnable(std::move(fun)); + return new FunctionRunnable(std::move(functionToRun)); } QT_END_NAMESPACE diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h index c13aa3fa8ce..26b6b991ac6 100644 --- a/src/corelib/thread/qrunnable.h +++ b/src/corelib/thread/qrunnable.h @@ -60,7 +60,7 @@ public: QRunnable() : ref(0) { } virtual ~QRunnable(); - static QRunnable *create(std::function<void()> fun); + static QRunnable *create(std::function<void()> functionToRun); bool autoDelete() const { return ref != -1; } void setAutoDelete(bool _autoDelete) { ref = _autoDelete ? 0 : -1; } diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index d1875a69a95..a9352c38943 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -515,16 +515,16 @@ void QThreadPool::start(QRunnable *runnable, int priority) \overload \since 5.15 - Reserves a thread and uses it to run \a fun, unless this thread will + Reserves a thread and uses it to run \a functionToRun, unless this thread will make the current thread count exceed maxThreadCount(). In that case, - \a fun is added to a run queue instead. The \a priority argument can + \a functionToRun is added to a run queue instead. The \a priority argument can be used to control the run queue's order of execution. */ -void QThreadPool::start(std::function<void()> fun, int priority) +void QThreadPool::start(std::function<void()> functionToRun, int priority) { - if (!fun) + if (!functionToRun) return; - start(QRunnable::create(std::move(fun)), priority); + start(QRunnable::create(std::move(functionToRun)), priority); } /*! @@ -561,17 +561,17 @@ bool QThreadPool::tryStart(QRunnable *runnable) /*! \overload \since 5.15 - Attempts to reserve a thread to run \a fun. + Attempts to reserve a thread to run \a functionToRun. If no threads are available at the time of calling, then this function - does nothing and returns \c false. Otherwise, \a fun is run immediately + does nothing and returns \c false. Otherwise, \a functionToRun is run immediately using one available thread and this function returns \c true. */ -bool QThreadPool::tryStart(std::function<void()> fun) +bool QThreadPool::tryStart(std::function<void()> functionToRun) { - if (!fun) + if (!functionToRun) return false; - return tryStart(QRunnable::create(std::move(fun))); + return tryStart(QRunnable::create(std::move(functionToRun))); } /*! \property QThreadPool::expiryTimeout diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h index 2eede44eca8..e3691ab010b 100644 --- a/src/corelib/thread/qthreadpool.h +++ b/src/corelib/thread/qthreadpool.h @@ -72,8 +72,8 @@ public: void start(QRunnable *runnable, int priority = 0); bool tryStart(QRunnable *runnable); - void start(std::function<void()> fun, int priority = 0); - bool tryStart(std::function<void()> fun); + void start(std::function<void()> functionToRun, int priority = 0); + bool tryStart(std::function<void()> functionToRun); int expiryTimeout() const; void setExpiryTimeout(int expiryTimeout); diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 790c20004a1..2a19611493b 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -1539,6 +1539,14 @@ QDateTimeParser::parse(QString input, int position, const QDateTime &defaultValu text = scan.input = input; // Set spec *after* all checking, so validity is a property of the string: scan.value = scan.value.toTimeSpec(spec); + + /* + However, even with a valid string we might have ended up with an invalid datetime: + the non-existent hour during dst changes, for instance. + */ + if (!scan.value.isValid() && scan.state == Acceptable) + scan.state = Intermediate; + return scan; } diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 47fa0520d9c..59883e3968d 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -324,7 +324,7 @@ public: QHashData::Node *i; public: -#if QT_DEPRECATED_SINCE(5, 15) +#if QT_DEPRECATED_WARNINGS_SINCE < QT_VERSION_CHECK(5, 15, 0) typedef std::bidirectional_iterator_tag iterator_category; #else typedef std::forward_iterator_tag iterator_category; @@ -354,23 +354,23 @@ public: return r; } #if QT_DEPRECATED_SINCE(5, 15) - inline QT_DEPRECATED iterator &operator--() + inline QT_DEPRECATED_VERSION_5_15 iterator &operator--() { i = QHashData::previousNode(i); return *this; } - inline QT_DEPRECATED iterator operator--(int) + inline QT_DEPRECATED_VERSION_5_15 iterator operator--(int) { iterator r = *this; i = QHashData::previousNode(i); return r; } - inline QT_DEPRECATED iterator operator+(int j) const + inline QT_DEPRECATED_VERSION_5_15 iterator operator+(int j) const { iterator r = *this; if (j > 0) while (j--) ++r; else while (j++) --r; return r; } - inline QT_DEPRECATED iterator operator-(int j) const { return operator+(-j); } - inline QT_DEPRECATED iterator &operator+=(int j) { return *this = *this + j; } - inline QT_DEPRECATED iterator &operator-=(int j) { return *this = *this - j; } - friend inline QT_DEPRECATED iterator operator+(int j, iterator k) { return k + j; } + inline QT_DEPRECATED_VERSION_5_15 iterator operator-(int j) const { return operator+(-j); } + inline QT_DEPRECATED_VERSION_5_15 iterator &operator+=(int j) { return *this = *this + j; } + inline QT_DEPRECATED_VERSION_5_15 iterator &operator-=(int j) { return *this = *this - j; } + friend inline QT_DEPRECATED_VERSION_5_15 iterator operator+(int j, iterator k) { return k + j; } #endif inline bool operator==(const const_iterator &o) const { return i == o.i; } @@ -387,7 +387,7 @@ public: QHashData::Node *i; public: -#if QT_DEPRECATED_SINCE(5, 15) +#if QT_DEPRECATED_WARNINGS_SINCE < QT_VERSION_CHECK(5, 15, 0) typedef std::bidirectional_iterator_tag iterator_category; #else typedef std::forward_iterator_tag iterator_category; @@ -420,23 +420,23 @@ public: return r; } #if QT_DEPRECATED_SINCE(5, 15) - inline QT_DEPRECATED const_iterator &operator--() + inline QT_DEPRECATED_VERSION_5_15 const_iterator &operator--() { i = QHashData::previousNode(i); return *this; } - inline QT_DEPRECATED const_iterator operator--(int) + inline QT_DEPRECATED_VERSION_5_15 const_iterator operator--(int) { const_iterator r = *this; i = QHashData::previousNode(i); return r; } - inline QT_DEPRECATED const_iterator operator+(int j) const + inline QT_DEPRECATED_VERSION_5_15 const_iterator operator+(int j) const { const_iterator r = *this; if (j > 0) while (j--) ++r; else while (j++) --r; return r; } - inline QT_DEPRECATED const_iterator operator-(int j) const { return operator+(-j); } - inline QT_DEPRECATED const_iterator &operator+=(int j) { return *this = *this + j; } - inline QT_DEPRECATED const_iterator &operator-=(int j) { return *this = *this - j; } - friend inline QT_DEPRECATED const_iterator operator+(int j, const_iterator k) + inline QT_DEPRECATED_VERSION_5_15 const_iterator operator-(int j) const { return operator+(-j); } + inline QT_DEPRECATED_VERSION_5_15 const_iterator &operator+=(int j) { return *this = *this + j; } + inline QT_DEPRECATED_VERSION_5_15 const_iterator &operator-=(int j) { return *this = *this - j; } + friend inline QT_DEPRECATED_VERSION_5_15 const_iterator operator+(int j, const_iterator k) { return k + j; } @@ -466,12 +466,12 @@ public: inline key_iterator &operator++() { ++i; return *this; } inline key_iterator operator++(int) { return key_iterator(i++);} #if QT_DEPRECATED_SINCE(5, 15) - inline QT_DEPRECATED key_iterator &operator--() + inline QT_DEPRECATED_VERSION_5_15 key_iterator &operator--() { --i; return *this; } - inline QT_DEPRECATED key_iterator operator--(int) { return key_iterator(i--); } + inline QT_DEPRECATED_VERSION_5_15 key_iterator operator--(int) { return key_iterator(i--); } #endif const_iterator base() const { return i; } }; @@ -1302,18 +1302,18 @@ public: return false; } #if QT_DEPRECATED_SINCE(5, 15) - inline QT_DEPRECATED bool hasPrevious() const { return i != c.constBegin(); } - inline QT_DEPRECATED Item previous() + inline QT_DEPRECATED_VERSION_5_15 bool hasPrevious() const { return i != c.constBegin(); } + inline QT_DEPRECATED_VERSION_5_15 Item previous() { n = --i; return n; } - inline QT_DEPRECATED Item peekPrevious() const + inline QT_DEPRECATED_VERSION_5_15 Item peekPrevious() const { const_iterator p = i; return --p; } - inline bool QT_DEPRECATED findPrevious(const T &t) + inline bool QT_DEPRECATED_VERSION_5_15 findPrevious(const T &t) { while (i != c.constBegin()) if (*(n = --i) == t) @@ -1399,18 +1399,18 @@ public: return false; } #if QT_DEPRECATED_SINCE(5, 15) - inline QT_DEPRECATED bool hasPrevious() const { return const_iterator(i) != c->constBegin(); } - inline QT_DEPRECATED Item previous() + inline QT_DEPRECATED_VERSION_5_15 bool hasPrevious() const { return const_iterator(i) != c->constBegin(); } + inline QT_DEPRECATED_VERSION_5_15 Item previous() { n = --i; return n; } - inline QT_DEPRECATED Item peekPrevious() const + inline QT_DEPRECATED_VERSION_5_15 Item peekPrevious() const { iterator p = i; return --p; } - inline QT_DEPRECATED bool findPrevious(const T &t) + inline QT_DEPRECATED_VERSION_5_15 bool findPrevious(const T &t) { while (const_iterator(i) != c->constBegin()) if (*(n = --i) == t) diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index fd25becbca1..d5a4b7c0270 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -710,7 +710,7 @@ void QScreenPrivate::updatePrimaryOrientation() \since 5.15 */ -QScreen *QScreen::virtualSiblingAt(const QPoint &point) +QScreen *QScreen::virtualSiblingAt(QPoint point) { const auto &siblings = virtualSiblings(); for (QScreen *sibling : siblings) { diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index 88925ab7314..09e1d4259a3 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -125,7 +125,7 @@ public: QRect availableGeometry() const; QList<QScreen *> virtualSiblings() const; - QScreen *virtualSiblingAt(const QPoint &point); + QScreen *virtualSiblingAt(QPoint point); QSize virtualSize() const; QRect virtualGeometry() const; diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 38814937f60..ec90247febb 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -663,6 +663,9 @@ glyph_metrics_t QFontEngine::tightBoundingBox(const QGlyphLayout &glyphs) QFixed ymax = 0; QFixed xmax = 0; for (int i = 0; i < glyphs.numGlyphs; i++) { + // If shaping has found this should be ignored, ignore it. + if (!glyphs.advances[i] || glyphs.attributes[i].dontPrint) + continue; glyph_metrics_t bb = boundingBox(glyphs.glyphs[i]); QFixed x = overall.xoff + glyphs.offsets[i].x + bb.x; QFixed y = overall.yoff + glyphs.offsets[i].y + bb.y; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index ac39a8cf69b..81ed8fa97a0 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -712,9 +712,8 @@ struct QBidiAlgorithm { analysis[pos].bidiDirection = QChar::DirEN; ++it; } - } else { - lastETPosition.clear(); } + lastETPosition.clear(); } last = current; lastPos = pos; diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index cda800ce354..2589c64b1c4 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -324,7 +324,7 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port) socket->setObjectName(QLatin1String("QFtpDTP Passive state socket")); connect(socket, SIGNAL(connected()), SLOT(socketConnected())); connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); + connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed())); connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); @@ -769,7 +769,7 @@ void QFtpDTP::setupSocket() socket->setObjectName(QLatin1String("QFtpDTP Active state socket")); connect(socket, SIGNAL(connected()), SLOT(socketConnected())); connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); + connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed())); connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); @@ -807,7 +807,7 @@ QFtpPI::QFtpPI(QObject *parent) : SLOT(connectionClosed())); connect(&commandSocket, SIGNAL(readyRead()), SLOT(readyRead())); - connect(&commandSocket, SIGNAL(error(QAbstractSocket::SocketError)), + connect(&commandSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), SLOT(error(QAbstractSocket::SocketError))); connect(&dtp, SIGNAL(connectState(int)), diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 65c2ae3054a..c1bb19650f7 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -156,7 +156,7 @@ void QHttpNetworkConnectionChannel::init() QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(_q_disconnected()), Qt::DirectConnection); - QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), + QObject::connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(_q_error(QAbstractSocket::SocketError)), Qt::DirectConnection); diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp index 981effb54f7..d39589fb967 100644 --- a/src/network/access/qhttpprotocolhandler.cpp +++ b/src/network/access/qhttpprotocolhandler.cpp @@ -233,7 +233,7 @@ void QHttpProtocolHandler::_q_readyRead() char c; qint64 ret = m_socket->peek(&c, 1); if (ret < 0) { - m_channel->_q_error(m_socket->socketError()); + m_channel->_q_error(m_socket->error()); // We still need to handle the reply so it emits its signals etc. if (m_reply) _q_receiveReply(); diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp index 0406f2fac1e..0029df41fe5 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend.cpp +++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp @@ -98,7 +98,7 @@ void QNetworkAccessDebugPipeBackend::open() // socket ready read -> we can push from socket to downstream connect(&socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); - connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError())); + connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), SLOT(socketError())); connect(&socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); connect(&socket, SIGNAL(connected()), SLOT(socketConnected())); // socket bytes written -> we can push more from upstream to socket @@ -242,9 +242,9 @@ void QNetworkAccessDebugPipeBackend::closeDownstreamChannel() void QNetworkAccessDebugPipeBackend::socketError() { - qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.socketError()); + qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.error()); QNetworkReply::NetworkError code; - switch (socket.socketError()) { + switch (socket.error()) { case QAbstractSocket::RemoteHostClosedError: return; // socketDisconnected will be called diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 85f065223a5..21d46011d7a 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1726,7 +1726,7 @@ int QNetworkAccessManager::transferTimeout() const Transfers are aborted if no bytes are transferred before the timeout expires. Zero means no timer is set. If no argument is provided, the timeout is - QNetworkRequest::TransferTimeoutPreset. If this function + QNetworkRequest::DefaultTransferTimeoutConstant. If this function is not called, the timeout is disabled and has the value zero. The request-specific non-zero timeouts set for the requests that are executed override this value. This means diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index c22dce8f1c3..fb30bfd4f18 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -554,32 +554,13 @@ QNetworkAccessManager::Operation QNetworkReply::operation() const return d_func()->operation; } -#if QT_DEPRECATED_SINCE(5, 15) /*! - \deprecated - - Use networkError() instead. - - Returns the error that was found during the processing of this - request. If no error was found, returns NoError. - - \sa setError(), networkError() -*/ -QNetworkReply::NetworkError QNetworkReply::error() const -{ - return networkError(); -} -#endif // QT_DEPRECATED_SINCE(5, 15) - -/*! - \since 5.15 - Returns the error that was found during the processing of this request. If no error was found, returns NoError. \sa setError() */ -QNetworkReply::NetworkError QNetworkReply::networkError() const +QNetworkReply::NetworkError QNetworkReply::error() const { return d_func()->errorCode; } @@ -877,7 +858,7 @@ void QNetworkReply::setRequest(const QNetworkRequest &request) Calling setError() does not emit the error(QNetworkReply::NetworkError) signal. - \sa error(), errorString(), networkError() + \sa error(), errorString() */ void QNetworkReply::setError(NetworkError errorCode, const QString &errorString) { diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h index 139009a56ab..4a402daa91a 100644 --- a/src/network/access/qnetworkreply.h +++ b/src/network/access/qnetworkreply.h @@ -124,12 +124,7 @@ public: QNetworkAccessManager *manager() const; QNetworkAccessManager::Operation operation() const; QNetworkRequest request() const; - -#if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_X("Use networkError()") NetworkError error() const; -#endif // QT_DEPRECATED_SINCE(5, 15) - NetworkError networkError() const; - + NetworkError error() const; bool isFinished() const; bool isRunning() const; QUrl url() const; diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 4765fdc30e2..33526bb7d56 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -931,7 +931,7 @@ int QNetworkRequest::transferTimeout() const Transfers are aborted if no bytes are transferred before the timeout expires. Zero means no timer is set. If no argument is provided, the timeout is - QNetworkRequest::TransferTimeoutPreset. If this function + QNetworkRequest::DefaultTransferTimeoutConstant. If this function is not called, the timeout is disabled and has the value zero. diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 5f1ff2fcb88..fb792e428f1 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -84,7 +84,7 @@ HostLookupState. If the host is found, QAbstractSocket enters ConnectingState and emits the hostFound() signal. When the connection has been established, it enters ConnectedState and - emits connected(). If an error occurs at any stage, error() is + emits connected(). If an error occurs at any stage, errorOccurred() is emitted. Whenever the state changes, stateChanged() is emitted. For convenience, isValid() returns \c true if the socket is ready for reading and writing, but note that the socket's state must be @@ -113,7 +113,7 @@ QAbstractSocket::UnconnectedState, and emits disconnected(). If you want to abort a connection immediately, discarding all pending data, call abort() instead. If the remote host closes the connection, - QAbstractSocket will emit error(QAbstractSocket::RemoteHostClosedError), + QAbstractSocket will emit errorOccurred(QAbstractSocket::RemoteHostClosedError), during which the socket state will still be ConnectedState, and then the disconnected() signal will be emitted. @@ -203,6 +203,14 @@ /*! \fn void QAbstractSocket::error(QAbstractSocket::SocketError socketError) + \obsolete + + Use errorOccurred() instead. +*/ + +/*! + \fn void QAbstractSocket::errorOccurred(QAbstractSocket::SocketError socketError) + \since 5.15 This signal is emitted after an error occurred. The \a socketError parameter describes the type of error that occurred. @@ -215,7 +223,7 @@ connections, you will have to register it with Q_DECLARE_METATYPE() and qRegisterMetaType(). - \sa socketError(), errorString(), {Creating Custom Qt Types} + \sa error(), errorString(), {Creating Custom Qt Types} */ /*! @@ -329,7 +337,8 @@ is non-blocking). \value UnknownSocketError An unidentified error occurred. - \sa QAbstractSocket::socketError() + \sa QAbstractSocket::error() + \sa QAbstractSocket::errorOccurred() */ /*! @@ -988,7 +997,7 @@ void QAbstractSocketPrivate::startConnectingByName(const QString &host) } state = QAbstractSocket::UnconnectedState; - emit q->error(socketError); + emit q->errorOccurred(socketError); emit q->stateChanged(state); } @@ -1047,7 +1056,7 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo) state = QAbstractSocket::UnconnectedState; setError(QAbstractSocket::HostNotFoundError, QAbstractSocket::tr("Host not found")); emit q->stateChanged(state); - emit q->error(QAbstractSocket::HostNotFoundError); + emit q->errorOccurred(QAbstractSocket::HostNotFoundError); return; } @@ -1070,8 +1079,8 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo) _q_testConnection(), this function takes the first address of the pending addresses list and tries to connect to it. If the connection succeeds, QAbstractSocket will emit - connected(). Otherwise, error(ConnectionRefusedError) or - error(SocketTimeoutError) is emitted. + connected(). Otherwise, errorOccurred(ConnectionRefusedError) or + errorOccurred(SocketTimeoutError) is emitted. */ void QAbstractSocketPrivate::_q_connectToNextAddress() { @@ -1101,7 +1110,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() // q->setErrorString(QAbstractSocket::tr("Connection refused")); } emit q->stateChanged(state); - emit q->error(socketError); + emit q->errorOccurred(socketError); return; } @@ -1223,7 +1232,7 @@ void QAbstractSocketPrivate::_q_abortConnectionAttempt() setError(QAbstractSocket::SocketTimeoutError, QAbstractSocket::tr("Connection timed out")); emit q->stateChanged(state); - emit q->error(socketError); + emit q->errorOccurred(socketError); } else { _q_connectToNextAddress(); } @@ -1430,14 +1439,14 @@ void QAbstractSocketPrivate::setError(QAbstractSocket::SocketError errorCode, \internal Sets the socket error state to \c errorCode and \a errorString, - and emits the QAbstractSocket::error() signal. + and emits the QAbstractSocket::errorOccurred() signal. */ void QAbstractSocketPrivate::setErrorAndEmit(QAbstractSocket::SocketError errorCode, const QString &errorString) { Q_Q(QAbstractSocket); setError(errorCode, errorString); - emit q->error(errorCode); + emit q->errorOccurred(errorCode); } /*! \internal @@ -1456,6 +1465,9 @@ QAbstractSocket::QAbstractSocket(SocketType socketType, : socketType == SctpSocket ? "Sctp" : "Unknown", &dd, parent); #endif d->socketType = socketType; + + // Support the deprecated error() signal: + connect(this, &QAbstractSocket::errorOccurred, this, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error)); } /*! @@ -1654,7 +1666,7 @@ bool QAbstractSocket::isValid() const established, QAbstractSocket enters ConnectedState and emits connected(). - At any point, the socket can emit error() to signal that an error + At any point, the socket can emit errorOccurred() to signal that an error occurred. \a hostName may be an IP address in string form (e.g., @@ -2092,7 +2104,7 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option) Waits until the socket is connected, up to \a msecs milliseconds. If the connection has been established, this function returns \c true; otherwise it returns \c false. In the case - where it returns \c false, you can call socketError() to determine + where it returns \c false, you can call error() to determine the cause of the error. The following example waits up to one second for a connection @@ -2864,7 +2876,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size) /*! Returns the state of the socket. - \sa socketError() + \sa error() */ QAbstractSocket::SocketState QAbstractSocket::state() const { @@ -2891,35 +2903,16 @@ QAbstractSocket::SocketType QAbstractSocket::socketType() const return d_func()->socketType; } -#if QT_DEPRECATED_SINCE(5, 15) -/*! - \deprecated - - Use socketError() instead. - - Returns the type of error that last occurred. - - \sa state(), errorString(), socketError() -*/ -QAbstractSocket::SocketError QAbstractSocket::error() const -{ - return socketError(); -} -#endif // QT_DEPRECATED_SINCE(5, 15) - /*! - \since 5.15 - Returns the type of error that last occurred. \sa state(), errorString() */ -QAbstractSocket::SocketError QAbstractSocket::socketError() const +QAbstractSocket::SocketError QAbstractSocket::error() const { return d_func()->socketError; } - /*! Sets the type of error that last occurred to \a socketError. diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index cbc79ea684f..1482dcaab24 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -180,12 +180,7 @@ public: SocketType socketType() const; SocketState state() const; - -#if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_X("Use socketError()") SocketError error() const; -#endif // QT_DEPRECATED_SINCE(5, 15) - - SocketError socketError() const; + SocketError error() const; // from QIODevice void close() override; @@ -211,7 +206,11 @@ Q_SIGNALS: void connected(); void disconnected(); void stateChanged(QAbstractSocket::SocketState); +#if QT_DEPRECATED_SINCE(5,15) + QT_DEPRECATED_X("Use QAbstractSocket::errorOccurred(QAbstractSocket::SocketError) instead") void error(QAbstractSocket::SocketError); +#endif + void errorOccurred(QAbstractSocket::SocketError); #ifndef QT_NO_NETWORKPROXY void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator); #endif diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index b80bdec9923..9b0460b1848 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -93,7 +93,7 @@ bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSo connect(d->socket, SIGNAL(bytesWritten(qint64)), this, SLOT(slotSocketBytesWritten()), Qt::DirectConnection); - connect(d->socket, SIGNAL(error(QAbstractSocket::SocketError)), + connect(d->socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError)), Qt::DirectConnection); connect(d->socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), @@ -370,8 +370,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut) if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { if (d->socket->state() == QAbstractSocket::UnconnectedState) return true; - setError(d->socket->socketError(), d->socket->errorString()); - if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) + setError(d->socket->error(), d->socket->errorString()); + if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -385,8 +385,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut) // Report any error that may occur. if (d->state != Connected) { - setError(d->socket->socketError(), d->socket->errorString()); - if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) + setError(d->socket->error(), d->socket->errorString()); + if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -401,7 +401,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut) if (d->state == Connected) { if (d->socket->bytesToWrite()) { if (!d->socket->waitForBytesWritten(msecs)) { - if (d->socket->socketError() == QAbstractSocket::SocketTimeoutError && timedOut) + if (d->socket->error() == QAbstractSocket::SocketTimeoutError && timedOut) *timedOut = true; return false; } @@ -421,7 +421,8 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut) // Report any error that may occur. if (d->state != Connected) { - if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) +// setError(d->socket->error(), d->socket->errorString()); + if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) *timedOut = true; } diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h index ae78c86b3c5..9cd62abca64 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -132,14 +132,14 @@ private: Q_DISABLE_COPY(QLocalSocket) #if defined(QT_LOCALSOCKET_TCP) Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QAbstractSocket::SocketState)) - Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError)) + Q_PRIVATE_SLOT(d_func(), void _q_errorOccurred(QAbstractSocket::SocketError)) #elif defined(Q_OS_WIN) Q_PRIVATE_SLOT(d_func(), void _q_canWrite()) Q_PRIVATE_SLOT(d_func(), void _q_pipeClosed()) Q_PRIVATE_SLOT(d_func(), void _q_winError(ulong, const QString &)) #else Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QAbstractSocket::SocketState)) - Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError)) + Q_PRIVATE_SLOT(d_func(), void _q_errorOccurred(QAbstractSocket::SocketError)) Q_PRIVATE_SLOT(d_func(), void _q_connectToSocket()) Q_PRIVATE_SLOT(d_func(), void _q_abortConnectionAttempt()) #endif diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h index e3bcd923263..0e05e4c5d75 100644 --- a/src/network/socket/qlocalsocket_p.h +++ b/src/network/socket/qlocalsocket_p.h @@ -127,7 +127,7 @@ public: QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const; void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function); void _q_stateChanged(QAbstractSocket::SocketState newState); - void _q_error(QAbstractSocket::SocketError newError); + void _q_errorOccurred(QAbstractSocket::SocketError newError); #elif defined(Q_OS_WIN) ~QLocalSocketPrivate(); void destroyPipeHandles(); @@ -144,7 +144,7 @@ public: QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const; void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function); void _q_stateChanged(QAbstractSocket::SocketState newState); - void _q_error(QAbstractSocket::SocketError newError); + void _q_errorOccurred(QAbstractSocket::SocketError newError); void _q_connectToSocket(); void _q_abortConnectionAttempt(); void cancelDelayedConnect(); diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index e13bcfc0cb9..1c63d161874 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -77,8 +77,8 @@ void QLocalSocketPrivate::setSocket(QLocalUnixSocket* socket) q->connect(tcpSocket, SIGNAL(disconnected()), q, SIGNAL(disconnected())); q->connect(tcpSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), q, SLOT(_q_stateChanged(QAbstractSocket::SocketState))); - q->connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), - q, SLOT(_q_error(QAbstractSocket::SocketError))); + q->connect(tcpSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), + q, SLOT(_q_errorOccurred(QAbstractSocket::SocketError))); q->connect(tcpSocket, SIGNAL(readChannelFinished()), q, SIGNAL(readChannelFinished())); tcpSocket->setParent(q); } @@ -88,7 +88,7 @@ qint64 QLocalSocketPrivate::skip(qint64 maxSize) return tcpSocket->skip(maxSize); } -void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError) +void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError) { Q_Q(QLocalSocket); QString function = QLatin1String("QLocalSocket"); diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index e860b880d55..d9b39a7752f 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -81,8 +81,8 @@ void QLocalSocketPrivate::init() q->connect(&unixSocket, SIGNAL(disconnected()), q, SIGNAL(disconnected())); q->connect(&unixSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), q, SLOT(_q_stateChanged(QAbstractSocket::SocketState))); - q->connect(&unixSocket, SIGNAL(error(QAbstractSocket::SocketError)), - q, SLOT(_q_error(QAbstractSocket::SocketError))); + q->connect(&unixSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), + q, SLOT(_q_errorOccurred(QAbstractSocket::SocketError))); q->connect(&unixSocket, SIGNAL(readChannelFinished()), q, SIGNAL(readChannelFinished())); unixSocket.setParent(q); } @@ -92,7 +92,7 @@ qint64 QLocalSocketPrivate::skip(qint64 maxSize) return unixSocket.skip(maxSize); } -void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError) +void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError) { Q_Q(QLocalSocket); QString function = QLatin1String("QLocalSocket"); @@ -464,7 +464,7 @@ void QLocalSocket::disconnectFromServer() QLocalSocket::LocalSocketError QLocalSocket::error() const { Q_D(const QLocalSocket); - switch (d->unixSocket.socketError()) { + switch (d->unixSocket.error()) { case QAbstractSocket::ConnectionRefusedError: return QLocalSocket::ConnectionRefusedError; case QAbstractSocket::RemoteHostClosedError: diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index eb5d1811347..6a9979a6753 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -559,8 +559,8 @@ void QSocks5SocketEnginePrivate::initialize(Socks5Mode socks5Mode) Qt::DirectConnection); QObject::connect(data->controlSocket, SIGNAL(bytesWritten(qint64)), q, SLOT(_q_controlSocketBytesWritten()), Qt::DirectConnection); - QObject::connect(data->controlSocket, SIGNAL(error(QAbstractSocket::SocketError)), - q, SLOT(_q_controlSocketError(QAbstractSocket::SocketError)), + QObject::connect(data->controlSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), + q, SLOT(_q_controlSocketErrorOccurred(QAbstractSocket::SocketError)), Qt::DirectConnection); QObject::connect(data->controlSocket, SIGNAL(disconnected()), q, SLOT(_q_controlSocketDisconnected()), Qt::DirectConnection); @@ -594,7 +594,7 @@ void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, const QString case ConnectError: case ControlSocketError: { - QAbstractSocket::SocketError controlSocketError = data->controlSocket->socketError(); + QAbstractSocket::SocketError controlSocketError = data->controlSocket->error(); if (socks5State != Connected) { switch (controlSocketError) { case QAbstractSocket::ConnectionRefusedError: @@ -918,7 +918,7 @@ void QSocks5SocketEnginePrivate::_q_emitPendingReadNotification() return; // check if there needs to be a new zero read notification if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState - && data->controlSocket->socketError() == QAbstractSocket::RemoteHostClosedError) { + && data->controlSocket->error() == QAbstractSocket::RemoteHostClosedError) { connectData->readBuffer.clear(); emitReadNotification(); } @@ -1056,7 +1056,7 @@ bool QSocks5SocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: Qt::DirectConnection); QObject::connect(d->data->controlSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(_q_controlSocketBytesWritten()), Qt::DirectConnection); - QObject::connect(d->data->controlSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_q_controlSocketError(QAbstractSocket::SocketError)), + QObject::connect(d->data->controlSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(_q_controlSocketErrorOccurred(QAbstractSocket::SocketError)), Qt::DirectConnection); QObject::connect(d->data->controlSocket, SIGNAL(disconnected()), this, SLOT(_q_controlSocketDisconnected()), Qt::DirectConnection); @@ -1231,7 +1231,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketBytesWritten() } } -void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketError error) +void QSocks5SocketEnginePrivate::_q_controlSocketErrorOccurred(QAbstractSocket::SocketError error) { QSOCKS5_D_DEBUG << "controlSocketError" << error << data->controlSocket->errorString(); @@ -1256,7 +1256,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr data->controlSocket->close(); emitConnectionNotification(); } else { - q_func()->setError(data->controlSocket->socketError(), data->controlSocket->errorString()); + q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); emitReadNotification(); emitWriteNotification(); } @@ -1348,7 +1348,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port) if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) { if (!d->udpData->udpSocket->bind(address, port)) { QSOCKS5_Q_DEBUG << "local udp bind failed"; - setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); + setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); return false; } d->localAddress = d->udpData->udpSocket->localAddress(); @@ -1656,8 +1656,8 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI } if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) { //### try frgamenting - if (d->udpData->udpSocket->socketError() == QAbstractSocket::DatagramTooLargeError) - setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); + if (d->udpData->udpSocket->error() == QAbstractSocket::DatagramTooLargeError) + setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); //### else maybe more serious error return -1; } @@ -1727,7 +1727,7 @@ bool QSocks5SocketEnginePrivate::waitForConnected(int msecs, bool *timedOut) return true; setErrorState(QSocks5SocketEnginePrivate::ControlSocketError); - if (timedOut && data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError) + if (timedOut && data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -1765,8 +1765,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) return true; - setError(d->data->controlSocket->socketError(), d->data->controlSocket->errorString()); - if (timedOut && d->data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError) + setError(d->data->controlSocket->error(), d->data->controlSocket->errorString()); + if (timedOut && d->data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -1775,8 +1775,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) } else { while (!d->readNotificationActivated) { if (!d->udpData->udpSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { - setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); - if (timedOut && d->udpData->udpSocket->socketError() == QAbstractSocket::SocketTimeoutError) + setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); + if (timedOut && d->udpData->udpSocket->error() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h index c256987e2de..77b461b9441 100644 --- a/src/network/socket/qsocks5socketengine_p.h +++ b/src/network/socket/qsocks5socketengine_p.h @@ -130,7 +130,7 @@ private: Q_DISABLE_COPY_MOVE(QSocks5SocketEngine) Q_PRIVATE_SLOT(d_func(), void _q_controlSocketConnected()) Q_PRIVATE_SLOT(d_func(), void _q_controlSocketReadNotification()) - Q_PRIVATE_SLOT(d_func(), void _q_controlSocketError(QAbstractSocket::SocketError)) + Q_PRIVATE_SLOT(d_func(), void _q_controlSocketErrorOccurred(QAbstractSocket::SocketError)) #ifndef QT_NO_UDPSOCKET Q_PRIVATE_SLOT(d_func(), void _q_udpSocketReadNotification()) #endif @@ -246,7 +246,7 @@ public: void _q_controlSocketConnected(); void _q_controlSocketReadNotification(); - void _q_controlSocketError(QAbstractSocket::SocketError); + void _q_controlSocketErrorOccurred(QAbstractSocket::SocketError); #ifndef QT_NO_UDPSOCKET void _q_udpSocketReadNotification(); #endif diff --git a/src/network/ssl/qdtls_openssl.cpp b/src/network/ssl/qdtls_openssl.cpp index 36b4d572fdf..25a6c5f49c8 100644 --- a/src/network/ssl/qdtls_openssl.cpp +++ b/src/network/ssl/qdtls_openssl.cpp @@ -1125,7 +1125,7 @@ qint64 QDtlsPrivateOpenSSL::writeDatagramEncrypted(QUdpSocket *socket, // some errors can be just ignored (it's UDP, not TCP after all). // Unlike QSslSocket we do not abort though. QString description(QSslSocketBackendPrivate::getErrorsFromOpenSsl()); - if (socket->socketError() != QAbstractSocket::UnknownSocketError && description.isEmpty()) { + if (socket->error() != QAbstractSocket::UnknownSocketError && description.isEmpty()) { setDtlsError(QDtlsError::UnderlyingSocketError, socket->errorString()); } else { setDtlsError(QDtlsError::TlsFatalError, diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 64c6629645a..da9d4a38fec 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -676,7 +676,7 @@ bool QSslSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState state d->createPlainSocket(openMode); bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode); d->cachedSocketDescriptor = d->plainSocket->socketDescriptor(); - d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); + d->setError(d->plainSocket->error(), d->plainSocket->errorString()); setSocketState(state); setOpenMode(openMode); setLocalPort(d->plainSocket->localPort()); @@ -1784,7 +1784,7 @@ bool QSslSocket::waitForConnected(int msecs) bool retVal = d->plainSocket->waitForConnected(msecs); if (!retVal) { setSocketState(d->plainSocket->state()); - d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); + d->setError(d->plainSocket->error(), d->plainSocket->errorString()); } return retVal; } @@ -1953,7 +1953,7 @@ bool QSslSocket::waitForDisconnected(int msecs) bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed())); if (!retVal) { setSocketState(d->plainSocket->state()); - d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); + d->setError(d->plainSocket->error(), d->plainSocket->errorString()); } return retVal; } @@ -2681,7 +2681,7 @@ void QSslSocketPrivate::createPlainSocket(QIODevice::OpenMode openMode) q->connect(plainSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), q, SLOT(_q_stateChangedSlot(QAbstractSocket::SocketState)), Qt::DirectConnection); - q->connect(plainSocket, SIGNAL(error(QAbstractSocket::SocketError)), + q->connect(plainSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), q, SLOT(_q_errorSlot(QAbstractSocket::SocketError)), Qt::DirectConnection); q->connect(plainSocket, SIGNAL(readyRead()), @@ -2857,7 +2857,7 @@ void QSslSocketPrivate::_q_errorSlot(QAbstractSocket::SocketError error) readBufferMaxSize = tmpReadBufferMaxSize; } - setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); } /*! diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index f033d3b2988..57f7f459ce4 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1125,7 +1125,7 @@ void QSslSocketBackendPrivate::transmit() if (actualWritten < 0) { //plain socket write fails if it was in the pending close state. const ScopedBool bg(inSetAndEmitError, true); - setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); return; } transmitting = true; diff --git a/src/network/ssl/qsslsocket_schannel.cpp b/src/network/ssl/qsslsocket_schannel.cpp index ba15a0a65e2..2db5c48ff29 100644 --- a/src/network/ssl/qsslsocket_schannel.cpp +++ b/src/network/ssl/qsslsocket_schannel.cpp @@ -576,7 +576,7 @@ bool QSslSocketBackendPrivate::sendToken(void *token, unsigned long tokenLength, if (written != qint64(tokenLength)) { // Failed to write/buffer everything or an error occurred if (emitError) - setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); return false; } return true; @@ -1286,7 +1286,7 @@ void QSslSocketBackendPrivate::transmit() if (bytesWritten >= 0) { totalBytesWritten += bytesWritten; } else { - setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); return; } } diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index a2619b2d25b..d7ccd9db921 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -1693,6 +1693,9 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) QFixed ymax = 0; QFixed xmax = 0; for (int i = 0; i < glyphs.numGlyphs; i++) { + // If shaping has found this should be ignored, ignore it. + if (!glyphs.advances[i] || glyphs.attributes[i].dontPrint) + continue; Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs.glyphs[i]) : nullptr; if (!g) { if (!face) diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp index a7423e9c47e..cef15543d4f 100644 --- a/src/plugins/platforms/wasm/qwasmbackingstore.cpp +++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp @@ -36,7 +36,7 @@ #include <QtGui/qpainter.h> #include <private/qguiapplication_p.h> #include <qpa/qplatformscreen.h> - +#include <QtGui/qoffscreensurface.h> #include <QtGui/qbackingstore.h> QT_BEGIN_NAMESPACE @@ -53,12 +53,29 @@ QWasmBackingStore::QWasmBackingStore(QWasmCompositor *compositor, QWindow *windo QWasmBackingStore::~QWasmBackingStore() { + auto window = this->window(); + QWasmIntegration::get()->removeBackingStore(window); + destroy(); + QWasmWindow *wasmWindow = static_cast<QWasmWindow *>(window->handle()); + if (wasmWindow) + wasmWindow->setBackingStore(nullptr); } void QWasmBackingStore::destroy() { - if (m_texture->isCreated()) - m_texture->destroy(); + if (m_texture->isCreated()) { + auto context = m_compositor->context(); + auto currentContext = QOpenGLContext::currentContext(); + if (!currentContext || !QOpenGLContext::areSharing(context, currentContext)) { + QOffscreenSurface offScreenSurface(m_compositor->screen()->screen()); + offScreenSurface.setFormat(context->format()); + offScreenSurface.create(); + context->makeCurrent(&offScreenSurface); + m_texture->destroy(); + } else { + m_texture->destroy(); + } + } } QPaintDevice *QWasmBackingStore::paintDevice() @@ -81,9 +98,9 @@ void QWasmBackingStore::updateTexture() if (m_dirty.isNull()) return; - if (m_recreateTexture && m_texture->isCreated()) { + if (m_recreateTexture) { m_recreateTexture = false; - m_texture->destroy(); + destroy(); } if (!m_texture->isCreated()) { diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index 74890ead82a..a4cfaa85a83 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -58,7 +58,6 @@ QWasmCompositedWindow::QWasmCompositedWindow() QWasmCompositor::QWasmCompositor(QWasmScreen *screen) :QObject(screen) - , m_frameBuffer(nullptr) , m_blitter(new QOpenGLTextureBlitter) , m_needComposit(false) , m_inFlush(false) @@ -70,7 +69,6 @@ QWasmCompositor::QWasmCompositor(QWasmScreen *screen) QWasmCompositor::~QWasmCompositor() { - delete m_frameBuffer; destroy(); } @@ -747,3 +745,8 @@ QWasmScreen *QWasmCompositor::screen() { return static_cast<QWasmScreen *>(parent()); } + +QOpenGLContext *QWasmCompositor::context() +{ + return m_context.data(); +} diff --git a/src/plugins/platforms/wasm/qwasmcompositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h index 250d244c9f9..a07c747a98b 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.h +++ b/src/plugins/platforms/wasm/qwasmcompositor.h @@ -124,11 +124,13 @@ public: static QWasmTitleBarOptions makeTitleBarOptions(const QWasmWindow *window); static QRect titlebarRect(QWasmTitleBarOptions tb, QWasmCompositor::SubControls subcontrol); + QWasmScreen *screen(); + QOpenGLContext *context(); + private slots: void frame(); private: - QWasmScreen *screen(); void notifyTopWindowChanged(QWasmWindow *window); void drawWindow(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window); void drawWindowContent(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window); @@ -137,7 +139,6 @@ private: void drawWindowDecorations(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window); void drwPanelButton(); - QImage *m_frameBuffer; QScopedPointer<QOpenGLContext> m_context; QScopedPointer<QOpenGLTextureBlitter> m_blitter; diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index d1901d840ef..37cc6185c54 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -189,6 +189,11 @@ QPlatformBackingStore *QWasmIntegration::createPlatformBackingStore(QWindow *win #endif } +void QWasmIntegration::removeBackingStore(QWindow* window) +{ + m_backingStores.remove(window); +} + #ifndef QT_NO_OPENGL QPlatformOpenGLContext *QWasmIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h index 08b68cb5f7b..cb8639086ac 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.h +++ b/src/plugins/platforms/wasm/qwasmintegration.h @@ -89,6 +89,7 @@ public: void resizeScreen(const emscripten::val &canvas); void resizeAllScreens(); void updateDpi(); + void removeBackingStore(QWindow* window); private: mutable QWasmFontDatabase *m_fontDb; diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index 95fa8355c77..28e17d23010 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -181,7 +181,7 @@ Run the installer, select custom installation and install the MySQL C Connector which matches your Qt installation (x86 or x64). - After installation make sure that the needed files are there: + After installation check that the needed files are there: \list \li \c {<MySQL dir>/lib/libmysql.lib} \li \c {<MySQL dir>/lib/libmysql.dll} @@ -194,16 +194,20 @@ \li \c {<MariaDB dir>/include/mysql.h} \endlist - Build the plugin as follows (here it is assumed that the MySQL - C Connector is installed in + \note As of MySQL 8.0.19, the C Connector is no longer offered as a standalone + installable component. Instead, you can get \c{mysql.h} and \c{libmysql.*} by + installing the full MySQL Server (x64 only) or the + \l{https://downloads.mariadb.org/connector-c/}{MariaDB C Connector}. + + Build the plugin as follows (here it is assumed that \c{<MySQL dir>} is \c{C:/Program Files/MySQL/MySQL Connector C 6.1}): \snippet code/doc_src_sql-driver.qdoc 5 If you are not using a Microsoft compiler, replace \c nmake with \c - mingw32-make in the line above. + mingw32-make above. - When you distribute your application, remember to include libmysql.dll / libmariadb.dll + When you distribute your application, remember to include \e libmysql.dll / \e libmariadb.dll in your installation package. It must be placed in the same folder as the application executable. \e libmysql.dll additionally needs the MSVC runtime libraries which can be installed with diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 437ce4a1145..3fb55781532 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1302,8 +1302,12 @@ QStringList QFileDialog::selectedFiles() const QStringList files; const QList<QUrl> userSelectedFiles = d->userSelectedFiles(); files.reserve(userSelectedFiles.size()); - for (const QUrl &file : userSelectedFiles) - files.append(file.toLocalFile()); + for (const QUrl &file : userSelectedFiles) { + if (file.isLocalFile() || file.isEmpty()) + files.append(file.toLocalFile()); + else + files.append(file.toString()); + } if (files.isEmpty() && d->usingWidgets()) { const FileMode fm = fileMode(); if (fm != ExistingFile && fm != ExistingFiles) @@ -3151,7 +3155,7 @@ void QFileDialogPrivate::createWidgets() // filetype qFileDialogUi->fileTypeCombo->setDuplicatesEnabled(false); - qFileDialogUi->fileTypeCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); + qFileDialogUi->fileTypeCombo->setSizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow); qFileDialogUi->fileTypeCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); QObject::connect(qFileDialogUi->fileTypeCombo, SIGNAL(activated(int)), q, SLOT(_q_useNameFilter(int))); diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 31e32bb9313..b0f4312f401 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -2384,13 +2384,23 @@ bool QWizard::hasVisitedPage(int theid) const \sa hasVisitedPage() */ -QList<int> QWizard::visitedPages() const +QList<int> QWizard::visitedIds() const { Q_D(const QWizard); return d->history; } /*! + \obsolete Use visitedIds() instead +*/ +#if QT_DEPRECATED_SINCE(5, 15) +QList<int> QWizard::visitedPages() const +{ + return visitedIds(); +} +#endif + +/*! Returns the list of page IDs. \since 4.5 */ diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index ef71efa0cb2..a40635c4a5f 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -128,7 +128,10 @@ public: void removePage(int id); QWizardPage *page(int id) const; bool hasVisitedPage(int id) const; - QList<int> visitedPages() const; // ### Qt 6: visitedIds()? +#if QT_DEPRECATED_SINCE(5, 15) + QList<int> visitedPages() const; +#endif + QList<int> visitedIds() const; QList<int> pageIds() const; void setStartId(int id); int startId() const; diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h index 6c92f87c462..a519a8696ad 100644 --- a/src/widgets/kernel/qshortcut.h +++ b/src/widgets/kernel/qshortcut.h @@ -90,7 +90,8 @@ public: template<class Obj1, typename Func1> QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); @@ -98,7 +99,8 @@ public: template<class Obj1, typename Func1, typename Func2> QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, Func2 slot2, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); @@ -108,7 +110,9 @@ public: QShortcut(const QKeySequence &key, QWidget *parent, const Obj1 *object1, Func1 slot1, const Obj2 *object2, Func2 slot2, - Qt::ShortcutContext context = Qt::WindowShortcut) + Qt::ShortcutContext context = Qt::WindowShortcut, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0, + typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj2*>::Value>::type* = 0) : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) { connect(this, &QShortcut::activated, object1, std::move(slot1)); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b4699ae0408..03d6ea31e94 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -395,7 +395,7 @@ void QWidget::setAutoFillBackground(bool enabled) Every widget's constructor accepts one or two standard arguments: \list 1 - \li \c{QWidget *parent = \nullptr} is the parent of the new widget. + \li \c{QWidget *parent = nullptr} is the parent of the new widget. If it is \nullptr (the default), the new widget will be a window. If not, it will be a child of \e parent, and be constrained by \e parent's geometry (unless you specify Qt::Window as window flag). diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 9c1bd1e79ac..47993b8f3b7 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -894,7 +894,7 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const \value AdjustToContents The combobox will always adjust to the contents \value AdjustToContentsOnFirstShow The combobox will adjust to its contents the first time it is shown. - \value AdjustToMinimumContentsLength Use AdjustToContents or AdjustToContentsOnFirstShow instead. + \omitvalue AdjustToMinimumContentsLength \value AdjustToMinimumContentsLengthWithIcon The combobox will adjust to \l minimumContentsLength plus space for an icon. For performance reasons use this policy on large models. */ diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 444c834e880..99816954fa8 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -137,8 +137,11 @@ public: enum SizeAdjustPolicy { AdjustToContents, AdjustToContentsOnFirstShow, - AdjustToMinimumContentsLength, // ### Qt 6: remove - AdjustToMinimumContentsLengthWithIcon +#if QT_DEPRECATED_SINCE(5, 15) + AdjustToMinimumContentsLength Q_DECL_ENUMERATOR_DEPRECATED_X( + "Use AdjustToContents or AdjustToContentsOnFirstShow"), // ### Qt 6: remove +#endif + AdjustToMinimumContentsLengthWithIcon = AdjustToContentsOnFirstShow + 2 }; Q_ENUM(SizeAdjustPolicy) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 48588b1e8ee..105318ba206 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -683,7 +683,8 @@ void QDateTimeEdit::setTimeRange(QTime min, QTime max) \brief The currently displayed fields of the date time edit. Returns a bit set of the displayed sections for this format. - \a setDisplayFormat(), displayFormat() + + \sa setDisplayFormat(), displayFormat() */ QDateTimeEdit::Sections QDateTimeEdit::displayedSections() const @@ -696,7 +697,8 @@ QDateTimeEdit::Sections QDateTimeEdit::displayedSections() const \property QDateTimeEdit::currentSection \brief The current section of the spinbox. - \a setCurrentSection() + + \sa setCurrentSection() */ QDateTimeEdit::Section QDateTimeEdit::currentSection() const @@ -776,8 +778,7 @@ int QDateTimeEdit::sectionCount() const the cursorPosition is 5, currentSectionIndex returns 1. If the cursorPosition is 3, currentSectionIndex is 0, and so on. - \a setCurrentSection() - \sa currentSection() + \sa setCurrentSection(), currentSection() */ int QDateTimeEdit::currentSectionIndex() const @@ -1448,7 +1449,16 @@ void QDateTimeEdit::fixup(QString &input) const QValidator::State state; int copy = d->edit->cursorPosition(); - d->validateAndInterpret(input, copy, state, true); + QDateTime value = d->validateAndInterpret(input, copy, state, true); + /* + String was valid, but the datetime still is not; use the time that + has the same distance from epoch. + CorrectToPreviousValue correction is handled by QAbstractSpinBox. + */ + if (!value.isValid() && d->correctionMode == QAbstractSpinBox::CorrectToNearestValue) { + value = QDateTime::fromMSecsSinceEpoch(value.toMSecsSinceEpoch(), value.timeSpec()); + input = textFromDateTime(value); + } } @@ -2085,6 +2095,17 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c const int oldDay = v.date().day(calendar); setDigit(v, sectionIndex, val); + /* + Stepping into a daylight saving time that doesn't exist, + so use the time that has the same distance from epoch. + */ + if (!v.isValid()) { + auto msecsSinceEpoch = v.toMSecsSinceEpoch(); + // decreasing from e.g 3am to 2am would get us back to 3am, but we want 1am + if (steps < 0 && sn.type & HourSectionMask) + msecsSinceEpoch -= 3600 * 1000; + v = QDateTime::fromMSecsSinceEpoch(msecsSinceEpoch, v.timeSpec()); + } // if this sets year or month it will make // sure that days are lowered if needed. diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index b53a991dae1..36dff4d420c 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -78,7 +78,10 @@ public: DockWidgetVerticalTitleBar = 0x08, DockWidgetFeatureMask = 0x0f, - AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### Qt 6: remove +#if QT_DEPRECATED_SINCE(5, 15) + AllDockWidgetFeatures Q_DECL_ENUMERATOR_DEPRECATED = + DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### Qt 6: remove +#endif NoDockWidgetFeatures = 0x00, Reserved = 0xff diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp index 3ddada4514e..4d299d87399 100644 --- a/src/widgets/widgets/qlcdnumber.cpp +++ b/src/widgets/widgets/qlcdnumber.cpp @@ -713,7 +713,7 @@ void QLCDNumber::paintEvent(QPaintEvent *) void QLCDNumberPrivate::internalSetString(const QString& s) { Q_Q(QLCDNumber); - QString buffer; + QString buffer(ndigits, QChar()); int i; int len = s.length(); QBitArray newPoints(ndigits); diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 9faf161cb17..0ba3611cfd0 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1202,8 +1202,8 @@ QMargins QLineEdit::textMargins() const The input mask is an input template string. It can contain the following elements: \table - \row \li Mask Characters \li Defines the class of input characters that are - considered valid in this position + \row \li Mask Characters \li Defines the \l {QChar::} {Category} of input characters + that are considered valid in this position \row \li Meta Characters \li Various special meanings \row \li Separators \li All other characters are regarded as immutable separators \endtable @@ -1212,17 +1212,21 @@ QMargins QLineEdit::textMargins() const \table \header \li Mask Character \li Meaning - \row \li \c A \li ASCII alphabetic character required. A-Z, a-z. - \row \li \c a \li ASCII alphabetic character permitted but not required. - \row \li \c N \li ASCII alphanumeric character required. A-Z, a-z, 0-9. - \row \li \c n \li ASCII alphanumeric character permitted but not required. + \row \li \c A \li character of the Letter category required, such as A-Z, a-z. + \row \li \c a \li character of the Letter category permitted but not required. + \row \li \c N \li character of the Letter or Number category required, such as + A-Z, a-z, 0-9. + \row \li \c n \li character of the Letter or Number category permitted but not required. \row \li \c X \li Any non-blank character required. \row \li \c x \li Any non-blank character permitted but not required. - \row \li \c 9 \li ASCII digit required. 0-9. - \row \li \c 0 \li ASCII digit permitted but not required. - \row \li \c D \li ASCII digit required. 1-9. - \row \li \c d \li ASCII digit permitted but not required (1-9). - \row \li \c # \li ASCII digit or plus/minus sign permitted but not required. + \row \li \c 9 \li character of the Number category required, e.g 0-9. + \row \li \c 0 \li character of the Number category permitted but not required. + \row \li \c D \li character of the Number category and larger than zero required, + such as 1-9 + \row \li \c d \li character of the Number category and larger than zero permitted but not + required, such as 1-9. + \row \li \c # \li character of the Number category, or plus/minus sign permitted but not + required. \row \li \c H \li Hexadecimal character required. A-F, a-f, 0-9. \row \li \c h \li Hexadecimal character permitted but not required. \row \li \c B \li Binary character required. 0-1. @@ -1264,7 +1268,7 @@ QMargins QLineEdit::textMargins() const To get range control (e.g., for an IP address) use masks together with \l{setValidator()}{validators}. - \sa maxLength + \sa maxLength, QChar::isLetter(), QChar::isNumber(), QChar::digitValue() */ QString QLineEdit::inputMask() const { diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h index 2492e8487fd..976e45f9ed0 100644 --- a/src/widgets/widgets/qstatusbar.h +++ b/src/widgets/widgets/qstatusbar.h @@ -83,7 +83,6 @@ protected: void paintEvent(QPaintEvent *) override; void resizeEvent(QResizeEvent *) override; - // ### Qt 6: consider making reformat() and hideOrShow() private void reformat(); void hideOrShow(); bool event(QEvent *) override; |