From f43e947dc405b6a2324656f631c804db8e8dec3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Thu, 26 Jul 2018 16:03:50 +0200 Subject: QJsonDocument: Make emptyObject an object A default-constructed QJsonObject has no data payload, it is only a pair of null pointers. So, when it becomes necessary to 'materialize' such an object, a special global emptyObject constant is used as the substitute payload. There is a small problem with this global constant though, namely that it's is_object flag is unset. In other words, the emptyObject is not an object, but an array. Fix by setting the is_object flag on emptyObject. The example code in the bug report QJsonObject parent; QJsonObject child; parent["child"] = child; // 1 child = parent["child"].toObject(); // 2 child["test"] = "test"; // 3 runs into this problem on line 1. Inserting the default-constructed child means inserting a copy of emptyObject. On line 2 a pointer to this copy of emptyObject is retrieved and cast to an object. But it's not an object, it's an array, so things go wrong hereafter. Specifically, on line 3, two inserts are performed, one from operator[] and one from operator=. Each insert increments a compaction counter. The second insert triggers compaction (QJsonObject::insert calls Value::requiredStorage calls Data::compact) and compaction branches based on the is_object flag. Replacing line 3 with child.insert("test", "test"); causes the example to appear to work since compaction is not triggered and the JSON serializer does not look at the is_object flag. Still, any further insert() calls would trigger compaction and memory corruption. Task-number: QTBUG-69626 Change-Id: I8bd5174dce95998bac479c4b4ffea70bca1a4d04 Reviewed-by: Lars Knoll --- src/corelib/serialization/qjson.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/serialization/qjson.cpp b/src/corelib/serialization/qjson.cpp index 7912b5040c..b82923fe0c 100644 --- a/src/corelib/serialization/qjson.cpp +++ b/src/corelib/serialization/qjson.cpp @@ -46,7 +46,7 @@ namespace QJsonPrivate { static Q_CONSTEXPR Base emptyArray = { { qle_uint(sizeof(Base)) }, { 0 }, { qle_uint(0) } }; -static Q_CONSTEXPR Base emptyObject = { { qle_uint(sizeof(Base)) }, { 0 }, { qle_uint(0) } }; +static Q_CONSTEXPR Base emptyObject = { { qle_uint(sizeof(Base)) }, { qToLittleEndian(1u) }, { qle_uint(0) } }; void Data::compact() { -- cgit v1.2.3 From 2dfa41e0eac65f5772ec61364f9afd0ce49fecc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 30 Jul 2018 17:16:01 +0200 Subject: Return to eventloop after emitting encrypted When the connection has been encrypted we will, in QHttpNetworkConnectionChannel::_q_encrypted, emit 'reply->encrypted' in which user slots can be called. In the event that the user calls abort it will, however, not abort until the next time it goes back to the event loop (which might not happen until after the request has already been sent). Task-number: QTBUG-65960 Change-Id: I96865f83c47f89deb9f644c86a71948dbb0ec0d0 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 16 +++++++++++++++- src/network/access/qhttpnetworkconnectionchannel_p.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 0ac14c78f6..5726925cb0 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -251,6 +251,20 @@ bool QHttpNetworkConnectionChannel::sendRequest() return protocolHandler->sendRequest(); } +/* + * Invoke "protocolHandler->sendRequest" using a queued connection. + * It's used to return to the event loop before invoking sendRequest when + * there's a very real chance that the request could have been aborted + * (i.e. after having emitted 'encrypted'). + */ +void QHttpNetworkConnectionChannel::sendRequestDelayed() +{ + QMetaObject::invokeMethod(this, [this] { + Q_ASSERT(!protocolHandler.isNull()); + if (reply) + protocolHandler->sendRequest(); + }, Qt::ConnectionType::QueuedConnection); +} void QHttpNetworkConnectionChannel::_q_receiveReply() { @@ -1234,7 +1248,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted() emit reply->encrypted(); } if (reply) - sendRequest(); + sendRequestDelayed(); } } diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index e9cdae5653..270b3eb9ba 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -174,6 +174,7 @@ public: void abort(); bool sendRequest(); + void sendRequestDelayed(); bool ensureConnection(); -- cgit v1.2.3 From 9a30a8f4fc19a90835e4d1032f9ab753ff3b2ae6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 30 Jul 2018 17:43:05 +0200 Subject: Link from QLocale to where date-time formats are explained QLocale has various methods that deal in date-time formats, which may be supplied as strings; but does not document the form of a format string. That's documented in QDate, QTime and QDateTime, so link to them for the details. Task-number: QTBUG-23307 Change-Id: I6347d80a87dc03f6a4065e3d5bf4d535f05af93f Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 12 ++++++++++++ src/corelib/tools/qlocale.qdoc | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 00a2c05c35..89896cdc60 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1773,6 +1773,8 @@ QString QLocale::toString(qulonglong i) const Returns a localized string representation of the given \a date in the specified \a format. If \a format is an empty string, an empty string is returned. + + \sa QDate::toString() */ QString QLocale::toString(const QDate &date, const QString &format) const @@ -1787,6 +1789,8 @@ QString QLocale::toString(const QDate &date, const QString &format) const Returns a localized string representation of the given \a date in the specified \a format. If \a format is an empty string, an empty string is returned. + + \sa QDate::toString() */ QString QLocale::toString(const QDate &date, QStringView format) const { @@ -1839,6 +1843,8 @@ static bool timeFormatContainsAP(QStringView format) Returns a localized string representation of the given \a time according to the specified \a format. If \a format is an empty string, an empty string is returned. + + \sa QTime::toString() */ QString QLocale::toString(const QTime &time, const QString &format) const { @@ -1852,6 +1858,8 @@ QString QLocale::toString(const QTime &time, const QString &format) const Returns a localized string representation of the given \a time according to the specified \a format. If \a format is an empty string, an empty string is returned. + + \sa QTime::toString() */ QString QLocale::toString(const QTime &time, QStringView format) const { @@ -1865,6 +1873,8 @@ QString QLocale::toString(const QTime &time, QStringView format) const Returns a localized string representation of the given \a dateTime according to the specified \a format. If \a format is an empty string, an empty string is returned. + + \sa QDateTime::toString(), QDate::toString(), QTime::toString() */ QString QLocale::toString(const QDateTime &dateTime, const QString &format) const @@ -1879,6 +1889,8 @@ QString QLocale::toString(const QDateTime &dateTime, const QString &format) cons Returns a localized string representation of the given \a dateTime according to the specified \a format. If \a format is an empty string, an empty string is returned. + + \sa QDateTime::toString(), QDate::toString(), QTime::toString() */ QString QLocale::toString(const QDateTime &dateTime, QStringView format) const { diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc index ed3eb93313..c23e4e3439 100644 --- a/src/corelib/tools/qlocale.qdoc +++ b/src/corelib/tools/qlocale.qdoc @@ -939,6 +939,8 @@ locale doesn't support narrow names, so you should avoid using it for date formatting. Also, for the system locale this format is the same as ShortFormat. + + \sa QDateTime::toString(), QDate::toString(), QTime::toString() */ /*! @@ -1103,6 +1105,8 @@ \value ListToSeparatedString a string that represents a join of a given QStringList with a locale-defined separator. \value NativeLanguageName a string that represents the name of the native language. \value NativeCountryName a string that represents the name of the native country. + + \sa FormatType */ /*! -- cgit v1.2.3 From 6a1c26b08a56cd71315fcbbf2743c32072d806d2 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Mon, 16 Jul 2018 09:45:48 +0200 Subject: Doc: Update signals and slots introduction page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use this as context in connect to functors/lambdas. Add description of the use of context in connects. Update the simple example to make it slightly less confusing for (new) readers. Task-number: QTBUG-69483 Change-Id: Ibbbe98c4282cea4ebd860b1d174871559b7f195b Reviewed-by: Topi Reiniö --- .../doc/src/objectmodel/signalsandslots.qdoc | 48 ++++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc index 6d3064d217..213caa6c59 100644 --- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc +++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc @@ -246,18 +246,20 @@ If you pass the Qt::UniqueConnection \a type, the connection will only be made if it is not a duplicate. If there is already a duplicate (exact same signal to the exact same slot on the same objects), - the connection will fail and connect will return false + the connection will fail and connect will return \c false. This example illustrates that objects can work together without needing to know any information about each other. To enable this, the objects only need to be connected together, and this can be achieved with some simple - QObject::connect() function calls, or with \c{uic}'s - \l{Automatic Connections}{automatic connections} feature. + QObject::connect() function calls, or with \l{User Interface Compiler + (uic)}{uic}'s \l{Automatic Connections}{automatic connections} feature. \section1 A Real Example - Here is a simple commented example of a widget. + The following is an example of the header of a simple widget class without + member functions. The purpose is to show how you can utilize signals and + slots in your own applications. \snippet signalsandslots/lcdnumber.h 0 \snippet signalsandslots/lcdnumber.h 1 @@ -281,19 +283,13 @@ \snippet signalsandslots/lcdnumber.h 6 \snippet signalsandslots/lcdnumber.h 7 - - It's not obviously relevant to the moc, but if you inherit - QWidget you almost certainly want to have the \c parent argument - in your constructor and pass it to the base class's constructor. - - Some destructors and member functions are omitted here; the \c - moc ignores member functions. - + \codeline \snippet signalsandslots/lcdnumber.h 8 \snippet signalsandslots/lcdnumber.h 9 - \c LcdNumber emits a signal when it is asked to show an impossible - value. + After the class constructor and \c public members, we declare the class + \c signals. The \c LcdNumber class emits a signal, \c overflow(), when it + is asked to show an impossible value. If you don't care about overflow, or you know that overflow cannot occur, you can ignore the \c overflow() signal, i.e. don't @@ -325,8 +321,8 @@ callbacks, you'd have to find five different names and keep track of the types yourself. - Some irrelevant member functions have been omitted from this - example. + \sa QLCDNumber, QObject::connect(), {Digital Clock Example}, and + {Tetrix Example}. \section1 Signals And Slots With Default Arguments @@ -361,16 +357,24 @@ You can also connect to functors or C++11 lambdas: \code - connect(sender, &QObject::destroyed, [=](){ this->m_objects.remove(sender); }); + connect(sender, &QObject::destroyed, this, [=](){ this->m_objects.remove(sender); }); \endcode + In both these cases, we provide \a this as context in the call to connect(). + The context object provides information about in which thread the receiver + should be executed. This is important, as providing the context ensures + that the receiver is executed in the context thread. + + The lambda will be disconnected when the sender or context is destroyed. + You should take care that any objects used inside the functor are still + alive when the signal is emitted. + The other way to connect a signal to a slot is to use QObject::connect() and the \c{SIGNAL} and \c{SLOT} macros. - The rule about whether to - include arguments or not in the \c{SIGNAL()} and \c{SLOT()} - macros, if the arguments have default values, is that the - signature passed to the \c{SIGNAL()} macro must \e not have fewer - arguments than the signature passed to the \c{SLOT()} macro. + The rule about whether to include arguments or not in the \c{SIGNAL()} and + \c{SLOT()} macros, if the arguments have default values, is that the + signature passed to the \c{SIGNAL()} macro must \e not have fewer arguments + than the signature passed to the \c{SLOT()} macro. All of these would work: \code -- cgit v1.2.3 From e386cd03d12e401b9e3945602e9621a86009fa11 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Tue, 31 Jul 2018 12:13:25 +0200 Subject: Doc: Remove reference to QTestEvent QTestEventList refers to QTestEvent, which is an implementation detail that should not appear in documentation. Task-number: QTBUG-68109 Change-Id: Id132889427b757ea17165c8b15ed47bcfb9e1c3f Reviewed-by: Mitch Curtis --- src/testlib/qtestevent.qdoc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/testlib/qtestevent.qdoc b/src/testlib/qtestevent.qdoc index a118017107..f0d3bff162 100644 --- a/src/testlib/qtestevent.qdoc +++ b/src/testlib/qtestevent.qdoc @@ -31,12 +31,10 @@ \brief The QTestEventList class provides a list of GUI events. - QTestEventList inherits from QList, and provides - convenience functions for populating the list. - A QTestEventList can be populated with GUI events that can be stored as test data for later usage, or be replayed on any - QWidget. + QWidget. QTestEventList provides convenience functions for populating + the list. Example: \snippet code/doc_src_qtestevent.cpp 0 @@ -174,4 +172,3 @@ \sa QTest::mousePress() */ - -- cgit v1.2.3 From 46fc3d3729df9e81e42f87c46907d6eb81a0c669 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 Jul 2018 09:09:03 +0200 Subject: Windows QPA: Fix override cursor being cleared when crossing window borders Override cursors can be modified externally when for example crossing window borders. Add helper function to enforce the cursor again to QWindowsWindow::applyCursor() which is called for enter events. Task-number: QTBUG-69637 Change-Id: Ibea4da9f2aac81377002b626daae64b1102f6c2b Reviewed-by: Andre de la Rocha Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscursor.cpp | 16 +++++++++++++--- src/plugins/platforms/windows/qwindowscursor.h | 4 +++- src/plugins/platforms/windows/qwindowswindow.cpp | 5 ++++- 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index e1a5837201..72155a1d1b 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -549,6 +549,7 @@ CursorHandlePtr QWindowsCursor::standardWindowCursor(Qt::CursorShape shape) } HCURSOR QWindowsCursor::m_overriddenCursor = nullptr; +HCURSOR QWindowsCursor::m_overrideCursor = nullptr; /*! \brief Return cached pixmap cursor or create new one. @@ -621,11 +622,20 @@ void QWindowsCursor::changeCursor(QCursor *cursorIn, QWindow *window) } } +// QTBUG-69637: Override cursors can get reset externally when moving across +// window borders. Enforce the cursor again (to be called from enter event). +void QWindowsCursor::enforceOverrideCursor() +{ + if (hasOverrideCursor() && m_overrideCursor != GetCursor()) + SetCursor(m_overrideCursor); +} + void QWindowsCursor::setOverrideCursor(const QCursor &cursor) { const CursorHandlePtr wcursor = cursorHandle(cursor); - if (wcursor->handle()) { - const HCURSOR previousCursor = SetCursor(wcursor->handle()); + if (const auto overrideCursor = wcursor->handle()) { + m_overrideCursor = overrideCursor; + const HCURSOR previousCursor = SetCursor(overrideCursor); if (m_overriddenCursor == nullptr) m_overriddenCursor = previousCursor; } else { @@ -638,7 +648,7 @@ void QWindowsCursor::clearOverrideCursor() { if (m_overriddenCursor) { SetCursor(m_overriddenCursor); - m_overriddenCursor = nullptr; + m_overriddenCursor = m_overrideCursor = nullptr; } } diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index 53f185358b..345f47597e 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -107,7 +107,8 @@ public: void changeCursor(QCursor * widgetCursor, QWindow * widget) override; void setOverrideCursor(const QCursor &cursor) override; void clearOverrideCursor() override; - bool hasOverrideCursor() const { return m_overriddenCursor != nullptr; } + static void enforceOverrideCursor(); + static bool hasOverrideCursor() { return m_overriddenCursor != nullptr; } QPoint pos() const override; void setPos(const QPoint &pos) override; @@ -143,6 +144,7 @@ private: mutable QPixmap m_ignoreDragCursor; static HCURSOR m_overriddenCursor; + static HCURSOR m_overrideCursor; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 3909c64c53..aa40d422fb 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2419,8 +2419,11 @@ static inline bool applyNewCursor(const QWindow *w) void QWindowsWindow::applyCursor() { - if (static_cast(screen()->cursor())->hasOverrideCursor()) + if (QWindowsCursor::hasOverrideCursor()) { + if (isTopLevel()) + QWindowsCursor::enforceOverrideCursor(); return; + } #ifndef QT_NO_CURSOR if (m_cursor->isNull()) { // Recurse up to parent with non-null cursor. Set default for toplevel. if (const QWindow *p = window()->parent()) { -- cgit v1.2.3 From d3cbabcc6dd1c0162e01214b25631332566354bd Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Wed, 1 Aug 2018 07:59:45 +0200 Subject: QDeadlineTimer: Fix documentation typo Change-Id: If8f7766ca0698a3defdf9c59c44fb02a8a5b3b62 Reviewed-by: Martin Smith --- src/corelib/kernel/qdeadlinetimer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index 4b9a946dd8..8a5bd5d681 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -224,7 +224,7 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW Constructs a QDeadlineTimer object with a deadline at \a deadline time point, converting from the clock source \c{Clock} to Qt's internal clock - source (see QElapsedTimer::clcokType()). + source (see QElapsedTimer::clockType()). If \a deadline is in the past, this QDeadlineTimer object is set to expired, whereas if \a deadline is equal to \c{Duration::max()}, then this @@ -267,7 +267,7 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW Sets this QDeadlineTimer to the deadline marked by \a deadline time point, converting from the clock source \c{Clock} to Qt's internal clock - source (see QElapsedTimer::clcokType()). + source (see QElapsedTimer::clockType()). If \a deadline is in the past, this QDeadlineTimer object is set to expired, whereas if \a deadline is equal to \c{Duration::max()}, then this -- cgit v1.2.3 From bd7eb131782286d5b41fb1a5b9de0350b4968e3b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 23 Jul 2018 08:25:56 +0200 Subject: Fix conditions for dup2 in QProcess::startDetached The channel pipes are only set up if the channel's type is Redirect. Fix the conditions accordingly. This amends commit 7ad55ca6. Change-Id: Ie8a800fbe2bf9f5f6709b14ba03133b80e9b4bef Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_unix.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index a849519635..713af9bd40 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -949,16 +949,14 @@ bool QProcessPrivate::startDetached(qint64 *pid) qt_safe_close(pidPipe[1]); // copy the stdin socket if asked to (without closing on exec) - if (inputChannelMode != QProcess::ForwardedInputChannel) + if (stdinChannel.type == Channel::Redirect) qt_safe_dup2(stdinChannel.pipe[0], STDIN_FILENO, 0); // copy the stdout and stderr if asked to - if (processChannelMode != QProcess::ForwardedChannels) { - if (processChannelMode != QProcess::ForwardedOutputChannel) - qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO, 0); - if (processChannelMode != QProcess::ForwardedErrorChannel) - qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO, 0); - } + if (stdoutChannel.type == Channel::Redirect) + qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO, 0); + if (stderrChannel.type == Channel::Redirect) + qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO, 0); if (!encodedWorkingDirectory.isEmpty()) { if (QT_CHDIR(encodedWorkingDirectory.constData()) == -1) -- cgit v1.2.3 From 6284d2cd77971e2b10c6d61572b358cf9b3cf897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 5 Jul 2018 15:52:17 +0200 Subject: QWidget: Add note about fixPosIncludesFrame not supporting window states Change-Id: Iee841e7e6552e24f2b62b0c2df5df3c432680eef Reviewed-by: Gatis Paeglis --- src/widgets/kernel/qwidget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 5f1f6d880a..1e249dc191 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7165,6 +7165,12 @@ void QWidget::move(const QPoint &p) // move() was invoked with Qt::WA_WState_Created not set (frame geometry // unknown), that is, crect has a position including the frame. // If we can determine the frame strut, fix that and clear the flag. +// FIXME: This does not play well with window states other than +// Qt::WindowNoState, as we depend on calling setGeometry() on the +// platform window after fixing up the position so that the new +// geometry is reflected in the platform window, but when the frame +// comes in after the window has been shown (e.g. maximized), we're +// not in a position to do that kind of fixup. void QWidgetPrivate::fixPosIncludesFrame() { Q_Q(QWidget); -- cgit v1.2.3 From 6f87926df55edb119e5eeb53c3beac135fdf72e2 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 26 Jul 2018 11:33:33 +0200 Subject: xcb: partly revert 3bc0f1724ae49c2fd7e6d7bcb650350d20d12246 After trying to fix (work around) system resize/move issues in various ways from within the platform plugin, it has been concluded that it is a bug at widget layer and should be fixed there instead: QTBUG-69716. This patch reverts parts of 3bc0f1724a and disables system move / resize on XCB plugin. Meaning, QSizeGrip will use its own implementation for resizing a window. Task-number: QTBUG-68501 Task-number: QTBUG-69628 Change-Id: Ib4744a93fb3e3c20f690a8f43713103856cb7d1a Reviewed-by: Allan Sandfeld Jensen --- src/plugins/platforms/xcb/qxcbconnection.cpp | 3 +- src/plugins/platforms/xcb/qxcbconnection.h | 1 - src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 89 +----------------------- src/plugins/platforms/xcb/qxcbwindow.cpp | 11 +-- 4 files changed, 3 insertions(+), 101 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index dbc53abeca..aca2c347ea 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -1718,8 +1718,7 @@ bool QXcbConnection::compressEvent(xcb_generic_event_t *event, int currentIndex, continue; if (isXIType(next, m_xiOpCode, XI_TouchUpdate)) { xXIDeviceEvent *xiDeviceNextEvent = reinterpret_cast(next); - if (id == xiDeviceNextEvent->detail % INT_MAX && - xiDeviceNextEvent->deviceid == xiDeviceEvent->deviceid) + if (id == xiDeviceNextEvent->detail % INT_MAX) return true; } } diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 98f08e6b2c..9966e06c7b 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -582,7 +582,6 @@ private: bool m_xi2Enabled = false; #if QT_CONFIG(xinput2) - QVector m_floatingSlaveDevices; int m_xi2Minor = -1; void initializeXInput2(); void xi2SetupDevice(void *info, bool removeExisting = true); diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 9a250b875f..6a5248b8f1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -127,7 +127,7 @@ void QXcbConnection::xi2SelectDeviceEvents(xcb_window_t window) XIEventMask mask; mask.mask_len = sizeof(bitMask); mask.mask = xiBitMask; - mask.deviceid = XIAllDevices; + mask.deviceid = XIAllMasterDevices; Display *dpy = static_cast(m_xlib_display); Status result = XISelectEvents(dpy, window, &mask, 1); if (result == Success) @@ -315,7 +315,6 @@ void QXcbConnection::xi2SetupDevices() #endif m_scrollingDevices.clear(); m_touchDevices.clear(); - m_floatingSlaveDevices.clear(); Display *xDisplay = static_cast(m_xlib_display); int deviceCount = 0; @@ -323,10 +322,6 @@ void QXcbConnection::xi2SetupDevices() m_xiMasterPointerIds.clear(); for (int i = 0; i < deviceCount; ++i) { XIDeviceInfo deviceInfo = devices[i]; - if (deviceInfo.use == XIFloatingSlave) { - m_floatingSlaveDevices.append(deviceInfo.deviceid); - continue; - } if (deviceInfo.use == XIMasterPointer) { m_xiMasterPointerIds.append(deviceInfo.deviceid); continue; @@ -555,72 +550,6 @@ static inline qreal fixed1616ToReal(FP1616 val) } #endif // defined(XCB_USE_XINPUT21) || QT_CONFIG(tabletevent) -namespace { - -/*! \internal - - Qt listens for XIAllDevices to avoid losing mouse events. This function - ensures that we don't process the same event twice: from a slave device and - then again from a master device. - - In a normal use case (e.g. mouse press and release inside a window), we will - drop events from master devices as duplicates. Other advantage of processing - events from slave devices is that they don't share button state. All buttons - on a master device share the state. - - Examples of special cases: - - - During system move/resize, window manager (_NET_WM_MOVERESIZE) grabs the - master pointer, in this case we process the matching release from the slave - device. A master device event is not sent by the server, hence no duplicate - event to drop. If we listened for XIAllMasterDevices instead, we would never - see a release event in this case. - - - If we dismiss a context menu by clicking somewhere outside a Qt application, - we will process the mouse press from the master pointer as that is the - device we are grabbing. We are not grabbing slave devices (grabbing on the - slave device is buggy according to 19d289ab1b5bde3e136765e5432b5c7d004df3a4). - And since the event occurs outside our window, the slave device event is - not sent to us by the server, hence no duplicate event to drop. -*/ -bool isDuplicateEvent(xcb_ge_event_t *event) -{ - struct qXIEvent { - bool isValid = false; - uint16_t sourceid; - uint8_t evtype; - uint32_t detail; - int32_t root_x; - int32_t root_y; - }; - static qXIEvent lastSeenEvent; - - bool isDuplicate = false; - auto xiDeviceEvent = reinterpret_cast(event); - if (lastSeenEvent.isValid) { - isDuplicate = lastSeenEvent.sourceid == xiDeviceEvent->sourceid && - lastSeenEvent.evtype == xiDeviceEvent->evtype && - lastSeenEvent.detail == xiDeviceEvent->detail && - lastSeenEvent.root_x == xiDeviceEvent->root_x && - lastSeenEvent.root_y == xiDeviceEvent->root_y; - } else { - lastSeenEvent.isValid = true; - } - lastSeenEvent.sourceid = xiDeviceEvent->sourceid; - lastSeenEvent.evtype = xiDeviceEvent->evtype; - lastSeenEvent.detail = xiDeviceEvent->detail; - lastSeenEvent.root_x = xiDeviceEvent->root_x; - lastSeenEvent.root_y = xiDeviceEvent->root_y; - - if (isDuplicate) - // This sanity check ensures that special cases like QTBUG-59277 keep working. - lastSeenEvent.isValid = false; // An event can be a duplicate only once. - - return isDuplicate; -} - -} // namespace - void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) { xi2PrepareXIGenericDeviceEvent(event); @@ -630,14 +559,10 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) xXIEnterEvent *xiEnterEvent = 0; QXcbWindowEventListener *eventListener = 0; - bool isTouchEvent = true; switch (xiEvent->evtype) { case XI_ButtonPress: case XI_ButtonRelease: case XI_Motion: - isTouchEvent = false; - if (!xi2MouseEventsDisabled() && isDuplicateEvent(event)) - return; #ifdef XCB_USE_XINPUT22 case XI_TouchBegin: case XI_TouchUpdate: @@ -645,18 +570,6 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) #endif { xiDeviceEvent = reinterpret_cast(event); - - if (m_floatingSlaveDevices.contains(xiDeviceEvent->sourceid)) - return; // Not interested in floating slave device events, only in attached slaves. - - bool isSlaveEvent = xiDeviceEvent->deviceid == xiDeviceEvent->sourceid; - if (!xi2MouseEventsDisabled() && isTouchEvent && isSlaveEvent) { - // For touch events we want events only from master devices, at least - // currently there is no apparent reason why we would need to consider - // events from slave devices. - return; - } - eventListener = windowEventListenerFromId(xiDeviceEvent->event); sourceDeviceId = xiDeviceEvent->sourceid; // use the actual device id instead of the master break; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 9b6376f39e..59b06d543e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2632,7 +2632,7 @@ bool QXcbWindow::startSystemMove(const QPoint &pos) bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int corner) { -#if QT_CONFIG(xinput2) + return false; // ### FIXME QTBUG-69716 const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE); if (!connection()->wmSupport()->isSupportedByWM(moveResize)) return false; @@ -2651,10 +2651,6 @@ bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int corner) } else #endif { // Started by mouse press. - if (!connection()->hasXInput2() || connection()->xi2MouseEventsDisabled()) { - // Without XI2 we can't get button press/move/release events. - return false; - } if (connection()->isUnity()) return false; // _NET_WM_MOVERESIZE on this WM is bouncy (WM bug?). @@ -2662,11 +2658,6 @@ bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int corner) } return true; -#else - Q_UNUSED(pos); - Q_UNUSED(corner); - return false; -#endif } void QXcbWindow::doStartSystemMoveResize(const QPoint &globalPos, int corner) { -- cgit v1.2.3 From 843629dd1f4e0521ab9bcc6b3c806a5d90b13613 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 27 Jul 2018 16:55:06 +0200 Subject: Improve documentation of QString::indexOf that take QRegExp They said "By default, this function is case sensitive" but this makes no sense when you're using a regexp for searching, the regexp is case sensitive or not by itself, QStringList does not influence that. Change-Id: I7446cb52a9f915c6551af6046ce89cbc8bab96ed Reviewed-by: Thiago Macieira --- src/corelib/tools/qstringlist.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index c9db39a29f..e9b7397a74 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -611,8 +611,6 @@ static int lastIndexOfMutating(const QStringList *that, QRegExp &rx, int from) the list, searching forward from index position \a from. Returns -1 if no item matched. - By default, this function is case sensitive. - \sa lastIndexOf(), contains(), QRegExp::exactMatch() */ int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegExp &rx, int from) @@ -630,8 +628,6 @@ int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegExp &rx, i the list, searching forward from index position \a from. Returns -1 if no item matched. - By default, this function is case sensitive. - If an item matched, the \a rx regular expression will contain the matched objects (see QRegExp::matchedLength, QRegExp::cap). @@ -650,8 +646,6 @@ int QtPrivate::QStringList_indexOf(const QStringList *that, QRegExp &rx, int fro from is -1 (the default), the search starts at the last item. Returns -1 if no item matched. - By default, this function is case sensitive. - \sa indexOf(), contains(), QRegExp::exactMatch() */ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegExp &rx, int from) @@ -670,8 +664,6 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegExp &r from is -1 (the default), the search starts at the last item. Returns -1 if no item matched. - By default, this function is case sensitive. - If an item matched, the \a rx regular expression will contain the matched objects (see QRegExp::matchedLength, QRegExp::cap). -- cgit v1.2.3 From 4126de887799c61793bf1f9efc8b7ac7b66c8b32 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Jul 2018 13:23:35 -0700 Subject: QCocoaMenuLoader - ensure that ensureAppMenuInMenu indeed, ensures The logic seems to be incorrect (or the naming is misleading): it only adds 'appMenu' if it was found in the previous 'mainMenu', failing otherwise. Consider the following example: while (true){ QApplication app(a,b); MainWindow w; w.show(); app.exec(); } It's quite a contrived but apparently allowed API use (OP claims they have to switch languages in their app). The main window and the app are destroyed, so is the menu bar. Then a new main window is created, with a new menu bar. Now the current [NSApp mainMenu] (the one set after we deleted the previous) does not have 'appMenu' anymore (we removed it when initializing the first menu bar). So as a result we have app menu missing and add new menus/items to a wrong menus/at wrong index. Change-Id: I64fce766d6c12ebf7ae12bb94af41c8c1de3d78b Task-number: QTBUG-69496 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoamenuloader.mm | 33 +++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm index cd597da71c..4432d3e27a 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm @@ -191,26 +191,23 @@ Q_ASSERT(mainMenu); #endif // Grab the app menu out of the current menu. - int numItems = [mainMenu numberOfItems]; - NSMenuItem *oldAppMenuItem = 0; - for (int i = 0; i < numItems; ++i) { - NSMenuItem *item = [mainMenu itemAtIndex:i]; - if ([item submenu] == appMenu) { - oldAppMenuItem = item; - [oldAppMenuItem retain]; - [mainMenu removeItemAtIndex:i]; - break; + auto unparentAppMenu = ^bool (NSMenu *supermenu) { + auto index = [supermenu indexOfItemWithSubmenu:appMenu]; + if (index != -1) { + [supermenu removeItemAtIndex:index]; + return true; } - } + return false; + }; - if (oldAppMenuItem) { - [oldAppMenuItem setSubmenu:nil]; - [oldAppMenuItem release]; - NSMenuItem *appMenuItem = [[NSMenuItem alloc] initWithTitle:@"Apple" - action:nil keyEquivalent:@""]; - [appMenuItem setSubmenu:appMenu]; - [menu insertItem:appMenuItem atIndex:0]; - } + if (!mainMenu || !unparentAppMenu(mainMenu)) + if (appMenu.supermenu) + unparentAppMenu(appMenu.supermenu); + + NSMenuItem *appMenuItem = [[NSMenuItem alloc] initWithTitle:@"Apple" + action:nil keyEquivalent:@""]; + [appMenuItem setSubmenu:appMenu]; + [menu insertItem:appMenuItem atIndex:0]; } - (void)removeActionsFromAppMenu -- cgit v1.2.3 From 2de297f1b76b97146a4ef0a74b996c8fa6154ff8 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Wed, 1 Aug 2018 16:49:29 +0200 Subject: QLabel: Use nullptr in documentation Change-Id: Idc3a5a40e33ddb4257e46d7b6f3279ca14241911 Reviewed-by: Martin Smith --- src/widgets/widgets/qlabel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 947da273dd..5d09e14073 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -189,7 +189,7 @@ QLabelPrivate::~QLabelPrivate() #ifndef QT_NO_PICTURE /*! - Returns the label's picture or 0 if the label doesn't have a + Returns the label's picture or nullptr if the label doesn't have a picture. */ @@ -348,7 +348,7 @@ void QLabel::clear() \property QLabel::pixmap \brief the label's pixmap - If no pixmap has been set this will return 0. + If no pixmap has been set this will return nullptr. Setting the pixmap clears any previous content. The buddy shortcut, if any, is disabled. @@ -1157,7 +1157,7 @@ void QLabelPrivate::updateLabel() Alt+P. To unset a previously set buddy, call this function with \a buddy - set to 0. + set to nullptr. \sa buddy(), setText(), QShortcut, setAlignment() */ @@ -1187,7 +1187,7 @@ void QLabel::setBuddy(QWidget *buddy) /*! - Returns this label's buddy, or 0 if no buddy is currently set. + Returns this label's buddy, or nullptr if no buddy is currently set. \sa setBuddy() */ @@ -1339,7 +1339,7 @@ void QLabelPrivate::clearContents() #if QT_CONFIG(movie) /*! - Returns a pointer to the label's movie, or 0 if no movie has been + Returns a pointer to the label's movie, or nullptr if no movie has been set. \sa setMovie() -- cgit v1.2.3 From c5af04cf8aa7bf2fbeaaf2a40f169fe8c17239f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Thu, 13 Jul 2017 20:02:58 +0200 Subject: HiDPI: Fix calculating window mask from pixmap on drag and drop Use platform window directly for setting a mask to prevent bitmap scaling if pixmap and window DPR are the same. Amends: 42f788ffe26d67864d569c3a3044619d49fc693a Task-number: QTBUG-61948 Change-Id: I5eec85c01f20bdefff7343e83ff10cbcb2c79508 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qshapedpixmapdndwindow.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qshapedpixmapdndwindow.cpp b/src/gui/kernel/qshapedpixmapdndwindow.cpp index b54c6b67a2..8509eb0961 100644 --- a/src/gui/kernel/qshapedpixmapdndwindow.cpp +++ b/src/gui/kernel/qshapedpixmapdndwindow.cpp @@ -39,6 +39,8 @@ #include "qshapedpixmapdndwindow_p.h" +#include "qplatformwindow.h" + #include #include #include @@ -70,7 +72,12 @@ void QShapedPixmapWindow::setPixmap(const QPixmap &pixmap) if (!mask.isNull()) { if (!handle()) create(); - setMask(mask); + if (auto platformWindow = handle()) { + const auto pixmapDpr = m_pixmap.devicePixelRatio(); + const auto winDpr = devicePixelRatio(); + const auto maskSize = (QSizeF(m_pixmap.size()) * winDpr / pixmapDpr).toSize(); + platformWindow->setMask(QBitmap(mask.scaled(maskSize))); + } } } } -- cgit v1.2.3 From db738cbaf1ba7a4886f7869db16dbb9107a8e65e Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Thu, 12 Jul 2018 10:55:33 +0200 Subject: QCommonStylePrivate::viewItemSize: Fix text width bounds calculation The width of the icon was subtracted out of the available text area width even when the value of the `decorationPosition` was Top/Bottom. Task-number: QTBUG-69404 Task-number: QTBUG-30116 Change-Id: I501ffc0dab0cff25e525c26adf9bdb060408927b Reviewed-by: Christian Ehrlicher Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qcommonstyle.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 7420bfb3f7..3b9186e61a 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -879,9 +879,16 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int QRect bounds = option->rect; switch (option->decorationPosition) { case QStyleOptionViewItem::Left: - case QStyleOptionViewItem::Right: - bounds.setWidth(wrapText && bounds.isValid() ? bounds.width() - 2 * textMargin : QFIXED_MAX); + case QStyleOptionViewItem::Right: { + if (wrapText && bounds.isValid()) { + int width = bounds.width() - 2 * textMargin; + if (option->features & QStyleOptionViewItem::HasDecoration) + width -= option->decorationSize.width() + 2 * textMargin; + bounds.setWidth(width); + } else + bounds.setWidth(QFIXED_MAX); break; + } case QStyleOptionViewItem::Top: case QStyleOptionViewItem::Bottom: if (wrapText) @@ -893,12 +900,8 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int break; } - if (wrapText) { - if (option->features & QStyleOptionViewItem::HasCheckIndicator) - bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth) - 2 * textMargin); - if (option->features & QStyleOptionViewItem::HasDecoration) - bounds.setWidth(bounds.width() - option->decorationSize.width() - 2 * textMargin); - } + if (wrapText && option->features & QStyleOptionViewItem::HasCheckIndicator) + bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth) - 2 * textMargin); const int lineWidth = bounds.width(); const QSizeF size = viewItemTextLayout(textLayout, lineWidth); -- cgit v1.2.3 From 81910b5f3cfb8c8b0c009913d62dacff4e73bc3b Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 2 Aug 2018 16:18:00 +0200 Subject: SecureTransport - disable lock on sleep for the custom keychain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It appears that by default our keychain auto-locks when the system sleeps. This makes the keychain totally useless, since its password is a random 256 bytes our user never has a chance to know. Thanks to Mårten for the hint about SecKeychainSetSettings, the way to properly fix it. Task-number: QTBUG-69677 Change-Id: I2603c26b8422a1bcace3336e9b4ebe0381c952d7 Reviewed-by: Edward Welbourne Reviewed-by: Mårten Nordheim --- src/network/ssl/qsslsocket_mac.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 046b432252..aa0e1b0dd1 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -60,6 +60,7 @@ #include #include +#include #include #include @@ -144,6 +145,16 @@ EphemeralSecKeychain::EphemeralSecKeychain() } } + if (keychain) { + SecKeychainSettings settings = {}; + settings.version = SEC_KEYCHAIN_SETTINGS_VERS1; + // Strange, huh? But that's what their docs say to do! With lockOnSleep + // == false, set interval to INT_MAX to never lock ... + settings.lockInterval = INT_MAX; + if (SecKeychainSetSettings(keychain, &settings) != errSecSuccess) + qCWarning(lcSsl) << "SecKeychainSettings: failed to disable lock on sleep"; + } + #ifdef QSSLSOCKET_DEBUG if (keychain) { qCDebug(lcSsl) << "Custom keychain with name" << keychainName << "was created" -- cgit v1.2.3 From 8c4207dddf9b2af0767de2ef0a10652612d462a5 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 2 Aug 2018 13:11:20 +0200 Subject: Fix crash in qppmhandler for certain malformed image files The ppm format specifies that the maximum color value field must be less than 65536. The handler did not enforce this, leading to potentional overflow when the value was used in 16 bits context. Task-number: QTBUG-69449 Change-Id: Iea7a7e0f8953ec1ea8571e215687d12a9d77e11c Reviewed-by: Lars Knoll --- src/gui/image/qppmhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index e9f5a905f0..53e3fa293d 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -115,7 +115,7 @@ static bool read_pbm_header(QIODevice *device, char& type, int& w, int& h, int& else mcc = read_pbm_int(device); // get max color component - if (w <= 0 || w > 32767 || h <= 0 || h > 32767 || mcc <= 0) + if (w <= 0 || w > 32767 || h <= 0 || h > 32767 || mcc <= 0 || mcc > 0xffff) return false; // weird P.M image return true; -- cgit v1.2.3 From f0ff73f631093b11c77d8d6fb548acfe8eb62583 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 19 Jul 2018 13:05:52 +0200 Subject: QProcess::startDetached: Fix behavior change on Windows Do not overwrite stdout/stderr by default, but only if requested. This restores the behavior of QProcess::startDetached of Qt 5.9. Task-number: QTBUG-67905 Change-Id: Idccf7b0da7bd80f88a0624286ddf2851bc974fb1 Reviewed-by: Friedemann Kleint --- src/corelib/io/qprocess.cpp | 4 ++++ src/corelib/io/qprocess_win.cpp | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 2ee680a7c6..890867cd51 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -2147,6 +2147,10 @@ void QProcess::start(OpenMode mode) \endlist All other properties of the QProcess object are ignored. + \note The called process inherits the console window of the calling + process. To suppress console output, redirect standard/error output to + QProcess::nullDevice(). + \sa start() \sa startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index b1ec2c560c..8c4e5b41b4 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -874,6 +874,11 @@ static bool startDetachedUacPrompt(const QString &programIn, const QStringList & return true; } +static Q_PIPE pipeOrStdHandle(Q_PIPE pipe, DWORD handleNumber) +{ + return pipe != INVALID_Q_PIPE ? pipe : GetStdHandle(handleNumber); +} + bool QProcessPrivate::startDetached(qint64 *pid) { static const DWORD errorElevationRequired = 740; @@ -906,15 +911,14 @@ bool QProcessPrivate::startDetached(qint64 *pid) 0, 0, 0, STARTF_USESTDHANDLES, 0, 0, 0, - stdinChannel.pipe[0], stdoutChannel.pipe[1], stderrChannel.pipe[1] + pipeOrStdHandle(stdinChannel.pipe[0], STD_INPUT_HANDLE), + pipeOrStdHandle(stdoutChannel.pipe[1], STD_OUTPUT_HANDLE), + pipeOrStdHandle(stderrChannel.pipe[1], STD_ERROR_HANDLE) }; - const bool inheritHandles = stdinChannel.type == Channel::Redirect - || stdoutChannel.type == Channel::Redirect - || stderrChannel.type == Channel::Redirect; QProcess::CreateProcessArguments cpargs = { nullptr, reinterpret_cast(const_cast(args.utf16())), - nullptr, nullptr, inheritHandles, dwCreationFlags, envPtr, + nullptr, nullptr, true, dwCreationFlags, envPtr, workingDirectory.isEmpty() ? nullptr : reinterpret_cast(workingDirectory.utf16()), &startupInfo, &pinfo -- cgit v1.2.3 From 66be5445e64b54bf60069dfee5dd918459e3deed Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 1 Aug 2018 12:59:42 +0200 Subject: Windows: Implement Qt::WindowStaysOnBottomHint Set the Z-order to HWND_BOTTOM in that case. Add a doc note stating that it only works for frameless or full screen windows. Task-number: QTBUG-53717 Change-Id: I7abf219a88aac715c51d27d925504da9e91b56f1 Reviewed-by: Paul Wicking Reviewed-by: Andre de la Rocha Reviewed-by: Oliver Wolff --- src/corelib/global/qnamespace.qdoc | 8 ++++++-- src/plugins/platforms/windows/qwindowswindow.cpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 36f2aaee72..8e46f3f0fd 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2271,13 +2271,17 @@ correctly. \value WindowStaysOnBottomHint Informs the window system that the - window should stay on bottom of all other windows. Note - that on X11 this hint will work only in window managers + window should stay on bottom of all other windows. + + \note On X11, this hint will work only in window managers that support _NET_WM_STATE_BELOW atom. If a window always on the bottom has a parent, the parent will also be left on the bottom. This window hint is currently not implemented for \macos. + \note On Windows, this will work only for frameless or + full-screen windows. + \value WindowTransparentForInput Informs the window system that this window is used only for output (displaying something) and does not take input. Therefore input events should pass through as if it wasn't there. diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index aa40d422fb..ca87f1b6a4 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2081,6 +2081,8 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow * HWND desktopHWND = GetDesktopWindow(); platformWindow->m_data.embedded = !parentWindow && parentHWND && (parentHWND != desktopHWND); } + if (qWindow->flags().testFlag(Qt::WindowStaysOnBottomHint)) + windowPos->hwndInsertAfter = HWND_BOTTOM; } if (!qWindow->isTopLevel()) // Implement hasHeightForWidth(). return false; -- cgit v1.2.3 From 1c8f9eb79da837db8e37cf6348de459088c3a20e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 2 Aug 2018 18:05:51 +0200 Subject: Add missing optimization for loading RGB32 to RGBA64 using NEON The rest of the RGB64 routines were optimized, but the loading of RGB32 was not as it was originally not used much, but with ARGB32 using the RGB64 backend, it is essential for decent performance. Task-number: QTBUG-69724 Change-Id: I1c02411ed29d3d993427afde44dfa83689d117e0 Reviewed-by: Lars Knoll --- src/gui/painting/qdrawhelper.cpp | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 34847daf55..9bb1498ff0 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -618,6 +618,53 @@ static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint * *buffer++ = QRgba64::fromArgb32(s); } } +#elif defined(__ARM_NEON__) +template +static inline void qConvertARGB32PMToRGBA64PM_neon(QRgba64 *buffer, const uint *src, int count) +{ + if (count <= 0) + return; + + const uint32x4_t amask = vdupq_n_u32(0xff000000); +#if defined(Q_PROCESSOR_ARM_64) + const uint8x16_t rgbaMask = { 2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15}; +#else + const uint8x8_t rgbaMask = { 2, 1, 0, 3, 6, 5, 4, 7 }; +#endif + int i = 0; + for (; i < count-3; i += 4) { + uint32x4_t vs32 = vld1q_u32(src); + src += 4; + if (maskAlpha) + vs32 = vorrq_u32(vs32, amask); + uint8x16_t vs8 = vreinterpretq_u8_u32(vs32); + if (!RGBA) { +#if defined(Q_PROCESSOR_ARM_64) + vs8 = vqtbl1q_u8(vs8, rgbaMask); +#else + // no vqtbl1q_u8 + const uint8x8_t vlo = vtbl1_u8(vget_low_u8(vs8), rgbaMask); + const uint8x8_t vhi = vtbl1_u8(vget_high_u8(vs8), rgbaMask); + vs8 = vcombine_u8(vlo, vhi); +#endif + } + uint8x16x2_t v = vzipq_u8(vs8, vs8); + + vst1q_u16((uint16_t *)buffer, vreinterpretq_u16_u8(v.val[0])); + buffer += 2; + vst1q_u16((uint16_t *)buffer, vreinterpretq_u16_u8(v.val[1])); + buffer += 2; + } + + SIMD_EPILOGUE(i, count, 3) { + uint s = *src++; + if (maskAlpha) + s = s | 0xff000000; + if (RGBA) + s = RGBA2ARGB(s); + *buffer++ = QRgba64::fromArgb32(s); + } +} #endif static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uint *src, int count, @@ -625,6 +672,8 @@ static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uin { #ifdef __SSE2__ qConvertARGB32PMToARGB64PM_sse2(buffer, src, count); +#elif defined(__ARM_NEON__) + qConvertARGB32PMToRGBA64PM_neon(buffer, src, count); #else for (int i = 0; i < count; ++i) buffer[i] = QRgba64::fromArgb32(0xff000000 | src[i]); @@ -639,6 +688,10 @@ static const QRgba64 *QT_FASTCALL convertARGB32ToARGB64PM(QRgba64 *buffer, const qConvertARGB32PMToARGB64PM_sse2(buffer, src, count); for (int i = 0; i < count; ++i) buffer[i] = buffer[i].premultiplied(); +#elif defined(__ARM_NEON__) + qConvertARGB32PMToRGBA64PM_neon(buffer, src, count); + for (int i = 0; i < count; ++i) + buffer[i] = buffer[i].premultiplied(); #else for (int i = 0; i < count; ++i) buffer[i] = QRgba64::fromArgb32(src[i]).premultiplied(); @@ -651,6 +704,8 @@ static const QRgba64 *QT_FASTCALL convertARGB32PMToARGB64PM(QRgba64 *buffer, con { #ifdef __SSE2__ qConvertARGB32PMToARGB64PM_sse2(buffer, src, count); +#elif defined(__ARM_NEON__) + qConvertARGB32PMToRGBA64PM_neon(buffer, src, count); #else for (int i = 0; i < count; ++i) buffer[i] = QRgba64::fromArgb32(src[i]); @@ -665,6 +720,10 @@ static const QRgba64 *QT_FASTCALL convertRGBA8888ToARGB64PM(QRgba64 *buffer, con qConvertARGB32PMToARGB64PM_sse2(buffer, src, count); for (int i = 0; i < count; ++i) buffer[i] = buffer[i].premultiplied(); +#elif defined(__ARM_NEON__) + qConvertARGB32PMToRGBA64PM_neon(buffer, src, count); + for (int i = 0; i < count; ++i) + buffer[i] = buffer[i].premultiplied(); #else for (int i = 0; i < count; ++i) buffer[i] = QRgba64::fromArgb32(RGBA2ARGB(src[i])).premultiplied(); @@ -677,6 +736,8 @@ static const QRgba64 *QT_FASTCALL convertRGBA8888PMToARGB64PM(QRgba64 *buffer, c { #ifdef __SSE2__ qConvertARGB32PMToARGB64PM_sse2(buffer, src, count); +#elif defined(__ARM_NEON__) + qConvertARGB32PMToRGBA64PM_neon(buffer, src, count); #else for (int i = 0; i < count; ++i) buffer[i] = QRgba64::fromArgb32(RGBA2ARGB(src[i])); -- cgit v1.2.3 From d2d59e77d5e16bc79ddfed37f4f29d1dcd9b92a7 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Fri, 3 Aug 2018 10:49:03 +0200 Subject: Doc: Increase precision in description of convenience typedefs Task-number: QTBUG-53856 Change-Id: I57917bb311d1d93e0903f2b3e021cc4db0f0d05e Reviewed-by: Nico Vertriest --- src/corelib/global/qglobal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index f60e47928c..a6990b88f4 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -589,7 +589,7 @@ Q_STATIC_ASSERT((std::is_same::value)); {long long int } (\c __int64 on Windows). Several convenience type definitions are declared: \l qreal for \c - double, \l uchar for \c unsigned char, \l uint for \c unsigned + double or \c float, \l uchar for \c unsigned char, \l uint for \c unsigned int, \l ulong for \c unsigned long and \l ushort for \c unsigned short. -- cgit v1.2.3 From cdf154e65a3137597f62880361c407e368aae0d6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 2 Aug 2018 16:34:43 +0200 Subject: Optimize blits of any compatible formats The fast image blending is only used for SourceOver composition, but several of our embedded backends make heavy use of Source composition which doesn't have a short-cut. This patch adds a blitting short cut that works in those cases. Task-number: QTBUG-69724 Change-Id: Icc61a67cc27bc83863153d69cae60dd986d26f69 Reviewed-by: Lars Knoll --- src/gui/painting/qpaintengine_raster.cpp | 119 ++++++++++++++++++++++++++++++- src/gui/painting/qpaintengine_raster_p.h | 3 + 2 files changed, 120 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 6336b2943e..cade334ea6 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1056,6 +1056,77 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt, alpha); } +void QRasterPaintEnginePrivate::blitImage(const QPointF &pt, + const QImage &img, + const QRect &clip, + const QRect &sr) +{ + if (!clip.isValid()) + return; + + Q_ASSERT(img.depth() >= 8); + + qsizetype srcBPL = img.bytesPerLine(); + const uchar *srcBits = img.bits(); + int srcSize = img.depth() >> 3; // This is the part that is incompatible with lower than 8-bit.. + int iw = img.width(); + int ih = img.height(); + + if (!sr.isEmpty()) { + iw = sr.width(); + ih = sr.height(); + // Adjust the image according to the source offset... + srcBits += ((sr.y() * srcBPL) + sr.x() * srcSize); + } + + // adapt the x parameters + int x = qRound(pt.x()); + int cx1 = clip.x(); + int cx2 = clip.x() + clip.width(); + if (x < cx1) { + int d = cx1 - x; + srcBits += srcSize * d; + iw -= d; + x = cx1; + } + if (x + iw > cx2) { + int d = x + iw - cx2; + iw -= d; + } + if (iw <= 0) + return; + + // adapt the y paremeters... + int cy1 = clip.y(); + int cy2 = clip.y() + clip.height(); + int y = qRound(pt.y()); + if (y < cy1) { + int d = cy1 - y; + srcBits += srcBPL * d; + ih -= d; + y = cy1; + } + if (y + ih > cy2) { + int d = y + ih - cy2; + ih -= d; + } + if (ih <= 0) + return; + + // blit.. + int dstSize = rasterBuffer->bytesPerPixel(); + qsizetype dstBPL = rasterBuffer->bytesPerLine(); + const uint *src = (const uint *) srcBits; + uint *dst = reinterpret_cast(rasterBuffer->buffer() + x * dstSize + y * dstBPL); + + const int len = iw * (qt_depthForFormat(rasterBuffer->format) >> 3); + for (int y = 0; y < ih; ++y) { + memcpy(dst, src, len); + dst = (quint32 *)(((uchar *) dst) + dstBPL); + src = (const quint32 *)(((const uchar *) src) + srcBPL); + } +} + void QRasterPaintEnginePrivate::systemStateChanged() { @@ -2160,7 +2231,15 @@ void QRasterPaintEngine::drawImage(const QPointF &p, const QImage &img) const QClipData *clip = d->clip(); QPointF pt(p.x() + s->matrix.dx(), p.y() + s->matrix.dy()); - if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) { + if (d->canUseImageBlitting(d->rasterBuffer->compositionMode, img)) { + if (!clip) { + d->blitImage(pt, img, d->deviceRect); + return; + } else if (clip->hasRectClip) { + d->blitImage(pt, img, clip->clipRect); + return; + } + } else if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) { SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()]; if (func) { if (!clip) { @@ -2445,7 +2524,16 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe fillPath(path, &d->image_filler_xform); s->matrix = m; } else { - if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) { + if (d->canUseImageBlitting(d->rasterBuffer->compositionMode, img)) { + QPointF pt(r.x() + s->matrix.dx(), r.y() + s->matrix.dy()); + if (!clip) { + d->blitImage(pt, img, d->deviceRect, sr.toRect()); + return; + } else if (clip->hasRectClip) { + d->blitImage(pt, img, clip->clipRect, sr.toRect()); + return; + } + } else if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) { SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()]; if (func) { QPointF pt(r.x() + s->matrix.dx(), r.y() + s->matrix.dy()); @@ -3665,6 +3753,33 @@ bool QRasterPaintEnginePrivate::canUseFastImageBlending(QPainter::CompositionMod && !image.hasAlphaChannel())); } +bool QRasterPaintEnginePrivate::canUseImageBlitting(QPainter::CompositionMode mode, const QImage &image) const +{ + Q_Q(const QRasterPaintEngine); + const QRasterPaintEngineState *s = q->state(); + + if (!s->flags.fast_images || s->intOpacity != 256 || qt_depthForFormat(rasterBuffer->format) < 8) + return false; + + QImage::Format dFormat = rasterBuffer->format; + QImage::Format sFormat = image.format(); + // Formats must match or source format must be a subset of destination format + if (dFormat != sFormat && image.pixelFormat().alphaUsage() == QPixelFormat::IgnoresAlpha) { + if ((sFormat == QImage::Format_RGB32 && dFormat == QImage::Format_ARGB32) + || (sFormat == QImage::Format_RGBX8888 && dFormat == QImage::Format_RGBA8888)) + sFormat = dFormat; + else + sFormat = qt_maybeAlphaVersionWithSameDepth(sFormat); // this returns premul formats + } + if (dFormat != sFormat) + return false; + + return s->matrix.type() <= QTransform::TxTranslate + && (mode == QPainter::CompositionMode_Source + || (mode == QPainter::CompositionMode_SourceOver + && !image.hasAlphaChannel())); +} + QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color) { Q_ASSERT(image.depth() == 1); diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 8c6f668d9d..14eddf07b1 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -291,6 +291,8 @@ public: void drawImage(const QPointF &pt, const QImage &img, SrcOverBlendFunc func, const QRect &clip, int alpha, const QRect &sr = QRect()); + void blitImage(const QPointF &pt, const QImage &img, + const QRect &clip, const QRect &sr = QRect()); QTransform brushMatrix() const { Q_Q(const QRasterPaintEngine); @@ -313,6 +315,7 @@ public: void recalculateFastImages(); bool canUseFastImageBlending(QPainter::CompositionMode mode, const QImage &image) const; + bool canUseImageBlitting(QPainter::CompositionMode mode, const QImage &image) const; QPaintDevice *device; QScopedPointer outlineMapper; -- cgit v1.2.3 From 65cd6f2e8271d070cd89da49d0993863e8836558 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 3 Aug 2018 11:31:42 +0200 Subject: Fix conversion from transparent indexed8 to RGB32 A typo meant the color-table was not fixed. For safety fallback colors are also made opaque. Change-Id: I3e609882177604910c4343c86f00221a89af9078 Reviewed-by: Eirik Aavitsland --- src/gui/image/qimage_conversions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 1b4d3e63dd..d981c43711 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -1194,7 +1194,7 @@ static QVector fix_color_table(const QVector &ctbl, QImage::Format f if (format == QImage::Format_RGB32) { // check if the color table has alpha for (int i = 0; i < colorTable.size(); ++i) - if (qAlpha(colorTable.at(i) != 0xff)) + if (qAlpha(colorTable.at(i)) != 0xff) colorTable[i] = colorTable.at(i) | 0xff000000; } else if (format == QImage::Format_ARGB32_Premultiplied) { // check if the color table has alpha @@ -1796,8 +1796,9 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt: if (colorTable.size() < 256) { int tableSize = colorTable.size(); colorTable.resize(256); + QRgb fallbackColor = (dest->format == QImage::Format_RGB32) ? 0xff000000 : 0; for (int i=tableSize; i<256; ++i) - colorTable[i] = 0; + colorTable[i] = fallbackColor; } int w = src->width; -- cgit v1.2.3 From ae289884db05cbaac71156983974eebfb9b59730 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Fri, 3 Aug 2018 14:09:52 +0200 Subject: Doc: Fix wrong link in QFont documentation Task-number: QTBUG-62072 Change-Id: I587534fc5723b3d198fe2065fbcf1bee4871a768 Reviewed-by: Mitch Curtis --- src/gui/text/qfont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index c7fff266ad..f7462b65c8 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1254,7 +1254,7 @@ QFont::StyleStrategy QFont::styleStrategy() const /*! Returns the StyleHint. - The style hint affects the \l{QFont}{font matching} algorithm. + The style hint affects the \l{#fontmatching}{font matching algorithm}. See \l QFont::StyleHint for the list of available hints. \sa setStyleHint(), QFont::StyleStrategy, QFontInfo::styleHint() -- cgit v1.2.3 From 6953e513f9034b98a48d83b67afd671f1ee33aeb Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Fri, 3 Aug 2018 13:47:48 +0200 Subject: Doc: Clean up Qt::ApplicationAttribute docs * Remove () from links to QGuiApplication link names. The link targets QGuiApplication, and the syntax Q(Gui)Application to suggest both QGuiApplication and QApplication seems unnecessary, as QApplication derives from QGuiApplication anyway. * Move added in version line to the bottom of each entry that contains said line for consistency. * "was added in" > "has been added in" Task-number: QTBUG-56077 Change-Id: Ife93acb7936ff9f0d3af2f2f456ad0db95419797 Reviewed-by: Nico Vertriest --- src/corelib/global/qnamespace.qdoc | 68 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 8e46f3f0fd..d6191d1585 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -116,8 +116,8 @@ \value AA_DontShowShortcutsInContextMenus Actions with the Shortcut property won't be shown in any shortcut menus unless specifically set by the - QAction::shortcutVisibleInContextMenu property. This value has - been added in Qt 5.10. + QAction::shortcutVisibleInContextMenu property. This value was added + in Qt 5.10. \value AA_NativeWindows Ensures that widgets have native windows. @@ -132,9 +132,8 @@ menu and not taking possession of the native menu bar. Setting this attribute to true will also set the AA_DontUseNativeMenuBar attribute to true. It also disables native event filters. - This attribute has been added in Qt 5.7. It must be set before - \l {QGuiApplication}{Q\(Gui\)Application} is constructed. - + This attribute must be set before QGuiApplication constructed. + This value was added in Qt 5.7. \value AA_DontUseNativeMenuBar All menubars created while this attribute is set to true won't be used as a native menubar (e.g, the menubar at @@ -174,14 +173,14 @@ \value AA_UseDesktopOpenGL Forces the usage of desktop OpenGL (for example, \e opengl32.dll or \e libGL.so) on platforms that use dynamic loading - of the OpenGL implementation. This value has been added in Qt 5.3. - This attribute must be set before \l {QGuiApplication} - {Q\(Gui\)Application} is constructed. + of the OpenGL implementation. This attribute must be set before + QGuiApplication is constructed. + This value was added in Qt 5.3. \value AA_UseOpenGLES Forces the usage of OpenGL ES 2.0 or higher on platforms that use dynamic loading of the OpenGL implementation. - This value has been added in Qt 5.3. This attribute must be set - before \l {QGuiApplication}{Q\(Gui\)Application} is constructed. + This attribute must be set before QGuiApplication is constructed. + This value was added in Qt 5.3. \value AA_UseSoftwareOpenGL Forces the usage of a software based OpenGL implementation on platforms that use dynamic loading of the OpenGL @@ -191,29 +190,28 @@ implementation is available. The default name of this library is \c opengl32sw.dll and can be overridden by setting the environment variable \e QT_OPENGL_DLL. See the platform-specific pages, for - instance \l{Qt for Windows}, for more information. This value has - been added in Qt 5.4. This attribute must be set before - \l {QGuiApplication}{Q\(Gui\)Application} is constructed. + instance \l{Qt for Windows}, for more information. This attribute + must be set before QGuiApplication is constructed. + This value was added in Qt 5.4. \value AA_ShareOpenGLContexts Enables resource sharing between the OpenGL contexts used by classes like QOpenGLWidget and QQuickWidget. This allows sharing OpenGL resources, like textures, between QOpenGLWidget - instances that belong to different top-level windows. This value has - been added in Qt 5.4. This attribute must be set before - \l {QGuiApplication}{Q\(Gui\)Application} is constructed. + instances that belong to different top-level windows. This attribute + must be set before QGuiApplication is constructed. + This value was added in Qt 5.4. \value AA_SetPalette Indicates whether a palette was explicitly set on the - \l {QGuiApplication}{Q\(Gui\)Application}. This value has been added - in Qt 5.5. + QGuiApplication. This value was added in Qt 5.5. \value AA_EnableHighDpiScaling Enables high-DPI scaling in Qt on supported platforms (see also \l{High DPI Displays}). Supported platforms are X11, Windows and Android. Enabling makes Qt scale the main (device independent) coordinate system according to display scale factors provided by the operating system. This corresponds to setting the - QT_AUTO_SCREEN\unicode{0x200b}_SCALE_FACTOR environment variable to 1. This value - has been added in Qt 5.6. This attribute must be set before - Q(Gui)Application is constructed. + QT_AUTO_SCREEN\unicode{0x200b}_SCALE_FACTOR environment variable to + 1. This attribute must be set before QGuiApplication is constructed. + This value was added in Qt 5.6. \value AA_DisableHighDpiScaling Disables high-DPI scaling in Qt, exposing window system coordinates. Note that the window system may do its own scaling, @@ -221,24 +219,26 @@ be equal to 1. In addition, scale factors set by QT_SCALE_FACTOR will not be affected. This corresponds to setting the QT_AUTO_SCREEN\unicode{0x200b}_SCALE_FACTOR environment variable to 0. - This value has been added in Qt 5.6. This - attribute must be set before Q(Gui)Application is constructed. + This attribute must be set before QGuiApplication is constructed. + This value was added in Qt 5.6. \value AA_UseStyleSheetPropagationInWidgetStyles By default, Qt Style Sheets disable regular QWidget palette and font propagation. When this flag is enabled, font and palette changes propagate as though the user had manually called the corresponding QWidget methods. See \l{The Style Sheet Syntax#Inheritance}{The Style Sheet Syntax - Inheritance} - for more details. This value has been added in Qt 5.7. + for more details. + This value was added in Qt 5.7. \value AA_DontUseNativeDialogs All dialogs created while this attribute is set to true won't use the native dialogs provided by the platform. - This value has been added in Qt 5.7. + This value was added in Qt 5.7. \value AA_SynthesizeMouseForUnhandledTabletEvents All tablet events that are not accepted by the application will be translated to mouse events instead. This attribute is enabled - by default. This value has been added in Qt 5.7. + by default. + This value was added in Qt 5.7. \value AA_CompressHighFrequencyEvents Enables compression of certain frequent events. On the X11 windowing system, the default value is true, which means that @@ -251,19 +251,21 @@ If your application needs to handle all events with no compression, you can unset this attribute. Notice that input events from tablet devices will not be compressed. See AA_CompressTabletEvents if you want these to be - compressed as well. This value has been added in Qt 5.7. + compressed as well. + This value was added in Qt 5.7. \value AA_CompressTabletEvents Enables compression of input events from tablet devices. Notice that AA_CompressHighFrequencyEvents must be true for events compression to be enabled, and that this flag extends the former to tablet events. Its default - value is false. This value has been added in Qt 5.10. + value is false. + This value was added in Qt 5.10. \value AA_DontCheckOpenGLContextThreadAffinity When making a context current using QOpenGLContext, do not check that the \l{QObject#Thread Affinity}{QObject thread affinity} of the QOpenGLContext object is the same thread calling - \l{QOpenGLContext::makeCurrent}{makeCurrent()}. This value has been - added in Qt 5.8. + \l{QOpenGLContext::makeCurrent}{makeCurrent()}. + This value was added in Qt 5.8. \value AA_DisableShaderDiskCache Disables caching of shader program binaries on disk. By default Qt Quick, QPainter's OpenGL backend, and any @@ -277,7 +279,7 @@ \value AA_DisableWindowContextHelpButton Disables the WindowContextHelpButtonHint by default on Qt::Sheet and Qt::Dialog widgets. This hides the \gui ? button on Windows, which only makes sense if you use \l QWhatsThis functionality. - This value has been added in Qt 5.10. For Qt 6, WindowContextHelpButtonHint + This value was added in Qt 5.10. In Qt 6, WindowContextHelpButtonHint will not be set by default. The following values are deprecated or obsolete: @@ -2651,7 +2653,7 @@ but \b{must} not return an empty string unless the cursor is at the end of the document. \value ImEnterKeyType The Enter key type. \value ImAnchorRectangle The bounding rectangle of the selection anchor. - This value has been added in Qt 5.7. + This value was added in Qt 5.7. \value ImInputItemClipRectangle The actual exposed input item rectangle. Parts of the input item might be clipped. This value will take clipping into consideration and return the actual painted item rectangle. The rectangle is in widget coordinates. @@ -2779,7 +2781,7 @@ \value ItemNeverHasChildren The item never has child items. This is used for optimization purposes only. \value ItemIsUserTristate The user can cycle through three separate states. - This value has been added in Qt 5.5. + This value was added in Qt 5.5. Note that checkable items need to be given both a suitable set of flags and an initial state, indicating whether the item is checked or not. -- cgit v1.2.3 From c6cca0f492717582cb113f3d62e97f554798cf14 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Fri, 3 Aug 2018 14:44:08 +0200 Subject: Doc: Update out-of-date image in QColorDialog documentation Task-number: QTBUG-58420 Change-Id: Ib5c7a3f681b082182cf6ec9aa62028b7040e81bf Reviewed-by: Martin Smith --- src/widgets/doc/images/fusion-colordialog.png | Bin 21518 -> 27155 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'src') diff --git a/src/widgets/doc/images/fusion-colordialog.png b/src/widgets/doc/images/fusion-colordialog.png index 011319e9c8..aacdb7a727 100644 Binary files a/src/widgets/doc/images/fusion-colordialog.png and b/src/widgets/doc/images/fusion-colordialog.png differ -- cgit v1.2.3 From 4c223502787f604fc8e726b0f9006c868810c08d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 30 Jul 2018 10:19:00 -0700 Subject: Remove the src/sql/README.module file It's stale. Thanks to Olivier B. for pointing out. Change-Id: Ie01831ddac5446fdbdeefffd15463530818cff9e Reviewed-by: Martin Smith Reviewed-by: Oswald Buddenhagen --- src/sql/README.module | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/sql/README.module (limited to 'src') diff --git a/src/sql/README.module b/src/sql/README.module deleted file mode 100644 index 511d90e83f..0000000000 --- a/src/sql/README.module +++ /dev/null @@ -1,37 +0,0 @@ -Before building the Qt library, the Qt SQL module can be enabled for -specific databases using 'configure'. 'configure' is located at the -top of your QTDIR. - -Specific databases drivers can be enabled using one of the following -options: - - ./configure [-qt-sql-] [-plugin-sql-] - -or disabled using the following option: - - ./configure [-no-sql-] - -Where is the name of the driver, for example 'psql'. This -will configure the Qt library to compile the specified driver into -the Qt lib itself. - -For example, to build the PostgreSQL driver directly into the Qt -library, configure Qt like this: - - ./configure -qt-sql-psql - -In addition, you may need to specify an extra include path, as some -database drivers require headers for the database they are using, -for example: - - ./configure -qt-sql-psql -I/usr/local/include - -If instead you need to build the PostgreSQL driver as a dynamically -loaded plugin, configure Qt like this: - - ./configure -plugin-sql-psql - -To compile drivers as dynamically loaded plugins, see the -QTDIR/plugins/src/sqldrivers directory. Use 'configure -help' -for a complete list of configure options. See the Qt documentation -for a complete list of supported database drivers. -- cgit v1.2.3 From 64a560d977a0a511ef541d6116d82e7b5c911a92 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 3 Aug 2018 17:55:11 -0700 Subject: QObject: do allow setProperty() to change the type of the property [ChangeLog][QtCore][QObject] Fixed a bug in setProperty() that caused a property change not to take effect if the old value compared equal using QVariant's equality operator, but the values were not strictly equal. Task-number: QTBUG-69744 Change-Id: I00e04a465fcf4fc1a462fffd1547885861a07a64 Reviewed-by: Simon Hausmann Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qobject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 566f75a6c3..c6fe787e03 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3898,7 +3898,8 @@ bool QObject::setProperty(const char *name, const QVariant &value) d->extraData->propertyNames.append(name); d->extraData->propertyValues.append(value); } else { - if (value == d->extraData->propertyValues.at(idx)) + if (value.userType() == d->extraData->propertyValues.at(idx).userType() + && value == d->extraData->propertyValues.at(idx)) return false; d->extraData->propertyValues[idx] = value; } -- cgit v1.2.3 From 2841e2b61e32f26900bde987d469c8b97ea31999 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 3 Aug 2018 13:25:15 +0200 Subject: Check for QImage allocation failure in qgifhandler Since image files easily can be (or corrupt files claim to be) huge, it is worth checking for out of memory situations. Change-Id: I635a3ec6852288079fdec4e14cf7e776fe59e9e0 Reviewed-by: Lars Knoll --- src/plugins/imageformats/gif/qgifhandler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index e0f7f44701..ebe5964664 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -354,7 +354,8 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, (*image) = QImage(swidth, sheight, format); bpl = image->bytesPerLine(); bits = image->bits(); - memset(bits, 0, image->sizeInBytes()); + if (bits) + memset(bits, 0, image->sizeInBytes()); } // Check if the previous attempt to create the image failed. If it @@ -415,6 +416,10 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, backingstore = QImage(qMax(backingstore.width(), w), qMax(backingstore.height(), h), QImage::Format_RGB32); + if (backingstore.isNull()) { + state = Error; + return -1; + } memset(backingstore.bits(), 0, backingstore.sizeInBytes()); } const int dest_bpl = backingstore.bytesPerLine(); -- cgit v1.2.3 From 5d1809be83c667fc72f58b84d95fbe3e37451350 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Sun, 5 Aug 2018 14:12:37 +0200 Subject: QString: Fix documentation for toDouble() and toFloat() The character 'g' is only a valid format when converting numbers to strings, but not other way round. Change-Id: Ie772886e7a45a5067c0a3e4eaa3a6ccef8e69426 Reviewed-by: Martin Smith --- src/corelib/tools/qstring.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index bb5a1cf852..82a065efc0 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -7177,7 +7177,7 @@ ushort QString::toUShort(bool *ok, int base) const \snippet qstring/main.cpp 66 \warning The QString content may only contain valid numerical characters - which includes the plus/minus sign, the characters g and e used in scientific + which includes the plus/minus sign, the character e used in scientific notation, and the decimal point. Including the unit or additional characters leads to a conversion error. @@ -7213,7 +7213,7 @@ double QString::toDouble(bool *ok) const to \c false, and success by setting *\a{ok} to \c true. \warning The QString content may only contain valid numerical characters - which includes the plus/minus sign, the characters g and e used in scientific + which includes the plus/minus sign, the character e used in scientific notation, and the decimal point. Including the unit or additional characters leads to a conversion error. -- cgit v1.2.3 From f271dd8f960ad9f61697dfa57b26c4071441cadc Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Mon, 6 Aug 2018 15:27:21 +0200 Subject: Windows QPA: Fix UIA-to-MSAA accessibility bridge According to MS sample code, MSAA requests should be replied with UI Automation providers to enable the use the UIA-to-MSAA bridge, in order to support MSAA-only clients. Also changing the mapping of QAccessible::Client from UIA_CustomControlTypeId to UIA_GroupControlTypeId, as it seems more appropriate and avoids an incorrect mapping to a push button type in the UIA-to-MSAA conversion. Change-Id: I5149d250da2d1bd7b14b44ca46e856a81c9be045 Reviewed-by: Friedemann Kleint --- .../uiautomation/qwindowsuiaaccessibility.cpp | 27 ++++++++++------------ .../windows/uiautomation/qwindowsuiautils.cpp | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp index 907883bf5b..0f0f42fafe 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp @@ -68,21 +68,18 @@ QWindowsUiaAccessibility::~QWindowsUiaAccessibility() // Handles UI Automation window messages. bool QWindowsUiaAccessibility::handleWmGetObject(HWND hwnd, WPARAM wParam, LPARAM lParam, LRESULT *lResult) { - if (lParam == LPARAM(UiaRootObjectId)) { - - // Start handling accessibility internally - QGuiApplicationPrivate::platformIntegration()->accessibility()->setActive(true); - - // Ignoring all requests while starting up / shutting down - if (QCoreApplication::startingUp() || QCoreApplication::closingDown()) - return false; - - if (QWindow *window = QWindowsContext::instance()->findWindow(hwnd)) { - if (QAccessibleInterface *accessible = window->accessibleRoot()) { - QWindowsUiaMainProvider *provider = QWindowsUiaMainProvider::providerForAccessible(accessible); - *lResult = QWindowsUiaWrapper::instance()->returnRawElementProvider(hwnd, wParam, lParam, provider); - return true; - } + // Start handling accessibility internally + QGuiApplicationPrivate::platformIntegration()->accessibility()->setActive(true); + + // Ignoring all requests while starting up / shutting down + if (QCoreApplication::startingUp() || QCoreApplication::closingDown()) + return false; + + if (QWindow *window = QWindowsContext::instance()->findWindow(hwnd)) { + if (QAccessibleInterface *accessible = window->accessibleRoot()) { + QWindowsUiaMainProvider *provider = QWindowsUiaMainProvider::providerForAccessible(accessible); + *lResult = QWindowsUiaWrapper::instance()->returnRawElementProvider(hwnd, wParam, lParam, provider); + return true; } } return false; diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp index 89e5075dcb..f777a59ce9 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiautils.cpp @@ -149,7 +149,7 @@ long roleToControlTypeId(QAccessible::Role role) {QAccessible::Caret, UIA_CustomControlTypeId}, {QAccessible::AlertMessage, UIA_CustomControlTypeId}, {QAccessible::Window, UIA_WindowControlTypeId}, - {QAccessible::Client, UIA_CustomControlTypeId}, + {QAccessible::Client, UIA_GroupControlTypeId}, {QAccessible::PopupMenu, UIA_MenuControlTypeId}, {QAccessible::MenuItem, UIA_MenuItemControlTypeId}, {QAccessible::ToolTip, UIA_ToolTipControlTypeId}, -- cgit v1.2.3