From 5d7e221bbf9e27e90448243909abc76d81733381 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 29 Mar 2019 12:49:47 -0700 Subject: [PATCH 01/16] QRandomGenerator: assert that bounded() calls have correct arguments Otherwise, the math will fail badly. Documentation improved to reflect reality. Change-Id: I9e3d261ad9bf41cfb2b6fffd159085cd38e3c388 Reviewed-by: Thiago Macieira --- src/corelib/global/qrandom.cpp | 16 ++++++++++++---- src/corelib/global/qrandom.h | 12 +++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 90df8653a73..bf01b7ae2a0 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -903,6 +903,10 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \snippet code/src_corelib_global_qrandom.cpp 12 + If the \a highest parameter is negative, the result will be negative too; + if it is infinite or NaN, the result will be infinite or NaN too (that is, + not random). + \sa generateDouble(), bounded() */ @@ -934,7 +938,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \overload Generates one random 32-bit quantity in the range between 0 (inclusive) and - \a highest (exclusive). \a highest must not be negative. + \a highest (exclusive). \a highest must be positive. Note that this function cannot be used to obtain values in the full 32-bit range of int. Instead, use generate() and cast to int. @@ -946,8 +950,11 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \fn quint32 QRandomGenerator::bounded(quint32 lowest, quint32 highest) \overload - Generates one random 32-bit quantity in the range between \a lowest (inclusive) - and \a highest (exclusive). The same result may also be obtained by using + Generates one random 32-bit quantity in the range between \a lowest + (inclusive) and \a highest (exclusive). The \a highest parameter must be + greater than \a lowest. + + The same result may also be obtained by using \l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{\c std::uniform_int_distribution} with parameters \a lowest and \c{\a highest - 1}. That class can also be used to obtain quantities larger than 32 bits. @@ -968,7 +975,8 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \overload Generates one random 32-bit quantity in the range between \a lowest - (inclusive) and \a highest (exclusive), both of which may be negative. + (inclusive) and \a highest (exclusive), both of which may be negative, but + \a highest must be greater than \a lowest. Note that this function cannot be used to obtain values in the full 32-bit range of int. Instead, use generate() and cast to int. diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 46d3e0e1526..260fc1501a4 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -122,16 +122,18 @@ public: return quint32(value); } - int bounded(int highest) - { - return int(bounded(quint32(highest))); - } - quint32 bounded(quint32 lowest, quint32 highest) { + Q_ASSERT(highest > lowest); return bounded(highest - lowest) + lowest; } + int bounded(int highest) + { + Q_ASSERT(highest > 0); + return int(bounded(0U, quint32(highest))); + } + int bounded(int lowest, int highest) { return bounded(highest - lowest) + lowest; From cafcab52638ed1f6f70db32345fff838eac67cae Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 1 Jul 2019 16:01:19 +0200 Subject: [PATCH 02/16] Bump version Change-Id: Ic4a8c031d1de3dd887fb6f135035ccb2ec9a37b3 --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 888bd8f66e0..4db9fecac82 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ CONFIG += warning_clean QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.12.4 +MODULE_VERSION = 5.12.5 From 1df2cdda6c9559cd20af245b41731e287f6214c7 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 1 Jul 2019 16:34:58 +0200 Subject: [PATCH 03/16] Bump version Change-Id: Ieb9a694d44503789664a6098c4fb14eb940337fe --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index c92e38c48fb..a4cd16555dc 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ CONFIG += warning_clean QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.13.0 +MODULE_VERSION = 5.13.1 From cee5a11bdba94fbeb48de8cffa08cfa3e85423c8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 1 Jul 2019 14:36:43 +0200 Subject: [PATCH 04/16] Fix directory separator of QMAKE_INCDIR_VULKAN Like in Qt code itself we should use forward slashes consistently. This enables the vulkan test to run on Linux for MinGW cross-compilation. Task-number: QTBUG-76660 Change-Id: Ifc6dec11bac3c3769d5d06e49da529f66f7b5843 Reviewed-by: Kai Koehne --- mkspecs/features/win32/windows_vulkan_sdk.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/win32/windows_vulkan_sdk.prf b/mkspecs/features/win32/windows_vulkan_sdk.prf index 6c08e28fe91..2aebbd3b256 100644 --- a/mkspecs/features/win32/windows_vulkan_sdk.prf +++ b/mkspecs/features/win32/windows_vulkan_sdk.prf @@ -1,7 +1,7 @@ isEmpty(QMAKE_INCDIR_VULKAN) { # Pick up the VULKAN_SDK env var set by the LunarG SDK so that the Vulkan # headers are found out-of-the-box on typical Windows setups. - QMAKE_INCDIR_VULKAN = $$(VULKAN_SDK)\\include + QMAKE_INCDIR_VULKAN = $$(VULKAN_SDK)/include # Do not export the include dir but resolve it on every qmake call. QMAKE_EXPORT_INCDIR_VULKAN = - From 5e0a45e932424c5ed661ae518ca21d2ab627db2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 21 Jun 2019 13:02:34 +0200 Subject: [PATCH 05/16] QSocks5SocketEngine: pass data to application when connected If we end up in the connected state then we should pass on any remaining data immediately instead of waiting until the next time we get a read notification. The other `case`s in the switch might be able to do something similar, but I don't want to introduce that logic now in case it breaks something else, the Connected branch is small and simple to deal with. Should severely reduce flakiness with socks proxy in CI under pressure. Task-number: QTBUG-76367 Change-Id: I0965d4c62a29a25ce6b8dd60862a464279aef0b4 Reviewed-by: Timur Pocheptsov Reviewed-by: Ryan Chu --- src/network/socket/qsocks5socketengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 6791b85273b..d2328f85363 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1188,6 +1188,8 @@ void QSocks5SocketEnginePrivate::_q_controlSocketReadNotification() break; case RequestMethodSent: parseRequestMethodReply(); + if (socks5State == Connected && data->controlSocket->bytesAvailable()) + _q_controlSocketReadNotification(); break; case Connected: { QByteArray buf; From 1eeab2d27f61485cb53364d40339a8d832a076e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 24 Jun 2019 18:55:36 +0200 Subject: [PATCH 06/16] QSocks5SocketEngine: account for in-transit signal when waiting for read When calling waitFor{ReadyRead,Disconnected} it will wait for data but if the data is already received and the read notification has been queued (and there's no more data coming in) it will return false. By checking if a read notification has been queued and then handling this we can easily take care of this scenario. Fixes some flaky tests which missed the read data in waitForDisconnect and similar. Fixes: QTBUG-38385 Change-Id: Ic05d59883c1175783e56ff1822b6636c35aec874 Reviewed-by: Volker Hilsheimer --- src/network/socket/qsocks5socketengine.cpp | 5 +++++ tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index d2328f85363..e7e4d64c322 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1753,6 +1753,11 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) return false; if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) return true; + if (bytesAvailable() && d->readNotificationPending) { + // We've got some data incoming, but the queued call hasn't been performed yet. + // The data is where we expect it to be already, so just return true. + return true; + } // we're connected if (d->mode == QSocks5SocketEnginePrivate::ConnectMode || diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index c473230246b..2d64714f922 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -328,8 +328,8 @@ void tst_QTcpSocket::initTestCase_data() qDebug() << QtNetworkSettings::serverName(); QTest::newRow("WithoutProxy") << false << 0 << false; - //QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; ### temporarily disabled, QTBUG-38385 - //QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; ### temporarily disabled, QTBUG-38385 + QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; + QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; QTest::newRow("WithHttpProxy") << true << int(HttpProxy) << false; QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic) << false; @@ -337,8 +337,8 @@ void tst_QTcpSocket::initTestCase_data() #ifndef QT_NO_SSL QTest::newRow("WithoutProxy SSL") << false << 0 << true; - //QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; ### temporarily disabled, QTBUG-38385 - //QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; ### temporarily disabled, QTBUG-38385 + QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; + QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; QTest::newRow("WithHttpProxy SSL") << true << int(HttpProxy) << true; QTest::newRow("WithHttpProxyBasicAuth SSL") << true << int(HttpProxy | AuthBasic) << true; From 555661b625c40f21a6a3e4c73e928a6e8a46db20 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 21 Jun 2019 16:31:04 +0200 Subject: [PATCH 07/16] Update visible window's alpha when toggling WA_TranslucentBackground MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWidgetPrivate::updateIsTranslucent sets the surface format of the window with the alpha based on the translucency attribute, so we need to call this function when the attribute value changes. The test can confirm that the window's requested surface format has changed, we can't rely on what is actually set, and don't have to rely on hard-coded values like 8bit alpha. While WA_NoSystemBackground needs to be set for WA_TranslucentBackground to have an effect, we can't clear the attribute when clearing translucency (as it might have been set explicitly). Change-Id: I238d6930b7e0488397467a4e035b5f530566a1ff Fixes: QTBUG-60822 Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 5 ++--- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6ef3a4f1633..50745175b4e 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -11474,10 +11474,9 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } break; case Qt::WA_TranslucentBackground: - if (on) { + if (on) setAttribute(Qt::WA_NoSystemBackground); - d->updateIsTranslucent(); - } + d->updateIsTranslucent(); break; case Qt::WA_AcceptTouchEvents: diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 489edb703c0..7edca2017de 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -8855,6 +8855,12 @@ void tst_QWidget::translucentWidget() QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(actual.size(),expected.size()); QCOMPARE(actual,expected); + + const QWindow *window = label.windowHandle(); + const QSurfaceFormat translucentFormat = window->requestedFormat(); + label.setAttribute(Qt::WA_TranslucentBackground, false); + const QSurfaceFormat opaqueFormat = window->requestedFormat(); + QVERIFY(translucentFormat != opaqueFormat); } class MaskResizeTestWidget : public QWidget From 24b9424adcda1ab083fae4ae857007227ba5fee2 Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Tue, 2 Jul 2019 14:24:25 +0200 Subject: [PATCH 08/16] Skip flaky test on MacOS_10_12 This is the most flaky-pass test currently. It fails the first time it is run on MacOS_10_12, but succeeds all the following times. This happens extremely often, so disable it until the issue is resolved. Task-number: QTBUG-76566 Change-Id: I94359eceb91c3b958930424e6c8b5957fb3f1252 Reviewed-by: Volker Hilsheimer --- .../graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 9a75774927d..ae0d91dfe3f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -5049,6 +5049,12 @@ public: void tst_QGraphicsItem::paint() { +#if defined(Q_OS_MACOS) + if (QSysInfo::productVersion() == QLatin1String("10.12")) { + QSKIP("Test is very flaky on MacOS_10_12, see QTBUG-76566"); + } +#endif + QGraphicsScene scene; PaintTester paintTester; From 833519f2debf963ec198760475ba26319303d0e0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 2 Jul 2019 13:20:03 +0200 Subject: [PATCH 09/16] Fix compiler warnings when building with DEBUG defines set Change-Id: I51fc7aae246916e585b21b4e7da1fc5a4ac392fd Reviewed-by: Timur Pocheptsov --- .../socket/qnativesocketengine_win.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index c999bd2088f..986b0b48619 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -608,13 +608,13 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() socketType = qt_socket_getType(socketDescriptor); #if defined (QNATIVESOCKETENGINE_DEBUG) - QString socketProtocolStr = "UnknownProtocol"; - if (socketProtocol == QAbstractSocket::IPv4Protocol) socketProtocolStr = "IPv4Protocol"; - else if (socketProtocol == QAbstractSocket::IPv6Protocol) socketProtocolStr = "IPv6Protocol"; + QString socketProtocolStr = QStringLiteral("UnknownProtocol"); + if (socketProtocol == QAbstractSocket::IPv4Protocol) socketProtocolStr = QStringLiteral("IPv4Protocol"); + else if (socketProtocol == QAbstractSocket::IPv6Protocol) socketProtocolStr = QStringLiteral("IPv6Protocol"); - QString socketTypeStr = "UnknownSocketType"; - if (socketType == QAbstractSocket::TcpSocket) socketTypeStr = "TcpSocket"; - else if (socketType == QAbstractSocket::UdpSocket) socketTypeStr = "UdpSocket"; + QString socketTypeStr = QStringLiteral("UnknownSocketType"); + if (socketType == QAbstractSocket::TcpSocket) socketTypeStr = QStringLiteral("TcpSocket"); + else if (socketType == QAbstractSocket::UdpSocket) socketTypeStr = QStringLiteral("UdpSocket"); qDebug("QNativeSocketEnginePrivate::fetchConnectionParameters() localAddress == %s, localPort = %i, peerAddress == %s, peerPort = %i, socketProtocol == %s, socketType == %s", localAddress.toString().toLatin1().constData(), localPort, peerAddress.toString().toLatin1().constData(), peerPort, socketProtocolStr.toLatin1().constData(), socketTypeStr.toLatin1().constData()); #endif @@ -1487,8 +1487,8 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len) } #if defined (QNATIVESOCKETENGINE_DEBUG) - qDebug("QNativeSocketEnginePrivate::nativeWrite(%p \"%s\", %li) == %li", - data, qt_prettyDebug(data, qMin((int)ret, 16), (int)ret).data(), (int)len, (int)ret); + qDebug("QNativeSocketEnginePrivate::nativeWrite(%p \"%s\", %lli) == %lli", + data, qt_prettyDebug(data, qMin(int(ret), 16), int(ret)).data(), len, ret); #endif return ret; @@ -1530,11 +1530,11 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxLength) #if defined (QNATIVESOCKETENGINE_DEBUG) if (ret != -2) { - qDebug("QNativeSocketEnginePrivate::nativeRead(%p \"%s\", %li) == %li", - data, qt_prettyDebug(data, qMin((int)bytesRead, 16), (int)bytesRead).data(), (int)maxLength, (int)ret); + qDebug("QNativeSocketEnginePrivate::nativeRead(%p \"%s\", %lli) == %lli", + data, qt_prettyDebug(data, qMin(int(bytesRead), 16), int(bytesRead)).data(), maxLength, ret); } else { - qDebug("QNativeSocketEnginePrivate::nativeRead(%p, %li) == -2 (WOULD BLOCK)", - data, int(maxLength)); + qDebug("QNativeSocketEnginePrivate::nativeRead(%p, %lli) == -2 (WOULD BLOCK)", + data, maxLength); } #endif From 2021b36ebdbdd1da1595f281a694b54beb1b23a3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 2 Jul 2019 20:48:40 -0300 Subject: [PATCH 10/16] QPluginLoader: fix failing test comparing the Qt version We stopped storing the patch release number of Qt in the plugin metadata in commit 7bd79b3cffbbbece23867c5e111a3dd2ebcad016 (5.13), to make it simpler to parse the validity of plugins before decoding the CBOR payload. Fixes: QTBUG-76855 Change-Id: I6aed4df6a12e43c3ac8efffd15adbbf83e928866 Reviewed-by: Liang Qi --- tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 4316ea14ea6..85763b03885 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -549,7 +549,8 @@ void tst_QPluginLoader::staticPlugins() } QVERIFY(found); - QCOMPARE(metaData.value("version").toInt(), QT_VERSION); + // We don't store the patch release version anymore (since 5.13) + QCOMPARE(metaData.value("version").toInt() / 0x100, QT_VERSION / 0x100); QCOMPARE(metaData.value("IID").toString(), "SomeIID"); QCOMPARE(metaData.value("ExtraMetaData"), QJsonArray({ "StaticPlugin", "foo" })); } From fb353592261e04896ad417ce5ace8adda1fe9fdf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 1 Jul 2019 10:30:14 +0200 Subject: [PATCH 11/16] [docs] Fix issues in QRect/QMargin API docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix grammar in op-(QRect, QMargin) - Correct shunk for grown in op-(QRectF, QMarginsF) Change-Id: Ia0dbd933cc9f6ed5e0dad05a27794c1135c794ed Reviewed-by: Mårten Nordheim --- src/corelib/tools/qrect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 6e51deebea0..c8301e25908 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -1194,7 +1194,7 @@ bool QRect::intersects(const QRect &r) const Q_DECL_NOTHROW \fn QRect operator-(const QRect &lhs, const QMargins &rhs) \relates QRect - Returns the \a lhs rectangle shrunken by the \a rhs margins. + Returns the \a lhs rectangle shrunk by the \a rhs margins. \since 5.3 */ @@ -2417,7 +2417,7 @@ QRect QRectF::toAlignedRect() const Q_DECL_NOTHROW \relates QRectF \since 5.3 - Returns the \a lhs rectangle grown by the \a rhs margins. + Returns the \a lhs rectangle shrunk by the \a rhs margins. */ /*! From 8d414e67941fdc45ab682b763a119ecc71291483 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 15:32:50 +0200 Subject: [PATCH 12/16] Mark QObject::deleteLater() as \threadsafe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because it is. It's just QCoreApplication::postEvent(), which is thread-safe. It also _has_ to be, because we recommend to use deleteLater() to delete QObjects that live in another thread: Quoting the ~QObject() docs: > Warning: Deleting a QObject while pending events are waiting to be delivered > can cause a crash. You must not delete the QObject directly if it exists in > a different thread than the one currently executing. Use deleteLater() > instead, which will cause the event loop to delete the object after all > pending events have been delivered to it. If deleteLater() is not thread-safe, it cannot be used for one of its intended purposes. Change-Id: I333d506b42bdfcdff00fe6cefa234c21865625a6 Reviewed-by: Mårten Nordheim --- src/corelib/kernel/qobject.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 68c5460b6a8..d685eaf27f2 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2163,6 +2163,8 @@ void QObject::removeEventFilter(QObject *obj) */ /*! + \threadsafe + Schedules this object for deletion. The object will be deleted when control returns to the event From 6ff0614b61b8645ec7ca4ea40501a0b6719a92fd Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 20 Jun 2019 13:07:04 +0200 Subject: [PATCH 13/16] Handle multiple font-families in face attribute This seems to be a common use case, and to be expected from pastes of MSWord documents. Change-Id: I5849d7f51408e76f15a0b03c2118649f118af1d6 Fixes: QTBUG-66794 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/text/qtexthtmlparser.cpp | 11 ++++++++- .../text/qtextdocument/tst_qtextdocument.cpp | 24 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 895232e4c70..929db40e5da 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1505,7 +1505,16 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) n -= 3; node->charFormat.setProperty(QTextFormat::FontSizeAdjustment, n); } else if (key == QLatin1String("face")) { - node->charFormat.setFontFamily(value); + if (value.contains(QLatin1Char(','))) { + const QStringList values = value.split(QLatin1Char(',')); + QStringList families; + for (const QString &family : values) + families << family.trimmed(); + node->charFormat.setFontFamilies(families); + node->charFormat.setFontFamily(families.at(0)); + } else { + node->charFormat.setFontFamily(value); + } } else if (key == QLatin1String("color")) { QColor c; c.setNamedColor(value); if (!c.isValid()) diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index e4ee778f64f..591fafc7fb3 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -188,6 +188,9 @@ private slots: void lineHeightType(); void cssLineHeightMultiplier(); + + void fontTagFace(); + private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); @@ -3498,5 +3501,26 @@ void tst_QTextDocument::cssLineHeightMultiplier() } } +void tst_QTextDocument::fontTagFace() +{ + { + QTextDocument td; + td.setHtml("Foobar"); + QTextFragment fragment = td.begin().begin().fragment(); + QTextCharFormat format = fragment.charFormat(); + QCOMPARE(format.fontFamily(), QLatin1String("Times")); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextFragment fragment = td.begin().begin().fragment(); + QTextCharFormat format = fragment.charFormat(); + QCOMPARE(format.fontFamily(), QLatin1String("Times")); + QStringList expectedFamilies = { QLatin1String("Times"), QLatin1String("serif") }; + QCOMPARE(format.fontFamilies().toStringList(), expectedFamilies); + } +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" From 0f92f2f35d55f2de545e8472c6b240c8fd0bb53f Mon Sep 17 00:00:00 2001 From: Felix Barz Date: Sun, 30 Jun 2019 20:43:03 +0200 Subject: [PATCH 14/16] Add custom verb support for WASM HTTP requests The QNetworkReply implementation for Qt for WebAssembly now supports usage of the QNetworkAccessManager::sendCustomRequest, making it possible to send requests with custom verbs. [ChangeLog][QtNetwork][QNetworkAccessManager] Fixed QNetworkAccessManager::sendCustomRequest for Qt For WebAssembly. Fixes: QTBUG-76775 Change-Id: I9394ffef110fce4ed2c877893631bedc7631f71e Reviewed-by: Lorn Potter --- src/network/access/qnetworkreplywasmimpl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index 9f6422a107f..ee91dc20b33 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -236,6 +236,7 @@ QNetworkReplyWasmImpl::~QNetworkReplyWasmImpl() QByteArray QNetworkReplyWasmImpl::methodName() const { + const Q_D( QNetworkReplyWasmImpl); switch (operation()) { case QNetworkAccessManager::HeadOperation: return "HEAD"; @@ -247,6 +248,8 @@ QByteArray QNetworkReplyWasmImpl::methodName() const return "POST"; case QNetworkAccessManager::DeleteOperation: return "DELETE"; + case QNetworkAccessManager::CustomOperation: + return d->request.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray(); default: break; } From 78d67d17a6c108a419816b8bd47f78864ddbb07f Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 19 Jun 2019 17:43:19 +0200 Subject: [PATCH 15/16] CMake: Fix prl and library names on macOS for debug configurations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The paths to the libraries and prl files should have the "_debug" suffix for the debug configuration. This prefix is added to the TARGET when by qt_module.prf when doing a debug build, but not during a debug_and_release build. Make sure to strip the _debug suffix if it's there, and re-add it later always, to be consistent in both debug_and_release builds and in debug builds. Amends a12b6e7bf6688021c6af809d024958b59dfa3555. Task-number: QTBUG-38913 Task-number: QTBUG-75520 Change-Id: I29e88f2b991e2be06b23652d64edc768fa35a5ae Reviewed-by: Jörg Bornemann --- mkspecs/features/create_cmake.prf | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index c9910dda53d..00da9bd33f1 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -34,10 +34,20 @@ CMAKE_INCLUDE_NAME = $$eval(QT.$${MODULE}.name) # TARGET here is the one changed at the end of qt_module.prf, # which already contains the Qt5 prefix and QT_LIBINFIX suffix : -# Qt5Core_suffix, Qt5Network_suffix, Foo_suffix -# (or QtCore_suffix, Foo_suffix on macos with -framework) +# Qt5Core_{libinfix_suffix}, Qt5Network_{libinfix_suffix}, Foo_{libinfix_suffix} +# (or QtCore_{libinfix_suffix}, Foo_{libinfix_suffix} on macos with -framework). CMAKE_QT_STEM = $${TARGET} +# On macOS when building just a debug configuration which is not part of debug_and_release, +# $${TARGET} already contains a _debug suffix, as per the following call chain: +# qt_module.prf -> qt5LibraryTarget -> qtLibraryTarget -> qtPlatformTargetSuffix. +# Remove the _debug suffix in the stem, to keep all further uses of CMAKE_QT_STEM consistent. +# The _debug suffix is then re-added where needed regardless if it's a debug_and_release build +# or just debug. +darwin:!qt_framework:!debug_and_release:CONFIG(debug, debug|release) { + CMAKE_QT_STEM = $$replace(CMAKE_QT_STEM, _debug$, ) +} + !generated_privates { isEmpty(SYNCQT.INJECTED_PRIVATE_HEADER_FILES):isEmpty(SYNCQT.PRIVATE_HEADER_FILES): \ CMAKE_NO_PRIVATE_INCLUDES = true @@ -211,18 +221,18 @@ CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";") mac { !isEmpty(CMAKE_STATIC_TYPE) { - CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.a + CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a - CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.prl + CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.prl CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl } else { qt_framework { - CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM} + CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM}_debug CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM} CMAKE_BUILD_IS_FRAMEWORK = "true" } else { - CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib + CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.$$eval(QT.$${MODULE}.VERSION).dylib CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib } } From 6ad08b9cad4efefc72e64deaa0b720a3aab0fa54 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 20 Jun 2019 11:46:49 +0200 Subject: [PATCH 16/16] CMake: Fix handling of static dependencies that have spaces in path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The absolute paths of certain static dependencies can have spaces in them. The _qt5_$${CMAKE_MODULE_NAME}_process_prl_file fails to handle this, and simply replaces all spaces with semicolons, which obviously breaks the list of dependencies, and a consuming application fails to link with a message like: LINK : fatal error LNK1181: cannot open input file 'C:\Program.obj' This change partially restores the functionality that was added in 102e1822ffcdc9954d3c698f863734a8083e349c specifically the part that changes qmake to export an additional variable QMAKE_PRL_LIBS_FOR_CMAKE. This variable has the same content as QMAKE_PRL_LIBS except it uses a semicolon as a separator, so that CMake can correctly parse the separate lib entries. This is much cleaner than trying to parse the original QMAKE_PRL_LIBS variable with a complicated regular expression. Amends eda28621f6c1a68774719f382be53ec109123b18. Task-number: QTBUG-38913 Change-Id: I1d18fb779606505bc92320d8ce13232c7022e212 Reviewed-by: Jörg Bornemann --- mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in | 13 ++++++++++--- qmake/generators/makefile.cpp | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index 705e0a3c933..ba7d9575c0d 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -56,9 +56,16 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura get_filename_component(_qt5_install_libs \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib\" ABSOLUTE) if(EXISTS \"${prl_file_location}\") - file(STRINGS \"${prl_file_location}\" _prl_strings REGEX \"QMAKE_PRL_LIBS[ \\t]*=\") - string(REGEX REPLACE \"QMAKE_PRL_LIBS[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends ${_prl_strings}) - string(REGEX REPLACE \"[ \\t]+\" \";\" _static_depends ${_static_depends}) + file(STRINGS \"${prl_file_location}\" _prl_strings REGEX \"QMAKE_PRL_LIBS_FOR_CMAKE[ \\t]*=\") + + # file(STRINGS) replaces all semicolons read from the file with backslash semicolons. + # We need to do a reverse transformation in CMake. For that we replace all backslash + # semicolons with just semicolons, but due to the qmake substitution feature + # creating this file, we need to double the amount of backslashes, so the final file + # should have three backslashes and one semicolon. + string(REGEX REPLACE \"\\\\\\;\" \";\" _prl_strings \"${_prl_strings}\") + + string(REGEX REPLACE \"QMAKE_PRL_LIBS_FOR_CMAKE[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends \"${_prl_strings}\") string(REGEX REPLACE \"[ \\t]+\" \";\" _standard_libraries \"${CMAKE_CXX_STANDARD_LIBRARIES}\") set(_search_paths) string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\") diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 956deba25bb..a963c381789 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1023,6 +1023,14 @@ MakefileGenerator::writePrlFile(QTextStream &t) for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it) t << qv(project->values((*it).toKey())); t << endl; + + t << "QMAKE_PRL_LIBS_FOR_CMAKE = "; + QString sep; + for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it) { + t << sep << project->values((*it).toKey()).join(';').replace('\\', "\\\\"); + sep = ';'; + } + t << endl; } }