From 295a16b0d3836a8f41b5133bcd9f355afb03f38b Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 3 Mar 2020 11:16:58 +0100 Subject: [PATCH 01/38] Don't use deprecated QPixmapCache::find overload Silence compile time warning and show correct usage in example snippet. Change-Id: I1936f006e4b5f3ca71bbc0100ed039beeb459271 Reviewed-by: Paul Wicking --- src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp | 3 +-- src/widgets/styles/qcommonstyle.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp b/src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp index 3870237ac36..9043ee6361f 100644 --- a/src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp +++ b/src/gui/doc/snippets/code/src_gui_image_qpixmapcache.cpp @@ -49,9 +49,8 @@ ****************************************************************************/ //! [0] -QPixmap* pp; QPixmap p; -if ((pp=QPixmapCache::find("my_big_image", pm))) { +if (QPixmap *pp = QPixmapCache::find("my_big_image"))) { p = *pp; } else { p.load("bigimage.png"); diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 4b0094e578c..45ac6712b47 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -6125,7 +6125,7 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size.width()); if (standardIcon >= QStyle::SP_CustomBase) { mainIcon = theme->standardPixmap(sp, QSizeF(size)); - } else if (QPixmapCache::find(cacheKey, mainIcon) == false) { + } else if (QPixmapCache::find(cacheKey, &mainIcon) == false) { mainIcon = theme->standardPixmap(sp, QSizeF(size)); QPixmapCache::insert(cacheKey, mainIcon); } From 566def740ec58e842e6bb37177f80e20aebaa245 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Mon, 2 Mar 2020 20:30:13 +0100 Subject: [PATCH 02/38] Windows QPA: Add support to UiaRaiseNotificationEvent() This change adds support to UiaRaiseNotificationEvent() in the UI Automation-based accessibility code, and uses it to notify changes in string-typed values, allowing Narrator, NVDA and other screen readers to notice changes in the application state that were previously missed. Fixes: QTBUG-75003 Change-Id: I646ca3a851ab7b69817d900b002eb91a3bf607a6 Reviewed-by: Friedemann Kleint --- .../qwindowsuiawrapper.cpp | 10 ++++++- .../qwindowsuiawrapper_p.h | 3 +++ .../windowsuiautomation/uiatypes_p.h | 16 ++++++++++++ .../uiautomation/qwindowsuiamainprovider.cpp | 26 +++++++++++++++---- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/platformsupport/windowsuiautomation/qwindowsuiawrapper.cpp b/src/platformsupport/windowsuiautomation/qwindowsuiawrapper.cpp index 79541fe636c..8038e1a3c3b 100644 --- a/src/platformsupport/windowsuiautomation/qwindowsuiawrapper.cpp +++ b/src/platformsupport/windowsuiautomation/qwindowsuiawrapper.cpp @@ -53,6 +53,7 @@ QWindowsUiaWrapper::QWindowsUiaWrapper() m_pUiaHostProviderFromHwnd = reinterpret_cast(uiaLib.resolve("UiaHostProviderFromHwnd")); m_pUiaRaiseAutomationPropertyChangedEvent = reinterpret_cast(uiaLib.resolve("UiaRaiseAutomationPropertyChangedEvent")); m_pUiaRaiseAutomationEvent = reinterpret_cast(uiaLib.resolve("UiaRaiseAutomationEvent")); + m_pUiaRaiseNotificationEvent = reinterpret_cast(uiaLib.resolve("UiaRaiseNotificationEvent")); m_pUiaClientsAreListening = reinterpret_cast(uiaLib.resolve("UiaClientsAreListening")); } } @@ -68,7 +69,7 @@ QWindowsUiaWrapper *QWindowsUiaWrapper::instance() return &wrapper; } -// True if all symbols resolved. +// True if most symbols resolved (UiaRaiseNotificationEvent is optional). BOOL QWindowsUiaWrapper::ready() { return m_pUiaReturnRawElementProvider @@ -113,5 +114,12 @@ HRESULT QWindowsUiaWrapper::raiseAutomationEvent(IRawElementProviderSimple *pPro return m_pUiaRaiseAutomationEvent(pProvider, id); } +HRESULT QWindowsUiaWrapper::raiseNotificationEvent(IRawElementProviderSimple *provider, NotificationKind notificationKind, NotificationProcessing notificationProcessing, BSTR displayString, BSTR activityId) +{ + if (!m_pUiaRaiseNotificationEvent) + return UIA_E_NOTSUPPORTED; + return m_pUiaRaiseNotificationEvent(provider, notificationKind, notificationProcessing, displayString, activityId); +} + QT_END_NAMESPACE diff --git a/src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h b/src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h index 3ebc3008d30..9208acbc31e 100644 --- a/src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h +++ b/src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h @@ -80,17 +80,20 @@ public: HRESULT hostProviderFromHwnd(HWND hwnd, IRawElementProviderSimple **ppProvider); HRESULT raiseAutomationPropertyChangedEvent(IRawElementProviderSimple *pProvider, PROPERTYID id, VARIANT oldValue, VARIANT newValue); HRESULT raiseAutomationEvent(IRawElementProviderSimple *pProvider, EVENTID id); + HRESULT raiseNotificationEvent(IRawElementProviderSimple *provider, NotificationKind notificationKind, NotificationProcessing notificationProcessing, BSTR displayString, BSTR activityId); private: typedef LRESULT (WINAPI *PtrUiaReturnRawElementProvider)(HWND, WPARAM, LPARAM, IRawElementProviderSimple *); typedef HRESULT (WINAPI *PtrUiaHostProviderFromHwnd)(HWND, IRawElementProviderSimple **); typedef HRESULT (WINAPI *PtrUiaRaiseAutomationPropertyChangedEvent)(IRawElementProviderSimple *, PROPERTYID, VARIANT, VARIANT); typedef HRESULT (WINAPI *PtrUiaRaiseAutomationEvent)(IRawElementProviderSimple *, EVENTID); + typedef HRESULT (WINAPI *PtrUiaRaiseNotificationEvent)(IRawElementProviderSimple *, NotificationKind, NotificationProcessing, BSTR, BSTR); typedef BOOL (WINAPI *PtrUiaClientsAreListening)(); PtrUiaReturnRawElementProvider m_pUiaReturnRawElementProvider = nullptr; PtrUiaHostProviderFromHwnd m_pUiaHostProviderFromHwnd = nullptr; PtrUiaRaiseAutomationPropertyChangedEvent m_pUiaRaiseAutomationPropertyChangedEvent = nullptr; PtrUiaRaiseAutomationEvent m_pUiaRaiseAutomationEvent = nullptr; + PtrUiaRaiseNotificationEvent m_pUiaRaiseNotificationEvent = nullptr; PtrUiaClientsAreListening m_pUiaClientsAreListening = nullptr; }; diff --git a/src/platformsupport/windowsuiautomation/uiatypes_p.h b/src/platformsupport/windowsuiautomation/uiatypes_p.h index afbc9570941..0d2e1161e44 100644 --- a/src/platformsupport/windowsuiautomation/uiatypes_p.h +++ b/src/platformsupport/windowsuiautomation/uiatypes_p.h @@ -162,6 +162,22 @@ enum ExpandCollapseState { ExpandCollapseState_LeafNode = 3 }; +enum NotificationKind { + NotificationKind_ItemAdded = 0, + NotificationKind_ItemRemoved = 1, + NotificationKind_ActionCompleted = 2, + NotificationKind_ActionAborted = 3, + NotificationKind_Other = 4 +}; + +enum NotificationProcessing { + NotificationProcessing_ImportantAll = 0, + NotificationProcessing_ImportantMostRecent = 1, + NotificationProcessing_All = 2, + NotificationProcessing_MostRecent = 3, + NotificationProcessing_CurrentThenMostRecent = 4 +}; + struct UiaRect { double left; double top; diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 9adc5c78dd9..59360616a19 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -166,11 +166,27 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve } if (event->value().type() == QVariant::String) { if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) { - // Notifies changes in string values. - VARIANT oldVal, newVal; - clearVariant(&oldVal); - setVariantString(event->value().toString(), &newVal); - QWindowsUiaWrapper::instance()->raiseAutomationPropertyChangedEvent(provider, UIA_ValueValuePropertyId, oldVal, newVal); + + // Tries to notify the change using UiaRaiseNotificationEvent(), which is only available on + // Windows 10 version 1709 or newer. Otherwise uses UiaRaiseAutomationPropertyChangedEvent(). + + BSTR displayString = bStrFromQString(event->value().toString()); + BSTR activityId = bStrFromQString(QString()); + + HRESULT hr = QWindowsUiaWrapper::instance()->raiseNotificationEvent(provider, NotificationKind_Other, + NotificationProcessing_ImportantMostRecent, + displayString, activityId); + + ::SysFreeString(displayString); + ::SysFreeString(activityId); + + if (hr == static_cast(UIA_E_NOTSUPPORTED)) { + VARIANT oldVal, newVal; + clearVariant(&oldVal); + setVariantString(event->value().toString(), &newVal); + QWindowsUiaWrapper::instance()->raiseAutomationPropertyChangedEvent(provider, UIA_ValueValuePropertyId, oldVal, newVal); + ::SysFreeString(newVal.bstrVal); + } } } else if (QAccessibleValueInterface *valueInterface = accessible->valueInterface()) { if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) { From 813111689629a71e51d7d149a5f689b2961f2716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 25 Feb 2020 11:55:30 +0100 Subject: [PATCH 03/38] QSslCertificate: Turn enum into enum class and expand abbreviation From API review Change-Id: Id174ff1a0a123585e41723ef1c1876b2f3bd39c5 Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslcertificate.cpp | 8 +- src/network/ssl/qsslcertificate.h | 4 +- src/network/ssl/qsslconfiguration.h | 5 +- .../qsslcertificate/tst_qsslcertificate.cpp | 170 +++++++++--------- 4 files changed, 94 insertions(+), 93 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index c179cf9c4a8..791dc7852f1 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -573,12 +573,12 @@ QList QSslCertificate::fromPath(const QString &path, int pos = -1; #if QT_CONFIG(regularexpression) - if (syntax == Wildcard) + if (syntax == PatternSyntax::Wildcard) pos = pathPrefix.indexOf(QRegularExpression(QLatin1String("[*?[]"))); - else if (syntax == RegExp) + else if (syntax == PatternSyntax::RegularExpression) pos = sourcePath.indexOf(QRegularExpression(QLatin1String("[\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]"))); #else - if (syntax == Wildcard || syntax == RegExp) + if (syntax == PatternSyntax::Wildcard || syntax == PatternSyntax::RegExp) qWarning("Regular expression support is disabled in this build. Only fixed string can be searched"); return QList(); #endif @@ -615,7 +615,7 @@ QList QSslCertificate::fromPath(const QString &path, QList certs; #if QT_CONFIG(regularexpression) - if (syntax == Wildcard) + if (syntax == PatternSyntax::Wildcard) sourcePath = QRegularExpression::wildcardToRegularExpression(sourcePath); QRegularExpression pattern(QRegularExpression::anchoredPattern(sourcePath)); diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h index 99937698881..b98c5cfcabe 100644 --- a/src/network/ssl/qsslcertificate.h +++ b/src/network/ssl/qsslcertificate.h @@ -84,8 +84,8 @@ public: EmailAddress }; - enum PatternSyntax { - RegExp, + enum class PatternSyntax { + RegularExpression, Wildcard, FixedString }; diff --git a/src/network/ssl/qsslconfiguration.h b/src/network/ssl/qsslconfiguration.h index 09616098a59..1c181121f4c 100644 --- a/src/network/ssl/qsslconfiguration.h +++ b/src/network/ssl/qsslconfiguration.h @@ -131,8 +131,9 @@ public: // Certificate Authority (CA) settings QList caCertificates() const; void setCaCertificates(const QList &certificates); - bool addCaCertificates(const QString &path, QSsl::EncodingFormat format = QSsl::Pem, - QSslCertificate::PatternSyntax syntax = QSslCertificate::FixedString); + bool addCaCertificates( + const QString &path, QSsl::EncodingFormat format = QSsl::Pem, + QSslCertificate::PatternSyntax syntax = QSslCertificate::PatternSyntax::FixedString); void addCaCertificate(const QSslCertificate &certificate); void addCaCertificates(const QList &certificates); diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index a7a81e9f0b0..6cd730bd387 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -436,7 +436,7 @@ void tst_QSslCertificate::subjectAlternativeNames() void tst_QSslCertificate::utf8SubjectNames() { QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert-ss-san-utf8.pem", QSsl::Pem, - QSslCertificate::FixedString).first(); + QSslCertificate::PatternSyntax::FixedString).first(); QVERIFY(!cert.isNull()); // O is "Heavy Metal Records" with heavy use of "decorations" like accents, umlauts etc., @@ -634,66 +634,66 @@ void tst_QSslCertificate::fromPath_qregularexpression_data() QTest::addColumn("pemencoding"); QTest::addColumn("numCerts"); - QTest::newRow("empty fixed pem") << QString() << int(QSslCertificate::FixedString) << true << 0; - QTest::newRow("empty fixed der") << QString() << int(QSslCertificate::FixedString) << false << 0; - QTest::newRow("empty regexp pem") << QString() << int(QSslCertificate::RegExp) << true << 0; - QTest::newRow("empty regexp der") << QString() << int(QSslCertificate::RegExp) << false << 0; - QTest::newRow("empty wildcard pem") << QString() << int(QSslCertificate::Wildcard) << true << 0; - QTest::newRow("empty wildcard der") << QString() << int(QSslCertificate::Wildcard) << false << 0; - QTest::newRow("\"certificates\" fixed pem") << (testDataDir + "certificates") << int(QSslCertificate::FixedString) << true << 0; - QTest::newRow("\"certificates\" fixed der") << (testDataDir + "certificates") << int(QSslCertificate::FixedString) << false << 0; - QTest::newRow("\"certificates\" regexp pem") << (testDataDir + "certificates") << int(QSslCertificate::RegExp) << true << 0; - QTest::newRow("\"certificates\" regexp der") << (testDataDir + "certificates") << int(QSslCertificate::RegExp) << false << 0; - QTest::newRow("\"certificates\" wildcard pem") << (testDataDir + "certificates") << int(QSslCertificate::Wildcard) << true << 0; - QTest::newRow("\"certificates\" wildcard der") << (testDataDir + "certificates") << int(QSslCertificate::Wildcard) << false << 0; - QTest::newRow("\"certificates/cert.pem\" fixed pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::FixedString) << true << 1; - QTest::newRow("\"certificates/cert.pem\" fixed der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::FixedString) << false << 0; - QTest::newRow("\"certificates/cert.pem\" regexp pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::RegExp) << true << 1; - QTest::newRow("\"certificates/cert.pem\" regexp der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::RegExp) << false << 0; - QTest::newRow("\"certificates/cert.pem\" wildcard pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::Wildcard) << true << 1; - QTest::newRow("\"certificates/cert.pem\" wildcard der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::Wildcard) << false << 0; - QTest::newRow("\"certificates/*\" fixed pem") << (testDataDir + "certificates/*") << int(QSslCertificate::FixedString) << true << 0; - QTest::newRow("\"certificates/*\" fixed der") << (testDataDir + "certificates/*") << int(QSslCertificate::FixedString) << false << 0; - QTest::newRow("\"certificates/*\" regexp pem") << (testDataDir + "certificates/*") << int(QSslCertificate::RegExp) << true << 0; - QTest::newRow("\"certificates/*\" regexp der") << (testDataDir + "certificates/*") << int(QSslCertificate::RegExp) << false << 0; - QTest::newRow("\"certificates/*\" wildcard pem") << (testDataDir + "certificates/*") << int(QSslCertificate::Wildcard) << true << 7; - QTest::newRow("\"certificates/ca*\" wildcard pem") << (testDataDir + "certificates/ca*") << int(QSslCertificate::Wildcard) << true << 1; - QTest::newRow("\"certificates/cert*\" wildcard pem") << (testDataDir + "certificates/cert*") << int(QSslCertificate::Wildcard) << true << 4; - QTest::newRow("\"certificates/cert-[sure]*\" wildcard pem") << (testDataDir + "certificates/cert-[sure]*") << int(QSslCertificate::Wildcard) << true << 3; - QTest::newRow("\"certificates/cert-[not]*\" wildcard pem") << (testDataDir + "certificates/cert-[not]*") << int(QSslCertificate::Wildcard) << true << 0; - QTest::newRow("\"certificates/*\" wildcard der") << (testDataDir + "certificates/*") << int(QSslCertificate::Wildcard) << false << 2; - QTest::newRow("\"c*/c*.pem\" fixed pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::FixedString) << true << 0; - QTest::newRow("\"c*/c*.pem\" fixed der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::FixedString) << false << 0; - QTest::newRow("\"c*/c*.pem\" regexp pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::RegExp) << true << 0; - QTest::newRow("\"c*/c*.pem\" regexp der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::RegExp) << false << 0; - QTest::newRow("\"c*/c*.pem\" wildcard pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::Wildcard) << true << 5; - QTest::newRow("\"c*/c*.pem\" wildcard der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::Wildcard) << false << 0; - QTest::newRow("\"d*/c*.pem\" fixed pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::FixedString) << true << 0; - QTest::newRow("\"d*/c*.pem\" fixed der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::FixedString) << false << 0; - QTest::newRow("\"d*/c*.pem\" regexp pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::RegExp) << true << 0; - QTest::newRow("\"d*/c*.pem\" regexp der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::RegExp) << false << 0; - QTest::newRow("\"d*/c*.pem\" wildcard pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::Wildcard) << true << 0; - QTest::newRow("\"d*/c*.pem\" wildcard der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::Wildcard) << false << 0; - QTest::newRow("\"c.*/c.*.pem\" fixed pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::FixedString) << true << 0; - QTest::newRow("\"c.*/c.*.pem\" fixed der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::FixedString) << false << 0; - QTest::newRow("\"c.*/c.*.pem\" regexp pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::RegExp) << true << 5; - QTest::newRow("\"c.*/c.*.pem\" regexp der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::RegExp) << false << 0; - QTest::newRow("\"c.*/c.*.pem\" wildcard pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::Wildcard) << true << 0; - QTest::newRow("\"c.*/c.*.pem\" wildcard der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::Wildcard) << false << 0; - QTest::newRow("\"d.*/c.*.pem\" fixed pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::FixedString) << true << 0; - QTest::newRow("\"d.*/c.*.pem\" fixed der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::FixedString) << false << 0; - QTest::newRow("\"d.*/c.*.pem\" regexp pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::RegExp) << true << 0; - QTest::newRow("\"d.*/c.*.pem\" regexp der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::RegExp) << false << 0; - QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::Wildcard) << true << 0; - QTest::newRow("\"d.*/c.*.pem\" wildcard der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::Wildcard) << false << 0; + QTest::newRow("empty fixed pem") << QString() << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; + QTest::newRow("empty fixed der") << QString() << int(QSslCertificate::PatternSyntax::FixedString) << false << 0; + QTest::newRow("empty regexp pem") << QString() << int(QSslCertificate::PatternSyntax::RegularExpression) << true << 0; + QTest::newRow("empty regexp der") << QString() << int(QSslCertificate::PatternSyntax::RegularExpression) << false << 0; + QTest::newRow("empty wildcard pem") << QString() << int(QSslCertificate::PatternSyntax::Wildcard) << true << 0; + QTest::newRow("empty wildcard der") << QString() << int(QSslCertificate::PatternSyntax::Wildcard) << false << 0; + QTest::newRow("\"certificates\" fixed pem") << (testDataDir + "certificates") << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; + QTest::newRow("\"certificates\" fixed der") << (testDataDir + "certificates") << int(QSslCertificate::PatternSyntax::FixedString) << false << 0; + QTest::newRow("\"certificates\" regexp pem") << (testDataDir + "certificates") << int(QSslCertificate::PatternSyntax::RegularExpression) << true << 0; + QTest::newRow("\"certificates\" regexp der") << (testDataDir + "certificates") << int(QSslCertificate::PatternSyntax::RegularExpression) << false << 0; + QTest::newRow("\"certificates\" wildcard pem") << (testDataDir + "certificates") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 0; + QTest::newRow("\"certificates\" wildcard der") << (testDataDir + "certificates") << int(QSslCertificate::PatternSyntax::Wildcard) << false << 0; + QTest::newRow("\"certificates/cert.pem\" fixed pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 1; + QTest::newRow("\"certificates/cert.pem\" fixed der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::PatternSyntax::FixedString) << false << 0; + QTest::newRow("\"certificates/cert.pem\" regexp pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << true << 1; + QTest::newRow("\"certificates/cert.pem\" regexp der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << false << 0; + QTest::newRow("\"certificates/cert.pem\" wildcard pem") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 1; + QTest::newRow("\"certificates/cert.pem\" wildcard der") << (testDataDir + "certificates/cert.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << false << 0; + QTest::newRow("\"certificates/*\" fixed pem") << (testDataDir + "certificates/*") << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; + QTest::newRow("\"certificates/*\" fixed der") << (testDataDir + "certificates/*") << int(QSslCertificate::PatternSyntax::FixedString) << false << 0; + QTest::newRow("\"certificates/*\" regexp pem") << (testDataDir + "certificates/*") << int(QSslCertificate::PatternSyntax::RegularExpression) << true << 0; + QTest::newRow("\"certificates/*\" regexp der") << (testDataDir + "certificates/*") << int(QSslCertificate::PatternSyntax::RegularExpression) << false << 0; + QTest::newRow("\"certificates/*\" wildcard pem") << (testDataDir + "certificates/*") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 7; + QTest::newRow("\"certificates/ca*\" wildcard pem") << (testDataDir + "certificates/ca*") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 1; + QTest::newRow("\"certificates/cert*\" wildcard pem") << (testDataDir + "certificates/cert*") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 4; + QTest::newRow("\"certificates/cert-[sure]*\" wildcard pem") << (testDataDir + "certificates/cert-[sure]*") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 3; + QTest::newRow("\"certificates/cert-[not]*\" wildcard pem") << (testDataDir + "certificates/cert-[not]*") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 0; + QTest::newRow("\"certificates/*\" wildcard der") << (testDataDir + "certificates/*") << int(QSslCertificate::PatternSyntax::Wildcard) << false << 2; + QTest::newRow("\"c*/c*.pem\" fixed pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; + QTest::newRow("\"c*/c*.pem\" fixed der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::PatternSyntax::FixedString) << false << 0; + QTest::newRow("\"c*/c*.pem\" regexp pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << true << 0; + QTest::newRow("\"c*/c*.pem\" regexp der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << false << 0; + QTest::newRow("\"c*/c*.pem\" wildcard pem") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 5; + QTest::newRow("\"c*/c*.pem\" wildcard der") << (testDataDir + "c*/c*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << false << 0; + QTest::newRow("\"d*/c*.pem\" fixed pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; + QTest::newRow("\"d*/c*.pem\" fixed der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::PatternSyntax::FixedString) << false << 0; + QTest::newRow("\"d*/c*.pem\" regexp pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << true << 0; + QTest::newRow("\"d*/c*.pem\" regexp der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << false << 0; + QTest::newRow("\"d*/c*.pem\" wildcard pem") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 0; + QTest::newRow("\"d*/c*.pem\" wildcard der") << (testDataDir + "d*/c*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << false << 0; + QTest::newRow("\"c.*/c.*.pem\" fixed pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; + QTest::newRow("\"c.*/c.*.pem\" fixed der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::PatternSyntax::FixedString) << false << 0; + QTest::newRow("\"c.*/c.*.pem\" regexp pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << true << 5; + QTest::newRow("\"c.*/c.*.pem\" regexp der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << false << 0; + QTest::newRow("\"c.*/c.*.pem\" wildcard pem") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 0; + QTest::newRow("\"c.*/c.*.pem\" wildcard der") << (testDataDir + "c.*/c.*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << false << 0; + QTest::newRow("\"d.*/c.*.pem\" fixed pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; + QTest::newRow("\"d.*/c.*.pem\" fixed der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::PatternSyntax::FixedString) << false << 0; + QTest::newRow("\"d.*/c.*.pem\" regexp pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << true << 0; + QTest::newRow("\"d.*/c.*.pem\" regexp der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::PatternSyntax::RegularExpression) << false << 0; + QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 0; + QTest::newRow("\"d.*/c.*.pem\" wildcard der") << (testDataDir + "d.*/c.*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << false << 0; #ifdef Q_OS_LINUX - QTest::newRow("absolute path wildcard pem") << (testDataDir + "certificates/*.pem") << int(QSslCertificate::Wildcard) << true << 7; + QTest::newRow("absolute path wildcard pem") << (testDataDir + "certificates/*.pem") << int(QSslCertificate::PatternSyntax::Wildcard) << true << 7; #endif - QTest::newRow("trailing-whitespace") << (testDataDir + "more-certificates/trailing-whitespace.pem") << int(QSslCertificate::FixedString) << true << 1; - QTest::newRow("no-ending-newline") << (testDataDir + "more-certificates/no-ending-newline.pem") << int(QSslCertificate::FixedString) << true << 1; - QTest::newRow("malformed-just-begin") << (testDataDir + "more-certificates/malformed-just-begin.pem") << int(QSslCertificate::FixedString) << true << 0; - QTest::newRow("malformed-just-begin-no-newline") << (testDataDir + "more-certificates/malformed-just-begin-no-newline.pem") << int(QSslCertificate::FixedString) << true << 0; + QTest::newRow("trailing-whitespace") << (testDataDir + "more-certificates/trailing-whitespace.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 1; + QTest::newRow("no-ending-newline") << (testDataDir + "more-certificates/no-ending-newline.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 1; + QTest::newRow("malformed-just-begin") << (testDataDir + "more-certificates/malformed-just-begin.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; + QTest::newRow("malformed-just-begin-no-newline") << (testDataDir + "more-certificates/malformed-just-begin-no-newline.pem") << int(QSslCertificate::PatternSyntax::FixedString) << true << 0; } void tst_QSslCertificate::fromPath_qregularexpression() @@ -795,7 +795,7 @@ void tst_QSslCertificate::certInfo() "55:ba:e7:fb:95:5d:91"; QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem, - QSslCertificate::FixedString).first(); + QSslCertificate::PatternSyntax::FixedString).first(); QVERIFY(!cert.isNull()); QCOMPARE(cert.issuerInfo(QSslCertificate::Organization)[0], QString("CryptSoft Pty Ltd")); @@ -852,7 +852,7 @@ void tst_QSslCertificate::certInfo() void tst_QSslCertificate::certInfoQByteArray() { QSslCertificate cert = QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem, - QSslCertificate::FixedString).first(); + QSslCertificate::PatternSyntax::FixedString).first(); QVERIFY(!cert.isNull()); // in this test, check the bytearray variants before the enum variants to see if @@ -904,7 +904,7 @@ void tst_QSslCertificate::nulInCN() QSKIP("Generic QSslCertificatePrivate fails this test"); #endif QList certList = - QSslCertificate::fromPath(testDataDir + "more-certificates/badguy-nul-cn.crt", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "more-certificates/badguy-nul-cn.crt", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QCOMPARE(certList.size(), 1); const QSslCertificate &cert = certList.at(0); @@ -923,7 +923,7 @@ void tst_QSslCertificate::nulInSan() QSKIP("Generic QSslCertificatePrivate fails this test"); #endif QList certList = - QSslCertificate::fromPath(testDataDir + "more-certificates/badguy-nul-san.crt", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "more-certificates/badguy-nul-san.crt", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QCOMPARE(certList.size(), 1); const QSslCertificate &cert = certList.at(0); @@ -943,7 +943,7 @@ void tst_QSslCertificate::nulInSan() void tst_QSslCertificate::largeSerialNumber() { QList certList = - QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-serial-number.pem", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-serial-number.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QCOMPARE(certList.size(), 1); @@ -955,7 +955,7 @@ void tst_QSslCertificate::largeSerialNumber() void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489 { QList certList = - QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QCOMPARE(certList.size(), 1); @@ -968,7 +968,7 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489 void tst_QSslCertificate::blacklistedCertificates() { - QList blacklistedCerts = QSslCertificate::fromPath(testDataDir + "more-certificates/blacklisted*.pem", QSsl::Pem, QSslCertificate::Wildcard); + QList blacklistedCerts = QSslCertificate::fromPath(testDataDir + "more-certificates/blacklisted*.pem", QSsl::Pem, QSslCertificate::PatternSyntax::Wildcard); QVERIFY(blacklistedCerts.count() > 0); for (int a = 0; a < blacklistedCerts.count(); a++) { QVERIFY(blacklistedCerts.at(a).isBlacklisted()); @@ -977,15 +977,15 @@ void tst_QSslCertificate::blacklistedCertificates() void tst_QSslCertificate::selfsignedCertificates() { - QVERIFY(QSslCertificate::fromPath(testDataDir + "certificates/cert-ss.pem", QSsl::Pem, QSslCertificate::FixedString).first().isSelfSigned()); - QVERIFY(!QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem, QSslCertificate::FixedString).first().isSelfSigned()); + QVERIFY(QSslCertificate::fromPath(testDataDir + "certificates/cert-ss.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first().isSelfSigned()); + QVERIFY(!QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first().isSelfSigned()); QVERIFY(!QSslCertificate().isSelfSigned()); } void tst_QSslCertificate::toText() { QList certList = - QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QCOMPARE(certList.size(), 1); const QSslCertificate &cert = certList.at(0); @@ -1027,7 +1027,7 @@ void tst_QSslCertificate::toText() void tst_QSslCertificate::multipleCommonNames() { QList certList = - QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-two-cns-cert.pem", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-two-cns-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QVERIFY(certList.count() > 0); QStringList commonNames = certList[0].subjectInfo(QSslCertificate::CommonName); @@ -1038,14 +1038,14 @@ void tst_QSslCertificate::multipleCommonNames() void tst_QSslCertificate::subjectAndIssuerAttributes() { QList certList = - QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-with-drink-cert.pem", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "more-certificates/test-cn-with-drink-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QVERIFY(certList.count() > 0); QList attributes = certList[0].subjectInfoAttributes(); QVERIFY(attributes.contains(QByteArray("favouriteDrink"))); attributes.clear(); - certList = QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::FixedString); + certList = QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QVERIFY(certList.count() > 0); QByteArray shortName("1.3.6.1.4.1.311.60.2.1.3"); @@ -1080,17 +1080,17 @@ void tst_QSslCertificate::verify() errors.clear(); // Verify a valid cert signed by a CA - QList caCerts = QSslCertificate::fromPath(testDataDir + "verify-certs/cacert.pem", QSsl::Pem, QSslCertificate::FixedString); + QList caCerts = QSslCertificate::fromPath(testDataDir + "verify-certs/cacert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QSslSocket::addDefaultCaCertificate(caCerts.first()); - toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::FixedString); + toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); errors = QSslCertificate::verify(toVerify); VERIFY_VERBOSE(errors.count() == 0); errors.clear(); // Test a blacklisted certificate - toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem", QSsl::Pem, QSslCertificate::FixedString); + toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); errors = QSslCertificate::verify(toVerify); bool foundBlack = false; foreach (const QSslError &error, errors) { @@ -1103,7 +1103,7 @@ void tst_QSslCertificate::verify() errors.clear(); // This one is expired and untrusted - toVerify = QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-serial-number.pem", QSsl::Pem, QSslCertificate::FixedString); + toVerify = QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-serial-number.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); errors = QSslCertificate::verify(toVerify); VERIFY_VERBOSE(errors.contains(QSslError(QSslError::SelfSignedCertificate, toVerify[0]))); VERIFY_VERBOSE(errors.contains(QSslError(QSslError::CertificateExpired, toVerify[0]))); @@ -1111,15 +1111,15 @@ void tst_QSslCertificate::verify() toVerify.clear(); // This one is signed by a valid cert, but the signer is not a valid CA - toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-not-ca-cert.pem", QSsl::Pem, QSslCertificate::FixedString).first(); - toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::FixedString).first(); + toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-not-ca-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first(); + toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first(); errors = QSslCertificate::verify(toVerify); VERIFY_VERBOSE(errors.contains(QSslError(QSslError::InvalidCaCertificate, toVerify[1]))); toVerify.clear(); // This one is signed by a valid cert, and the signer is a valid CA - toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-is-ca-cert.pem", QSsl::Pem, QSslCertificate::FixedString).first(); - toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-ca-cert.pem", QSsl::Pem, QSslCertificate::FixedString).first(); + toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-is-ca-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first(); + toVerify << QSslCertificate::fromPath(testDataDir + "verify-certs/test-intermediate-ca-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString).first(); errors = QSslCertificate::verify(toVerify); VERIFY_VERBOSE(errors.count() == 0); @@ -1149,7 +1149,7 @@ QString tst_QSslCertificate::toString(const QList& errors) void tst_QSslCertificate::extensions() { QList certList = - QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "more-certificates/natwest-banking.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QVERIFY(certList.count() > 0); QSslCertificate cert = certList[0]; @@ -1247,7 +1247,7 @@ void tst_QSslCertificate::extensions() void tst_QSslCertificate::extensionsCritical() { QList certList = - QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem", QSsl::Pem, QSslCertificate::FixedString); + QSslCertificate::fromPath(testDataDir + "verify-certs/test-addons-mozilla-org-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QVERIFY(certList.count() > 0); QSslCertificate cert = certList[0]; @@ -1368,12 +1368,12 @@ void tst_QSslCertificate::version_data() QTest::newRow("null certificate") << QSslCertificate() << QByteArray(); QList certs; - certs << QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::FixedString); + certs << QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QTest::newRow("v3 certificate") << certs.first() << QByteArrayLiteral("3"); certs.clear(); - certs << QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem, QSslCertificate::FixedString); + certs << QSslCertificate::fromPath(testDataDir + "certificates/cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QTest::newRow("v1 certificate") << certs.first() << QByteArrayLiteral("1"); } @@ -1410,7 +1410,7 @@ void tst_QSslCertificate::pkcs12() QVERIFY(ok); f.close(); - QList leafCert = QSslCertificate::fromPath(testDataDir + QLatin1String("pkcs12/leaf.crt"), QSsl::Pem, QSslCertificate::FixedString); + QList leafCert = QSslCertificate::fromPath(testDataDir + QLatin1String("pkcs12/leaf.crt"), QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QVERIFY(!leafCert.isEmpty()); QCOMPARE(cert, leafCert.first()); @@ -1425,7 +1425,7 @@ void tst_QSslCertificate::pkcs12() QVERIFY(!leafKey.isNull()); QCOMPARE(key, leafKey); - QList caCert = QSslCertificate::fromPath(testDataDir + QLatin1String("pkcs12/inter.crt"), QSsl::Pem, QSslCertificate::FixedString); + QList caCert = QSslCertificate::fromPath(testDataDir + QLatin1String("pkcs12/inter.crt"), QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); QVERIFY(!caCert.isEmpty()); QVERIFY(!caCerts.isEmpty()); From 519ea72108fae7f5c4ed7c3e9fed3a999a16ed73 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 2 Mar 2020 17:00:04 +0200 Subject: [PATCH 04/38] Android: Bump gradle (plugin) versions Move min & target sdk from AndroidManifest.xml to build.gradle Fixes: QTBUG-70817 Change-Id: Id9bb9825a3232587e0255b2d3d6f0273c5f9b66a Reviewed-by: Assam Boudjelthia Reviewed-by: Joerg Bornemann --- mkspecs/android-clang/qmake.conf | 3 +++ .../android/android_deployment_settings.prf | 6 ++++++ .../gradle/wrapper/gradle-wrapper.properties | 2 +- src/android/templates/AndroidManifest.xml | 2 -- src/android/templates/build.gradle | 8 +++++++- src/corelib/Qt5AndroidSupport.cmake | 5 +++++ src/tools/androiddeployqt/main.cpp | 16 ++++++++++++++++ 7 files changed, 38 insertions(+), 4 deletions(-) diff --git a/mkspecs/android-clang/qmake.conf b/mkspecs/android-clang/qmake.conf index 31ee5d26371..5cc5a20f717 100644 --- a/mkspecs/android-clang/qmake.conf +++ b/mkspecs/android-clang/qmake.conf @@ -43,6 +43,9 @@ isEmpty(ALL_ANDROID_ABIS): ALL_ANDROID_ABIS = arm64-v8a armeabi-v7a x86_64 x86 CONFIG += $$ANDROID_PLATFORM +ANDROID_MIN_SDK_VERSION = $$replace(ANDROID_PLATFORM, "android-", "") +ANDROID_TARGET_SDK_VERSION = 28 + NDK_LLVM_PATH = $$NDK_ROOT/toolchains/llvm/prebuilt/$$NDK_HOST QMAKE_CC = $$NDK_LLVM_PATH/bin/clang QMAKE_CXX = $$NDK_LLVM_PATH/bin/clang++ diff --git a/mkspecs/features/android/android_deployment_settings.prf b/mkspecs/features/android/android_deployment_settings.prf index f375a687a95..7cda5096b1f 100644 --- a/mkspecs/features/android/android_deployment_settings.prf +++ b/mkspecs/features/android/android_deployment_settings.prf @@ -53,6 +53,12 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-embedded { !isEmpty(ANDROID_VERSION_CODE): \ FILE_CONTENT += " \"android-version-code\": $$emitString($$ANDROID_VERSION_CODE)," + !isEmpty(ANDROID_MIN_SDK_VERSION): \ + FILE_CONTENT += " \"android-min-sdk-version\": $$emitString($$ANDROID_MIN_SDK_VERSION)," + + !isEmpty(ANDROID_TARGET_SDK_VERSION): \ + FILE_CONTENT += " \"android-target-sdk-version\": $$emitString($$ANDROID_TARGET_SDK_VERSION)," + !isEmpty(ANDROID_EXTRA_LIBS): \ FILE_CONTENT += " \"android-extra-libs\": $$emitString($$join(ANDROID_EXTRA_LIBS, ","))," diff --git a/src/3rdparty/gradle/gradle/wrapper/gradle-wrapper.properties b/src/3rdparty/gradle/gradle/wrapper/gradle-wrapper.properties index 4b7e1f3d386..5028f28f8e4 100644 --- a/src/3rdparty/gradle/gradle/wrapper/gradle-wrapper.properties +++ b/src/3rdparty/gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/android/templates/AndroidManifest.xml b/src/android/templates/AndroidManifest.xml index 6d0f4e0d458..e31dea6a8cc 100644 --- a/src/android/templates/AndroidManifest.xml +++ b/src/android/templates/AndroidManifest.xml @@ -1,7 +1,5 @@ - - diff --git a/src/android/templates/build.gradle b/src/android/templates/build.gradle index 3087d08c83e..d5b3b93499e 100644 --- a/src/android/templates/build.gradle +++ b/src/android/templates/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:3.6.0' } } @@ -59,4 +59,10 @@ android { aaptOptions { noCompress 'rcc' } + + defaultConfig { + resConfig "en" + minSdkVersion = qtMinSdkVersion + targetSdkVersion = qtTargetSdkVersion + } } diff --git a/src/corelib/Qt5AndroidSupport.cmake b/src/corelib/Qt5AndroidSupport.cmake index 5f24fb0e8c9..4db38f39574 100644 --- a/src/corelib/Qt5AndroidSupport.cmake +++ b/src/corelib/Qt5AndroidSupport.cmake @@ -18,6 +18,8 @@ if (NOT ${PROJECT_NAME}-MultiAbiBuild) option(ANDROID_BUILD_ABI_${abi} "Enable the build for Android ${abi}" ${abi_initial_value}) endif() endforeach() + option(ANDROID_MIN_SDK_VERSION "Android minimum SDK version" "21") + option(ANDROID_TARGET_SDK_VERSION "Android target SDK version" "28") # Make sure to delete the "android-build" directory, which contains all the # build artefacts, and also the androiddeployqt/gradle artefacts @@ -101,6 +103,9 @@ if (NOT ${PROJECT_NAME}-MultiAbiBuild) generate_json_variable(ANDROID_VERSION_NAME "android-version-name") generate_json_variable_list(ANDROID_EXTRA_LIBS "android-extra-libs") generate_json_variable_list(QML_IMPORT_PATH "qml-import-paths") + generate_json_variable_list(ANDROID_MIN_SDK_VERSION "android-min-sdk-version") + generate_json_variable_list(ANDROID_TARGET_SDK_VERSION "android-target-sdk-version") + configure_file( "${CMAKE_BINARY_DIR}/android_deployment_settings.json.in" diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 97e5c9eb694..2799f97fe8f 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -169,6 +169,8 @@ struct Options // Versioning QString versionName; QString versionCode; + QByteArray minSdkVersion{"21"}; + QByteArray targetSdkVersion{"28"}; // lib c++ path QString stdCppPath; @@ -849,6 +851,18 @@ bool readInputFile(Options *options) options->versionCode = QStringLiteral("1"); } + { + const QJsonValue ver = jsonObject.value(QLatin1String("android-min-sdk-version")); + if (!ver.isUndefined()) + options->minSdkVersion = ver.toString().toUtf8(); + } + + { + const QJsonValue ver = jsonObject.value(QLatin1String("android-target-sdk-version")); + if (!ver.isUndefined()) + options->targetSdkVersion = ver.toString().toUtf8(); + } + { const QJsonObject targetArchitectures = jsonObject.value(QLatin1String("architectures")).toObject(); if (targetArchitectures.isEmpty()) { @@ -2298,6 +2312,8 @@ bool buildAndroidProject(const Options &options) gradleProperties["buildDir"] = "build"; gradleProperties["qt5AndroidDir"] = (options.qtInstallDirectory + QLatin1String("/src/android/java")).toUtf8(); gradleProperties["androidCompileSdkVersion"] = options.androidPlatform.split(QLatin1Char('-')).last().toLocal8Bit(); + gradleProperties["qtMinSdkVersion"] = options.minSdkVersion; + gradleProperties["qtTargetSdkVersion"] = options.targetSdkVersion; if (gradleProperties["androidBuildToolsVersion"].isEmpty()) gradleProperties["androidBuildToolsVersion"] = options.sdkBuildToolsVersion.toLocal8Bit(); From 9e46dd7719b63710a6e4ffc6c43e55be710b2c5a Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 3 Mar 2020 15:46:17 +0100 Subject: [PATCH 05/38] Document TlsV1SslV3 as deprecated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id127b6d985d0085982e47b4f80886e3831ce07c7 Reviewed-by: Mårten Nordheim --- src/network/ssl/qssl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp index c9fa7f85d9b..beb03b646ac 100644 --- a/src/network/ssl/qssl.cpp +++ b/src/network/ssl/qssl.cpp @@ -137,7 +137,7 @@ Q_LOGGING_CATEGORY(lcSsl, "qt.network.ssl"); \value TlsV1_3OrLater TLSv1.3 and later versions. (Since Qt 5.12) \value UnknownProtocol The cipher's protocol cannot be determined. \value AnyProtocol Any supported protocol. This value is used by QSslSocket only. - \value TlsV1SslV3 Same as TlsV1_0. + \value TlsV1SslV3 Same as TlsV1_0. This enumerator is deprecated, use TlsV1_0 instead. \value SecureProtocols The default option, using protocols known to be secure. */ From 728cc964f3f25d23c72317a119b839701f5941e8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 27 Jul 2019 15:47:54 +0300 Subject: [PATCH 06/38] QString/QByteArray: make all symmetry-checked member-compare() combinations noexcept In QByteArray, they were just not marked as such. In QString and QStringRef, the implicit conversion from QChar to QString would destroy it. Add a QChar overload, delegating to QStringView. Added docs for the new overloads, copying from the nearest neighbor so as to not look out of place. All string classes use different wording for these functions. A cleanup of this state of affairs is out of the scope of this patch. Change-Id: I0b7b1d037aa229bcaf29b793841a18caf977d66b Reviewed-by: Volker Hilsheimer Reviewed-by: Lars Knoll --- src/corelib/text/qbytearray.h | 8 +++---- src/corelib/text/qstring.cpp | 23 +++++++++++++++++++ src/corelib/text/qstring.h | 4 ++++ .../tst_qstringapisymmetry.cpp | 4 ---- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 36cf580cd94..e3bb9ea9373 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -240,8 +240,8 @@ public: int count(const char *a) const; int count(const QByteArray &a) const; - inline int compare(const char *c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; - inline int compare(const QByteArray &a, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + inline int compare(const char *c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + inline int compare(const QByteArray &a, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; Q_REQUIRED_RESULT QByteArray left(int len) const; Q_REQUIRED_RESULT QByteArray right(int len) const; @@ -663,12 +663,12 @@ inline bool QByteArray::contains(const QByteArray &a) const { return indexOf(a) != -1; } inline bool QByteArray::contains(char c) const { return indexOf(c) != -1; } -inline int QByteArray::compare(const char *c, Qt::CaseSensitivity cs) const +inline int QByteArray::compare(const char *c, Qt::CaseSensitivity cs) const noexcept { return cs == Qt::CaseSensitive ? qstrcmp(*this, c) : qstrnicmp(data(), size(), c, -1); } -inline int QByteArray::compare(const QByteArray &a, Qt::CaseSensitivity cs) const +inline int QByteArray::compare(const QByteArray &a, Qt::CaseSensitivity cs) const noexcept { return cs == Qt::CaseSensitive ? qstrcmp(*this, a) : qstrnicmp(data(), size(), a.data(), a.size()); diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 68dec7cfff8..f64f148f49b 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -6276,6 +6276,16 @@ QString& QString::fill(QChar ch, int size) sensitivity setting \a cs. */ +/*! + \fn int QString::compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const + + \since 5.14 + \overload compare() + + Performs a comparison of this with \a ch, using the case + sensitivity setting \a cs. +*/ + #if QT_STRINGVIEW_LEVEL < 2 /*! \overload compare() @@ -11073,6 +11083,19 @@ QStringRef QStringRef::appendTo(QString *string) const Equivalent to \c {compare(*this, other, cs)}. */ +/*! + \overload + \fn int QStringRef::compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const + \since 5.14 + + Compares this string with \a ch and returns an + integer less than, equal to, or greater than zero if this string + is less than, equal to, or greater than \a ch, interpreted as a string of length one. + + If \a cs is Qt::CaseSensitive, the comparison is case sensitive; + otherwise the comparison is case insensitive. +*/ + /*! \overload \fn int QStringRef::compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index bfc190e9e93..d615e6646c1 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -732,6 +732,8 @@ public: #endif int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + int compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { return compare(QStringView{&ch, 1}, cs); } static inline int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept @@ -1749,6 +1751,8 @@ public: int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + int compare(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); } int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp index bcf4e73108f..e6884bc2e56 100644 --- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -830,10 +830,6 @@ void tst_QStringApiSymmetry::member_compare_impl() const QEXPECT_FAIL("", "Qt is missing a nothrow utf8-utf16 comparator", Continue); \ QVERIFY(noexcept(expr)); } while (0) - if (std::is_same::value || // needs to simply be marked as noexcept - ((std::is_same::value || std::is_same::value) - && std::is_same::value)) // implict QChar -> QString conversion kills noexcept - QEXPECT_FAIL("", "known issues, will be fixed before 5.14 release", Continue); QVERIFY_NOEXCEPT(lhs.compare(rhs, Qt::CaseSensitive)); QCOMPARE(sign(lhs.compare(rhs)), caseSensitiveCompareResult); From b2f79cceb11dfd15ac9eea631bc18ad6b036eb91 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 29 Jul 2019 09:44:04 +0300 Subject: [PATCH 07/38] QLatin1String/QStringView: add (missing) member compare() [ChangeLog][QtCore][QLatin1String] Added compare(). [ChangeLog][QtCore][QStringView] Added compare() overloads taking QLatin1String, QChar. Change-Id: Ie2aa400299cb63495e65ce29b2a32133066de826 Reviewed-by: Volker Hilsheimer Reviewed-by: Thiago Macieira --- src/corelib/text/qstring.cpp | 17 ++++++++++++ src/corelib/text/qstring.h | 11 ++++++++ src/corelib/text/qstringview.cpp | 26 ++++++++++++++----- src/corelib/text/qstringview.h | 5 ++++ .../tst_qstringapisymmetry.cpp | 8 +++--- 5 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index f64f148f49b..210a8afc533 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -9717,6 +9717,23 @@ QString &QString::setRawData(const QChar *unicode, int size) \sa front(), at(), operator[]() */ +/*! + \fn int QLatin1String::compare(QStringView str, Qt::CaseSensitivity cs) const + \fn int QLatin1String::compare(QLatin1String l1, Qt::CaseSensitivity cs) const + \fn int QLatin1String::compare(QChar ch) const + \fn int QLatin1String::compare(QChar ch, Qt::CaseSensitivity cs) const + \since 5.14 + + Returns an integer that compares to zero as this Latin-1 string compares to the + string-view \a str, Latin-1 string \a l1, or character \a ch, respectively. + + If \a cs is Qt::CaseSensitive (the default), the comparison is case sensitive; + otherwise the comparison is case-insensitive. + + \sa operator==(), operator<(), operator>() +*/ + + /*! \fn bool QLatin1String::startsWith(QStringView str, Qt::CaseSensitivity cs) const \since 5.10 diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index d615e6646c1..99b41c8ebf8 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -111,6 +111,15 @@ public: Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char front() const { return at(0); } Q_REQUIRED_RESULT Q_DECL_CONSTEXPR QLatin1Char back() const { return at(size() - 1); } + Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { return QtPrivate::compareStrings(*this, other, cs); } + Q_REQUIRED_RESULT int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept + { return QtPrivate::compareStrings(*this, other, cs); } + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int compare(QChar c) const noexcept + { return isEmpty() || front() == c ? size() - 1 : uchar(m_data[0]) - c.unicode() ; } + Q_REQUIRED_RESULT int compare(QChar c, Qt::CaseSensitivity cs) const noexcept + { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); } + Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } Q_REQUIRED_RESULT bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept @@ -233,6 +242,8 @@ Q_DECL_CONSTEXPR bool QtPrivate::isLatin1(QLatin1String) noexcept // // QStringView members that require QLatin1String: // +int QStringView::compare(QLatin1String s, Qt::CaseSensitivity cs) const noexcept +{ return QtPrivate::compareStrings(*this, s, cs); } bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept { return QtPrivate::startsWith(*this, s, cs); } bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp index 08dade7e687..9df656dc590 100644 --- a/src/corelib/text/qstringview.cpp +++ b/src/corelib/text/qstringview.cpp @@ -692,15 +692,29 @@ QT_BEGIN_NAMESPACE */ /*! - \fn int QStringView::compare(QStringView other, Qt::CaseSensitivity cs) const + \fn int QStringView::compare(QStringView str, Qt::CaseSensitivity cs) const \since 5.12 - Compares this string-view with the \a other string-view and returns an - integer less than, equal to, or greater than zero if this string-view - is less than, equal to, or greater than the other string-view. + Returns an integer that compares to zero as this string-view compares to the + string-view \a str. - If \a cs is Qt::CaseSensitive, the comparison is case sensitive; - otherwise the comparison is case insensitive. + If \a cs is Qt::CaseSensitive (the default), the comparison is case sensitive; + otherwise the comparison is case-insensitive. + + \sa operator==(), operator<(), operator>() +*/ + +/*! + \fn int QStringView::compare(QLatin1String l1, Qt::CaseSensitivity cs) const + \fn int QStringView::compare(QChar ch) const + \fn int QStringView::compare(QChar ch, Qt::CaseSensitivity cs) const + \since 5.14 + + Returns an integer that compares to zero as this string-view compares to the + Latin-1 string \a l1, or character \a ch, respectively. + + If \a cs is Qt::CaseSensitive (the default), the comparison is case sensitive; + otherwise the comparison is case-insensitive. \sa operator==(), operator<(), operator>() */ diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 06391ffef4a..83418970a55 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -257,6 +257,11 @@ public: Q_REQUIRED_RESULT int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::compareStrings(*this, other, cs); } + Q_REQUIRED_RESULT inline int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; + Q_REQUIRED_RESULT Q_DECL_CONSTEXPR int compare(QChar c) const noexcept + { return empty() || front() == c ? size() - 1 : *utf16() - c.unicode() ; } + Q_REQUIRED_RESULT int compare(QChar c, Qt::CaseSensitivity cs) const noexcept + { return QtPrivate::compareStrings(*this, QStringView(&c, 1), cs); } Q_REQUIRED_RESULT bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp index e6884bc2e56..5ff1bcdce40 100644 --- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -275,23 +275,22 @@ private Q_SLOTS: void member_compare_QString_const_char_star_data() { member_compare_data(); } void member_compare_QString_const_char_star() { member_compare_impl(); } -#ifdef NOT_YET_IMPLEMENTED // QChar doesn't implicitly convert to QStringView void member_compare_QStringView_QChar_data() { member_compare_data(false); } void member_compare_QStringView_QChar() { member_compare_impl(); } -#endif void member_compare_QStringView_QStringRef_data() { member_compare_data(); } void member_compare_QStringView_QStringRef() { member_compare_impl(); } void member_compare_QStringView_QString_data() { member_compare_data(); } void member_compare_QStringView_QString() { member_compare_impl(); } void member_compare_QStringView_QStringView_data() { member_compare_data(); } void member_compare_QStringView_QStringView() { member_compare_impl(); } -#ifdef NOT_YET_IMPLEMENTED void member_compare_QStringView_QLatin1String_data() { member_compare_data(); } void member_compare_QStringView_QLatin1String() { member_compare_impl(); } +#ifdef NOT_YET_IMPLEMENTED void member_compare_QStringView_QByteArray_data() { member_compare_data(); } void member_compare_QStringView_QByteArray() { member_compare_impl(); } void member_compare_QStringView_const_char_star_data() { member_compare_data(); } void member_compare_QStringView_const_char_star() { member_compare_impl(); } +#endif void member_compare_QLatin1String_QChar_data() { member_compare_data(false); } void member_compare_QLatin1String_QChar() { member_compare_impl(); } @@ -303,6 +302,7 @@ private Q_SLOTS: void member_compare_QLatin1String_QStringView() { member_compare_impl(); } void member_compare_QLatin1String_QLatin1String_data() { member_compare_data(); } void member_compare_QLatin1String_QLatin1String() { member_compare_impl(); } +#ifdef NOT_YET_IMPLEMENTED void member_compare_QLatin1String_QByteArray_data() { member_compare_data(); } void member_compare_QLatin1String_QByteArray() { member_compare_impl(); } void member_compare_QLatin1String_const_char_star_data() { member_compare_data(); } @@ -725,6 +725,8 @@ void tst_QStringApiSymmetry::compare_data(bool hasConceptOfNullAndEmpty) ROW("0", ""); ROW("0", "1"); ROW("0", "0"); + ROW("10", "0"); + ROW("01", "1"); ROW("\xE4", "\xE4"); // ä <> ä ROW("\xE4", "\xC4"); // ä <> Ä #undef ROW From 50f865e33f1c376e639597bdb675711598637a3c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 2 Aug 2019 22:49:31 +0300 Subject: [PATCH 08/38] tst_qstringapisymmetry: fix indexOf/contains/lastIndexOf tests ... to not fold QChar tests into QString ones. This is needed for adding char16_t tests. Change-Id: I2507d7d68a39ff96cf033eadde10e383dc976dda Reviewed-by: Volker Hilsheimer --- .../tst_qstringapisymmetry.cpp | 158 ++++++++++-------- 1 file changed, 90 insertions(+), 68 deletions(-) diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp index 5ff1bcdce40..aac32c7dc38 100644 --- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -566,9 +566,10 @@ private Q_SLOTS: private: template void indexOf_impl() const; - void indexOf_data(); + void indexOf_data(bool rhsHasVariableLength = true); private Q_SLOTS: + // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar}: void indexOf_QString_QString_data() { indexOf_data(); } void indexOf_QString_QString() { indexOf_impl(); } void indexOf_QString_QLatin1String_data() { indexOf_data(); } @@ -577,6 +578,8 @@ private Q_SLOTS: void indexOf_QString_QStringRef() { indexOf_impl(); } void indexOf_QString_QStringView_data() { indexOf_data(); } void indexOf_QString_QStringView() { indexOf_impl(); } + void indexOf_QString_QChar_data() { indexOf_data(false); } + void indexOf_QString_QChar() { indexOf_impl(); } void indexOf_QLatin1String_QString_data() { indexOf_data(); } void indexOf_QLatin1String_QString() { indexOf_impl(); } @@ -586,6 +589,8 @@ private Q_SLOTS: void indexOf_QLatin1String_QStringRef() { indexOf_impl(); } void indexOf_QLatin1String_QStringView_data() { indexOf_data(); } void indexOf_QLatin1String_QStringView() { indexOf_impl(); } + void indexOf_QLatin1String_QChar_data() { indexOf_data(false); } + void indexOf_QLatin1String_QChar() { indexOf_impl(); } void indexOf_QStringRef_QString_data() { indexOf_data(); } void indexOf_QStringRef_QString() { indexOf_impl(); } @@ -595,6 +600,8 @@ private Q_SLOTS: void indexOf_QStringRef_QStringRef() { indexOf_impl(); } void indexOf_QStringRef_QStringView_data() { indexOf_data(); } void indexOf_QStringRef_QStringView() { indexOf_impl(); } + void indexOf_QStringRef_QChar_data() { indexOf_data(false); } + void indexOf_QStringRef_QChar() { indexOf_impl(); } void indexOf_QStringView_QString_data() { indexOf_data(); } void indexOf_QStringView_QString() { indexOf_impl(); } @@ -604,12 +611,15 @@ private Q_SLOTS: void indexOf_QStringView_QStringRef() { indexOf_impl(); } void indexOf_QStringView_QStringView_data() { indexOf_data(); } void indexOf_QStringView_QStringView() { indexOf_impl(); } + void indexOf_QStringView_QChar_data() { indexOf_data(false); } + void indexOf_QStringView_QChar() { indexOf_impl(); } private: template void contains_impl() const; - void contains_data(); + void contains_data(bool rhsHasVariableLength = true); private Q_SLOTS: + // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar}: void contains_QString_QString_data() { contains_data(); } void contains_QString_QString() { contains_impl(); } void contains_QString_QLatin1String_data() { contains_data(); } @@ -618,6 +628,8 @@ private Q_SLOTS: void contains_QString_QStringRef() { contains_impl(); } void contains_QString_QStringView_data() { contains_data(); } void contains_QString_QStringView() { contains_impl(); } + void contains_QString_QChar_data() { contains_data(false); } + void contains_QString_QChar() { contains_impl(); } void contains_QLatin1String_QString_data() { contains_data(); } void contains_QLatin1String_QString() { contains_impl(); } @@ -627,6 +639,8 @@ private Q_SLOTS: void contains_QLatin1String_QStringRef() { contains_impl(); } void contains_QLatin1String_QStringView_data() { contains_data(); } void contains_QLatin1String_QStringView() { contains_impl(); } + void contains_QLatin1String_QChar_data() { contains_data(false); } + void contains_QLatin1String_QChar() { contains_impl(); } void contains_QStringRef_QString_data() { contains_data(); } void contains_QStringRef_QString() { contains_impl(); } @@ -636,6 +650,8 @@ private Q_SLOTS: void contains_QStringRef_QStringRef() { contains_impl(); } void contains_QStringRef_QStringView_data() { contains_data(); } void contains_QStringRef_QStringView() { contains_impl(); } + void contains_QStringRef_QChar_data() { contains_data(false); } + void contains_QStringRef_QChar() { contains_impl(); } void contains_QStringView_QString_data() { contains_data(); } void contains_QStringView_QString() { contains_impl(); } @@ -645,12 +661,15 @@ private Q_SLOTS: void contains_QStringView_QStringRef() { contains_impl(); } void contains_QStringView_QStringView_data() { contains_data(); } void contains_QStringView_QStringView() { contains_impl(); } + void contains_QStringView_QChar_data() { contains_data(false); } + void contains_QStringView_QChar() { contains_impl(); } private: template void lastIndexOf_impl() const; - void lastIndexOf_data(); + void lastIndexOf_data(bool rhsHasVariableLength = true); private Q_SLOTS: + // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar}: void lastIndexOf_QString_QString_data() { lastIndexOf_data(); } void lastIndexOf_QString_QString() { lastIndexOf_impl(); } void lastIndexOf_QString_QLatin1String_data() { lastIndexOf_data(); } @@ -659,6 +678,8 @@ private Q_SLOTS: void lastIndexOf_QString_QStringRef() { lastIndexOf_impl(); } void lastIndexOf_QString_QStringView_data() { lastIndexOf_data(); } void lastIndexOf_QString_QStringView() { lastIndexOf_impl(); } + void lastIndexOf_QString_QChar_data() { lastIndexOf_data(false); } + void lastIndexOf_QString_QChar() { lastIndexOf_impl(); } void lastIndexOf_QLatin1String_QString_data() { lastIndexOf_data(); } void lastIndexOf_QLatin1String_QString() { lastIndexOf_impl(); } @@ -668,6 +689,8 @@ private Q_SLOTS: void lastIndexOf_QLatin1String_QStringRef() { lastIndexOf_impl(); } void lastIndexOf_QLatin1String_QStringView_data() { lastIndexOf_data(); } void lastIndexOf_QLatin1String_QStringView() { lastIndexOf_impl(); } + void lastIndexOf_QLatin1String_QChar_data() { lastIndexOf_data(false); } + void lastIndexOf_QLatin1String_QChar() { lastIndexOf_impl(); } void lastIndexOf_QStringRef_QString_data() { lastIndexOf_data(); } void lastIndexOf_QStringRef_QString() { lastIndexOf_impl(); } @@ -677,6 +700,8 @@ private Q_SLOTS: void lastIndexOf_QStringRef_QStringRef() { lastIndexOf_impl(); } void lastIndexOf_QStringRef_QStringView_data() { lastIndexOf_data(); } void lastIndexOf_QStringRef_QStringView() { lastIndexOf_impl(); } + void lastIndexOf_QStringRef_QChar_data() { lastIndexOf_data(false); } + void lastIndexOf_QStringRef_QChar() { lastIndexOf_impl(); } void lastIndexOf_QStringView_QString_data() { lastIndexOf_data(); } void lastIndexOf_QStringView_QString() { lastIndexOf_impl(); } @@ -686,6 +711,8 @@ private Q_SLOTS: void lastIndexOf_QStringView_QStringRef() { lastIndexOf_impl(); } void lastIndexOf_QStringView_QStringView_data() { lastIndexOf_data(); } void lastIndexOf_QStringView_QStringView() { lastIndexOf_impl(); } + void lastIndexOf_QStringView_QChar_data() { lastIndexOf_data(false); } + void lastIndexOf_QStringView_QChar() { lastIndexOf_impl(); } }; void tst_QStringApiSymmetry::compare_data(bool hasConceptOfNullAndEmpty) @@ -1644,7 +1671,7 @@ void tst_QStringApiSymmetry::toUcs4_impl() QCOMPARE(unicode.isEmpty(), ucs4.isEmpty()); } -void tst_QStringApiSymmetry::indexOf_data() +void tst_QStringApiSymmetry::indexOf_data(bool rhsHasVariableLength) { QTest::addColumn("haystackU16"); QTest::addColumn("haystackL1"); @@ -1657,18 +1684,20 @@ void tst_QStringApiSymmetry::indexOf_data() constexpr qsizetype zeroPos = 0; constexpr qsizetype minus1Pos = -1; - QTest::addRow("haystack: null, needle: null") << null << QLatin1String() + if (rhsHasVariableLength) { + QTest::addRow("haystack: null, needle: null") << null << QLatin1String() << null << QLatin1String() << zeroPos << zeroPos << zeroPos; - QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") + QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") << null << QLatin1String() << zeroPos << zeroPos << zeroPos; - QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") << null << QLatin1String() << zeroPos << zeroPos << zeroPos; - QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() + QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() << empty << QLatin1String("") << zeroPos << zeroPos << zeroPos; - QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") << empty << QLatin1String("") << zeroPos << zeroPos << zeroPos; - QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") + QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") << empty << QLatin1String("") << zeroPos << zeroPos << zeroPos; + } QTest::addRow("haystack: empty, needle: a") << empty << QLatin1String("") << a << QLatin1String("a") << zeroPos << minus1Pos << minus1Pos; QTest::addRow("haystack: null, needle: a") << null << QLatin1String() @@ -1700,17 +1729,19 @@ void tst_QStringApiSymmetry::indexOf_data() ROW(ABC, b, 1, -1, 1); ROW(ABC, B, 2, -1, -1); - ROW(aBc, bc, 0, -1, 1); - ROW(aBc, Bc, 0, 1, 1); - ROW(aBc, bC, 0, -1, 1); - ROW(aBc, BC, 0, -1, 1); + if (rhsHasVariableLength) { + ROW(aBc, bc, 0, -1, 1); + ROW(aBc, Bc, 0, 1, 1); + ROW(aBc, bC, 0, -1, 1); + ROW(aBc, BC, 0, -1, 1); - ROW(AbC, bc, 0, -1, 1); - ROW(AbC, Bc, 0, -1, 1); - ROW(AbC, bC, 0, 1, 1); - ROW(AbC, BC, 0, -1, 1); - ROW(AbC, BC, 1, -1, 1); - ROW(AbC, BC, 2, -1, -1); + ROW(AbC, bc, 0, -1, 1); + ROW(AbC, Bc, 0, -1, 1); + ROW(AbC, bC, 0, 1, 1); + ROW(AbC, BC, 0, -1, 1); + ROW(AbC, BC, 1, -1, 1); + ROW(AbC, BC, 2, -1, -1); + } #undef ROW } @@ -1737,13 +1768,6 @@ void tst_QStringApiSymmetry::indexOf_impl() const QCOMPARE(haystack.indexOf(needle, startpos), size_type(resultCS)); QCOMPARE(haystack.indexOf(needle, startpos, Qt::CaseSensitive), size_type(resultCS)); QCOMPARE(haystack.indexOf(needle, startpos, Qt::CaseInsensitive), size_type(resultCIS)); - - if (needle.size() == 1) - { - QCOMPARE(haystack.indexOf(needle[0], startpos), size_type(resultCS)); - QCOMPARE(haystack.indexOf(needle[0], startpos, Qt::CaseSensitive), size_type(resultCS)); - QCOMPARE(haystack.indexOf(needle[0], startpos, Qt::CaseInsensitive), size_type(resultCIS)); - } } static QString ABCDEFGHIEfGEFG = QStringLiteral("ABCDEFGHIEfGEFG"); @@ -1753,7 +1777,7 @@ static QString asd = QStringLiteral("asd"); static QString asdf = QStringLiteral("asdf"); static QString Z = QStringLiteral("Z"); -void tst_QStringApiSymmetry::contains_data() +void tst_QStringApiSymmetry::contains_data(bool rhsHasVariableLength) { QTest::addColumn("haystackU16"); QTest::addColumn("haystackL1"); @@ -1762,18 +1786,20 @@ void tst_QStringApiSymmetry::contains_data() QTest::addColumn("resultCS"); QTest::addColumn("resultCIS"); - QTest::addRow("haystack: null, needle: null") << null << QLatin1String() + if (rhsHasVariableLength) { + QTest::addRow("haystack: null, needle: null") << null << QLatin1String() << null << QLatin1String() << true << true; - QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") + QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") << null << QLatin1String() << true << true; - QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") << null << QLatin1String() << true << true; - QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() + QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() << empty << QLatin1String("") << true << true; - QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") << empty << QLatin1String("") << true << true;; - QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") + QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") << empty << QLatin1String("") << true << true; + } QTest::addRow("haystack: empty, needle: a") << empty << QLatin1String("") << a << QLatin1String("a") << false << false; QTest::addRow("haystack: null, needle: a") << null << QLatin1String() @@ -1787,8 +1813,10 @@ void tst_QStringApiSymmetry::contains_data() ROW(ABCDEFGHIEfGEFG, A, true, true); ROW(ABCDEFGHIEfGEFG, a, false, true); ROW(ABCDEFGHIEfGEFG, Z, false, false); - ROW(ABCDEFGHIEfGEFG, EFG, true, true); - ROW(ABCDEFGHIEfGEFG, efg, false, true); + if (rhsHasVariableLength) { + ROW(ABCDEFGHIEfGEFG, EFG, true, true); + ROW(ABCDEFGHIEfGEFG, efg, false, true); + } ROW(ABCDEFGHIEfGEFG, E, true, true); ROW(ABCDEFGHIEfGEFG, e, false, true); #undef ROW @@ -1813,16 +1841,9 @@ void tst_QStringApiSymmetry::contains_impl() const QCOMPARE(haystack.contains(needle), resultCS); QCOMPARE(haystack.contains(needle, Qt::CaseSensitive), resultCS); QCOMPARE(haystack.contains(needle, Qt::CaseInsensitive), resultCIS); - - if (needle.size() == 1) - { - QCOMPARE(haystack.contains(needle[0]), resultCS); - QCOMPARE(haystack.contains(needle[0], Qt::CaseSensitive), resultCS); - QCOMPARE(haystack.contains(needle[0], Qt::CaseInsensitive), resultCIS); - } } -void tst_QStringApiSymmetry::lastIndexOf_data() +void tst_QStringApiSymmetry::lastIndexOf_data(bool rhsHasVariableLength) { QTest::addColumn("haystackU16"); QTest::addColumn("haystackL1"); @@ -1835,38 +1856,43 @@ void tst_QStringApiSymmetry::lastIndexOf_data() constexpr qsizetype zeroPos = 0; constexpr qsizetype minus1Pos = -1; - QTest::addRow("haystack: null, needle: null") << null << QLatin1String() + if (rhsHasVariableLength) { + QTest::addRow("haystack: null, needle: null") << null << QLatin1String() << null << QLatin1String() << minus1Pos << minus1Pos << minus1Pos; - QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") + QTest::addRow("haystack: empty, needle: null") << empty << QLatin1String("") << null << QLatin1String() << minus1Pos << minus1Pos << minus1Pos; - QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") << null << QLatin1String() << minus1Pos << zeroPos << zeroPos; - QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() + QTest::addRow("haystack: null, needle: empty") << null << QLatin1String() << empty << QLatin1String("") << minus1Pos << minus1Pos << minus1Pos; - QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") << empty << QLatin1String("") << minus1Pos << zeroPos << zeroPos; - QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") + QTest::addRow("haystack: empty, needle: empty") << empty << QLatin1String("") << empty << QLatin1String("") << minus1Pos << minus1Pos << minus1Pos; + } QTest::addRow("haystack: empty, needle: a") << empty << QLatin1String("") << a << QLatin1String("a") << minus1Pos << minus1Pos << minus1Pos; QTest::addRow("haystack: null, needle: a") << null << QLatin1String() << a << QLatin1String("a") << minus1Pos << minus1Pos << minus1Pos; - QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + if (rhsHasVariableLength) { + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") << null << QLatin1String() << qsizetype(1) << qsizetype(1) << qsizetype(1); - QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") << empty << QLatin1String("") << qsizetype(1) << qsizetype(1) << qsizetype(1); - QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: null") << a << QLatin1String("a") << null << QLatin1String() << qsizetype(2) << minus1Pos << minus1Pos; - QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") + QTest::addRow("haystack: a, needle: empty") << a << QLatin1String("a") << empty << QLatin1String("") << qsizetype(2) << minus1Pos << minus1Pos; + } #define ROW(h, n, st, cs, cis) \ QTest::addRow("haystack: %s, needle: %s", #h, #n) << h << QLatin1String(#h) \ << n << QLatin1String(#n) \ << qsizetype(st) << qsizetype(cs) << qsizetype(cis) - ROW(asd, asdf, -1, -1, -1); + if (rhsHasVariableLength) + ROW(asd, asdf, -1, -1, -1); ROW(ABCDEFGHIEfGEFG, G, -1, 14, 14); ROW(ABCDEFGHIEfGEFG, g, -1, -1, 14); @@ -1893,13 +1919,15 @@ void tst_QStringApiSymmetry::lastIndexOf_data() ROW(ABCDEFGHIEfGEFG, A, -15, 0, 0); ROW(ABCDEFGHIEfGEFG, a, -15, -1, 0); - ROW(ABCDEFGHIEfGEFG, efg, 0, -1, -1); - ROW(ABCDEFGHIEfGEFG, efg, 15, -1, -1); - ROW(ABCDEFGHIEfGEFG, efg, -15, -1, -1); - ROW(ABCDEFGHIEfGEFG, efg, 14, -1, 12); - ROW(ABCDEFGHIEfGEFG, efg, 12, -1, 12); - ROW(ABCDEFGHIEfGEFG, efg, -12, -1, -1); - ROW(ABCDEFGHIEfGEFG, efg, 11, -1, 9); + if (rhsHasVariableLength) { + ROW(ABCDEFGHIEfGEFG, efg, 0, -1, -1); + ROW(ABCDEFGHIEfGEFG, efg, 15, -1, -1); + ROW(ABCDEFGHIEfGEFG, efg, -15, -1, -1); + ROW(ABCDEFGHIEfGEFG, efg, 14, -1, 12); + ROW(ABCDEFGHIEfGEFG, efg, 12, -1, 12); + ROW(ABCDEFGHIEfGEFG, efg, -12, -1, -1); + ROW(ABCDEFGHIEfGEFG, efg, 11, -1, 9); + } #undef ROW } @@ -1926,12 +1954,6 @@ void tst_QStringApiSymmetry::lastIndexOf_impl() const QCOMPARE(haystack.lastIndexOf(needle, startpos, Qt::CaseSensitive), size_type(resultCS)); QCOMPARE(haystack.lastIndexOf(needle, startpos, Qt::CaseInsensitive), size_type(resultCIS)); - if (needle.size() == 1) - { - QCOMPARE(haystack.lastIndexOf(needle[0], startpos), size_type(resultCS)); - QCOMPARE(haystack.lastIndexOf(needle[0], startpos, Qt::CaseSensitive), size_type(resultCS)); - QCOMPARE(haystack.lastIndexOf(needle[0], startpos, Qt::CaseInsensitive), size_type(resultCIS)); - } } QTEST_APPLESS_MAIN(tst_QStringApiSymmetry) From c58249c32774646a4be5c7504339b483d658a4da Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 31 Jul 2019 22:01:06 +0300 Subject: [PATCH 09/38] tst_qstringapisymmetry: start testing char16_t, too No surprises, as char16_t is transparently handled by QChar overloads. Ok, one surprise: we seem to have QChar <> QByteArray relational operators, but they don't work for char16_t. Probably members of QChar, so LHS implicit conversions are disabled. Didn't investigate, because it needs to be fixed at some point anyway, but that point is not now. Change-Id: I74e1c9bdd168e6480e18d7d86c1f13412e718a32 Reviewed-by: Volker Hilsheimer --- .../tst_qstringapisymmetry.cpp | 119 +++++++++++++++--- 1 file changed, 99 insertions(+), 20 deletions(-) diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp index aac32c7dc38..35546c2968d 100644 --- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -73,6 +73,8 @@ QStringList toQStringList(const Iterable &i) { MAKE_ALL(QByteArray, QChar) MAKE_ALL(QByteArray, QLatin1String) +MAKE_ALL(QByteArray, char16_t) +MAKE_ALL(char16_t, QByteArray) MAKE_ALL(const char*, QChar) @@ -100,6 +102,11 @@ static QByteArray rowName(const QByteArray &data) return result; } +# define QVERIFY_NOEXCEPT(expr) do { \ + if (!has_nothrow_compare::value) \ + QEXPECT_FAIL("", "Qt is missing a nothrow utf8-utf16 comparator", Continue); \ + QVERIFY(noexcept(expr)); } while (0) + class tst_QStringApiSymmetry : public QObject { Q_OBJECT @@ -113,9 +120,11 @@ class tst_QStringApiSymmetry : public QObject void compare_impl() const; private Q_SLOTS: - // test all combinations of {QChar, QStringRef, QString, QStringView, QLatin1String, QByteArray, const char*} + // test all combinations of {QChar, char16_t, QStringRef, QString, QStringView, QLatin1String, QByteArray, const char*} void compare_QChar_QChar_data() { compare_data(false); } void compare_QChar_QChar() { compare_impl(); } + void compare_QChar_char16_t_data() { compare_data(false); } + void compare_QChar_char16_t() { compare_impl(); } void compare_QChar_QStringRef_data() { compare_data(false); } void compare_QChar_QStringRef() { compare_impl(); } void compare_QChar_QString_data() { compare_data(false); } @@ -129,8 +138,27 @@ private Q_SLOTS: void compare_QChar_const_char_star_data() { compare_data(false); } void compare_QChar_const_char_star() { compare_impl(); } + void compare_char16_t_QChar_data() { compare_data(false); } + void compare_char16_t_QChar() { compare_impl(); } + //void compare_char16_t_char16_t_data() { compare_data(false); } + //void compare_char16_t_char16_t() { compare_impl(); } + void compare_char16_t_QStringRef_data() { compare_data(false); } + void compare_char16_t_QStringRef() { compare_impl(); } + void compare_char16_t_QString_data() { compare_data(false); } + void compare_char16_t_QString() { compare_impl(); } + void compare_char16_t_QStringView_data() { compare_data(false); } + void compare_char16_t_QStringView() { compare_impl(); } + void compare_char16_t_QLatin1String_data() { compare_data(false); } + void compare_char16_t_QLatin1String() { compare_impl(); } + void compare_char16_t_QByteArray_data() { compare_data(false); } + void compare_char16_t_QByteArray() { compare_impl(); } + //void compare_char16_t_const_char_star_data() { compare_data(false); } + //void compare_char16_t_const_char_star() { compare_impl(); } + void compare_QStringRef_QChar_data() { compare_data(false); } void compare_QStringRef_QChar() { compare_impl(); } + void compare_QStringRef_char16_t_data() { compare_data(false); } + void compare_QStringRef_char16_t() { compare_impl(); } void compare_QStringRef_QStringRef_data() { compare_data(); } void compare_QStringRef_QStringRef() { compare_impl(); } void compare_QStringRef_QString_data() { compare_data(); } @@ -146,6 +174,8 @@ private Q_SLOTS: void compare_QString_QChar_data() { compare_data(false); } void compare_QString_QChar() { compare_impl(); } + void compare_QString_char16_t_data() { compare_data(false); } + void compare_QString_char16_t() { compare_impl(); } void compare_QString_QStringRef_data() { compare_data(); } void compare_QString_QStringRef() { compare_impl(); } void compare_QString_QString_data() { compare_data(); } @@ -161,6 +191,8 @@ private Q_SLOTS: void compare_QStringView_QChar_data() { compare_data(false); } void compare_QStringView_QChar() { compare_impl(); } + void compare_QStringView_char16_t_data() { compare_data(false); } + void compare_QStringView_char16_t() { compare_impl(); } void compare_QStringView_QStringRef_data() { compare_data(); } void compare_QStringView_QStringRef() { compare_impl(); } void compare_QStringView_QString_data() { compare_data(); } @@ -178,6 +210,8 @@ private Q_SLOTS: void compare_QLatin1String_QChar_data() { compare_data(false); } void compare_QLatin1String_QChar() { compare_impl(); } + void compare_QLatin1String_char16_t_data() { compare_data(false); } + void compare_QLatin1String_char16_t() { compare_impl(); } void compare_QLatin1String_QStringRef_data() { compare_data(); } void compare_QLatin1String_QStringRef() { compare_impl(); } void compare_QLatin1String_QString_data() { compare_data(); } @@ -193,6 +227,8 @@ private Q_SLOTS: void compare_QByteArray_QChar_data() { compare_data(false); } void compare_QByteArray_QChar() { compare_impl(); } + void compare_QByteArray_char16_t_data() { compare_data(false); } + void compare_QByteArray_char16_t() { compare_impl(); } void compare_QByteArray_QStringRef_data() { compare_data(); } void compare_QByteArray_QStringRef() { compare_impl(); } void compare_QByteArray_QString_data() { compare_data(); } @@ -206,6 +242,8 @@ private Q_SLOTS: void compare_const_char_star_QChar_data() { compare_data(false); } void compare_const_char_star_QChar() { compare_impl(); } + //void compare_const_char_star_char16_t_data() { compare_data(false); } + //void compare_const_char_star_char16_t() { compare_impl(); } void compare_const_char_star_QStringRef_data() { compare_data(); } void compare_const_char_star_QStringRef() { compare_impl(); } void compare_const_char_star_QString_data() { compare_data(); } @@ -223,10 +261,12 @@ private: void member_compare_impl() const; private Q_SLOTS: - // test all combinations of {QChar, QStringRef, QString, QStringView, QLatin1String, QByteArray, const char*} + // test all combinations of {QChar, char16_t, QStringRef, QString, QStringView, QLatin1String, QByteArray, const char*} #ifdef NOT_YET_IMPLEMENTED // probably never will be - what's the point of QChar::compare(QStringView)? void member_compare_QChar_QChar_data() { member_compare_data(false); } void member_compare_QChar_QChar() { member_compare_impl(); } + void member_compare_QChar_char16_t_data() { member_compare_data(false); } + void member_compare_QChar_char16_t() { member_compare_impl(); } void member_compare_QChar_QStringRef_data() { member_compare_data(false); } void member_compare_QChar_QStringRef() { member_compare_impl(); } void member_compare_QChar_QString_data() { member_compare_data(false); } @@ -241,8 +281,12 @@ private Q_SLOTS: void member_compare_QChar_const_char_star() { member_compare_impl(); } #endif + // void member_compare_char16_t_XXX() - not possible + void member_compare_QStringRef_QChar_data() { member_compare_data(false); } void member_compare_QStringRef_QChar() { member_compare_impl(); } + void member_compare_QStringRef_char16_t_data() { member_compare_data(false); } + void member_compare_QStringRef_char16_t() { member_compare_impl(); } void member_compare_QStringRef_QStringRef_data() { member_compare_data(); } void member_compare_QStringRef_QStringRef() { member_compare_impl(); } void member_compare_QStringRef_QString_data() { member_compare_data(); } @@ -262,6 +306,8 @@ private Q_SLOTS: void member_compare_QString_QChar_data() { member_compare_data(false); } void member_compare_QString_QChar() { member_compare_impl(); } + void member_compare_QString_char16_t_data() { member_compare_data(false); } + void member_compare_QString_char16_t() { member_compare_impl(); } void member_compare_QString_QStringRef_data() { member_compare_data(); } void member_compare_QString_QStringRef() { member_compare_impl(); } void member_compare_QString_QString_data() { member_compare_data(); } @@ -277,6 +323,8 @@ private Q_SLOTS: void member_compare_QStringView_QChar_data() { member_compare_data(false); } void member_compare_QStringView_QChar() { member_compare_impl(); } + void member_compare_QStringView_char16_t_data() { member_compare_data(false); } + void member_compare_QStringView_char16_t() { member_compare_impl(); } void member_compare_QStringView_QStringRef_data() { member_compare_data(); } void member_compare_QStringView_QStringRef() { member_compare_impl(); } void member_compare_QStringView_QString_data() { member_compare_data(); } @@ -294,6 +342,8 @@ private Q_SLOTS: void member_compare_QLatin1String_QChar_data() { member_compare_data(false); } void member_compare_QLatin1String_QChar() { member_compare_impl(); } + void member_compare_QLatin1String_char16_t_data() { member_compare_data(false); } + void member_compare_QLatin1String_char16_t() { member_compare_impl(); } void member_compare_QLatin1String_QStringRef_data() { member_compare_data(); } void member_compare_QLatin1String_QStringRef() { member_compare_impl(); } void member_compare_QLatin1String_QString_data() { member_compare_data(); } @@ -310,6 +360,8 @@ private Q_SLOTS: void member_compare_QByteArray_QChar_data() { member_compare_data(false); } void member_compare_QByteArray_QChar() { member_compare_impl(); } + void member_compare_QByteArray_char16_t_data() { member_compare_data(false); } + void member_compare_QByteArray_char16_t() { member_compare_impl(); } void member_compare_QByteArray_QStringRef_data() { member_compare_data(); } void member_compare_QByteArray_QStringRef() { member_compare_impl(); } void member_compare_QByteArray_QString_data() { member_compare_data(); } @@ -330,7 +382,7 @@ private: template void endsWith_impl() const; private Q_SLOTS: - // test all combinations of {QString, QStringRef, QStringView, QLatin1String} x {QString, QStringRef, QStringView, QLatin1String, QChar}: + // test all combinations of {QString, QStringRef, QStringView, QLatin1String} x {QString, QStringRef, QStringView, QLatin1String, QChar, char16_t}: void startsWith_QString_QString_data() { startsWith_data(); } void startsWith_QString_QString() { startsWith_impl(); } void startsWith_QString_QStringRef_data() { startsWith_data(); } @@ -341,6 +393,8 @@ private Q_SLOTS: void startsWith_QString_QLatin1String() { startsWith_impl(); } void startsWith_QString_QChar_data() { startsWith_data(false); } void startsWith_QString_QChar() { startsWith_impl(); } + void startsWith_QString_char16_t_data() { startsWith_data(false); } + void startsWith_QString_char16_t() { startsWith_impl(); } void startsWith_QStringRef_QString_data() { startsWith_data(); } void startsWith_QStringRef_QString() { startsWith_impl(); } @@ -352,6 +406,8 @@ private Q_SLOTS: void startsWith_QStringRef_QLatin1String() { startsWith_impl(); } void startsWith_QStringRef_QChar_data() { startsWith_data(false); } void startsWith_QStringRef_QChar() { startsWith_impl(); } + void startsWith_QStringRef_char16_t_data() { startsWith_data(false); } + void startsWith_QStringRef_char16_t() { startsWith_impl(); } void startsWith_QStringView_QString_data() { startsWith_data(); } void startsWith_QStringView_QString() { startsWith_impl(); } @@ -363,6 +419,8 @@ private Q_SLOTS: void startsWith_QStringView_QLatin1String() { startsWith_impl(); } void startsWith_QStringView_QChar_data() { startsWith_data(false); } void startsWith_QStringView_QChar() { startsWith_impl(); } + void startsWith_QStringView_char16_t_data() { startsWith_data(false); } + void startsWith_QStringView_char16_t() { startsWith_impl(); } void startsWith_QLatin1String_QString_data() { startsWith_data(); } void startsWith_QLatin1String_QString() { startsWith_impl(); } @@ -374,6 +432,8 @@ private Q_SLOTS: void startsWith_QLatin1String_QLatin1String() { startsWith_impl(); } void startsWith_QLatin1String_QChar_data() { startsWith_data(false); } void startsWith_QLatin1String_QChar() { startsWith_impl(); } + void startsWith_QLatin1String_char16_t_data() { startsWith_data(false); } + void startsWith_QLatin1String_char16_t() { startsWith_impl(); } void endsWith_QString_QString_data() { endsWith_data(); } void endsWith_QString_QString() { endsWith_impl(); } @@ -385,6 +445,8 @@ private Q_SLOTS: void endsWith_QString_QLatin1String() { endsWith_impl(); } void endsWith_QString_QChar_data() { endsWith_data(false); } void endsWith_QString_QChar() { endsWith_impl(); } + void endsWith_QString_char16_t_data() { endsWith_data(false); } + void endsWith_QString_char16_t() { endsWith_impl(); } void endsWith_QStringRef_QString_data() { endsWith_data(); } void endsWith_QStringRef_QString() { endsWith_impl(); } @@ -396,6 +458,8 @@ private Q_SLOTS: void endsWith_QStringRef_QLatin1String() { endsWith_impl(); } void endsWith_QStringRef_QChar_data() { endsWith_data(false); } void endsWith_QStringRef_QChar() { endsWith_impl(); } + void endsWith_QStringRef_char16_t_data() { endsWith_data(false); } + void endsWith_QStringRef_char16_t() { endsWith_impl(); } void endsWith_QStringView_QString_data() { endsWith_data(); } void endsWith_QStringView_QString() { endsWith_impl(); } @@ -407,6 +471,8 @@ private Q_SLOTS: void endsWith_QStringView_QLatin1String() { endsWith_impl(); } void endsWith_QStringView_QChar_data() { endsWith_data(false); } void endsWith_QStringView_QChar() { endsWith_impl(); } + void endsWith_QStringView_char16_t_data() { endsWith_data(false); } + void endsWith_QStringView_char16_t() { endsWith_impl(); } void endsWith_QLatin1String_QString_data() { endsWith_data(); } void endsWith_QLatin1String_QString() { endsWith_impl(); } @@ -418,6 +484,8 @@ private Q_SLOTS: void endsWith_QLatin1String_QLatin1String() { endsWith_impl(); } void endsWith_QLatin1String_QChar_data() { endsWith_data(false); } void endsWith_QLatin1String_QChar() { endsWith_impl(); } + void endsWith_QLatin1String_char16_t_data() { endsWith_data(false); } + void endsWith_QLatin1String_char16_t() { endsWith_impl(); } private: void split_data(bool rhsHasVariableLength = true); @@ -569,7 +637,7 @@ private: void indexOf_data(bool rhsHasVariableLength = true); private Q_SLOTS: - // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar}: + // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar, char16_t}: void indexOf_QString_QString_data() { indexOf_data(); } void indexOf_QString_QString() { indexOf_impl(); } void indexOf_QString_QLatin1String_data() { indexOf_data(); } @@ -580,6 +648,8 @@ private Q_SLOTS: void indexOf_QString_QStringView() { indexOf_impl(); } void indexOf_QString_QChar_data() { indexOf_data(false); } void indexOf_QString_QChar() { indexOf_impl(); } + void indexOf_QString_char16_t_data() { indexOf_data(false); } + void indexOf_QString_char16_t() { indexOf_impl(); } void indexOf_QLatin1String_QString_data() { indexOf_data(); } void indexOf_QLatin1String_QString() { indexOf_impl(); } @@ -591,6 +661,8 @@ private Q_SLOTS: void indexOf_QLatin1String_QStringView() { indexOf_impl(); } void indexOf_QLatin1String_QChar_data() { indexOf_data(false); } void indexOf_QLatin1String_QChar() { indexOf_impl(); } + void indexOf_QLatin1String_char16_t_data() { indexOf_data(false); } + void indexOf_QLatin1String_char16_t() { indexOf_impl(); } void indexOf_QStringRef_QString_data() { indexOf_data(); } void indexOf_QStringRef_QString() { indexOf_impl(); } @@ -602,6 +674,8 @@ private Q_SLOTS: void indexOf_QStringRef_QStringView() { indexOf_impl(); } void indexOf_QStringRef_QChar_data() { indexOf_data(false); } void indexOf_QStringRef_QChar() { indexOf_impl(); } + void indexOf_QStringRef_char16_t_data() { indexOf_data(false); } + void indexOf_QStringRef_char16_t() { indexOf_impl(); } void indexOf_QStringView_QString_data() { indexOf_data(); } void indexOf_QStringView_QString() { indexOf_impl(); } @@ -613,13 +687,15 @@ private Q_SLOTS: void indexOf_QStringView_QStringView() { indexOf_impl(); } void indexOf_QStringView_QChar_data() { indexOf_data(false); } void indexOf_QStringView_QChar() { indexOf_impl(); } + void indexOf_QStringView_char16_t_data() { indexOf_data(false); } + void indexOf_QStringView_char16_t() { indexOf_impl(); } private: template void contains_impl() const; void contains_data(bool rhsHasVariableLength = true); private Q_SLOTS: - // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar}: + // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar, char16_t}: void contains_QString_QString_data() { contains_data(); } void contains_QString_QString() { contains_impl(); } void contains_QString_QLatin1String_data() { contains_data(); } @@ -630,6 +706,8 @@ private Q_SLOTS: void contains_QString_QStringView() { contains_impl(); } void contains_QString_QChar_data() { contains_data(false); } void contains_QString_QChar() { contains_impl(); } + void contains_QString_char16_t_data() { contains_data(false); } + void contains_QString_char16_t() { contains_impl(); } void contains_QLatin1String_QString_data() { contains_data(); } void contains_QLatin1String_QString() { contains_impl(); } @@ -641,6 +719,8 @@ private Q_SLOTS: void contains_QLatin1String_QStringView() { contains_impl(); } void contains_QLatin1String_QChar_data() { contains_data(false); } void contains_QLatin1String_QChar() { contains_impl(); } + void contains_QLatin1String_char16_t_data() { contains_data(false); } + void contains_QLatin1String_char16_t() { contains_impl(); } void contains_QStringRef_QString_data() { contains_data(); } void contains_QStringRef_QString() { contains_impl(); } @@ -652,6 +732,8 @@ private Q_SLOTS: void contains_QStringRef_QStringView() { contains_impl(); } void contains_QStringRef_QChar_data() { contains_data(false); } void contains_QStringRef_QChar() { contains_impl(); } + void contains_QStringRef_char16_t_data() { contains_data(false); } + void contains_QStringRef_char16_t() { contains_impl(); } void contains_QStringView_QString_data() { contains_data(); } void contains_QStringView_QString() { contains_impl(); } @@ -663,13 +745,15 @@ private Q_SLOTS: void contains_QStringView_QStringView() { contains_impl(); } void contains_QStringView_QChar_data() { contains_data(false); } void contains_QStringView_QChar() { contains_impl(); } + void contains_QStringView_char16_t_data() { contains_data(false); } + void contains_QStringView_char16_t() { contains_impl(); } private: template void lastIndexOf_impl() const; void lastIndexOf_data(bool rhsHasVariableLength = true); private Q_SLOTS: - // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar}: + // test all combinations of {QString, QLatin1String, QStringRef, QStringView} x {QString, QLatin1String, QStringRef, QStringView, QChar, char16_t}: void lastIndexOf_QString_QString_data() { lastIndexOf_data(); } void lastIndexOf_QString_QString() { lastIndexOf_impl(); } void lastIndexOf_QString_QLatin1String_data() { lastIndexOf_data(); } @@ -680,6 +764,8 @@ private Q_SLOTS: void lastIndexOf_QString_QStringView() { lastIndexOf_impl(); } void lastIndexOf_QString_QChar_data() { lastIndexOf_data(false); } void lastIndexOf_QString_QChar() { lastIndexOf_impl(); } + void lastIndexOf_QString_char16_t_data() { lastIndexOf_data(false); } + void lastIndexOf_QString_char16_t() { lastIndexOf_impl(); } void lastIndexOf_QLatin1String_QString_data() { lastIndexOf_data(); } void lastIndexOf_QLatin1String_QString() { lastIndexOf_impl(); } @@ -691,6 +777,8 @@ private Q_SLOTS: void lastIndexOf_QLatin1String_QStringView() { lastIndexOf_impl(); } void lastIndexOf_QLatin1String_QChar_data() { lastIndexOf_data(false); } void lastIndexOf_QLatin1String_QChar() { lastIndexOf_impl(); } + void lastIndexOf_QLatin1String_char16_t_data() { lastIndexOf_data(false); } + void lastIndexOf_QLatin1String_char16_t() { lastIndexOf_impl(); } void lastIndexOf_QStringRef_QString_data() { lastIndexOf_data(); } void lastIndexOf_QStringRef_QString() { lastIndexOf_impl(); } @@ -702,6 +790,8 @@ private Q_SLOTS: void lastIndexOf_QStringRef_QStringView() { lastIndexOf_impl(); } void lastIndexOf_QStringRef_QChar_data() { lastIndexOf_data(false); } void lastIndexOf_QStringRef_QChar() { lastIndexOf_impl(); } + void lastIndexOf_QStringRef_char16_t_data() { lastIndexOf_data(false); } + void lastIndexOf_QStringRef_char16_t() { lastIndexOf_impl(); } void lastIndexOf_QStringView_QString_data() { lastIndexOf_data(); } void lastIndexOf_QStringView_QString() { lastIndexOf_impl(); } @@ -713,6 +803,8 @@ private Q_SLOTS: void lastIndexOf_QStringView_QStringView() { lastIndexOf_impl(); } void lastIndexOf_QStringView_QChar_data() { lastIndexOf_data(false); } void lastIndexOf_QStringView_QChar() { lastIndexOf_impl(); } + void lastIndexOf_QStringView_char16_t_data() { lastIndexOf_data(false); } + void lastIndexOf_QStringView_char16_t() { lastIndexOf_impl(); } }; void tst_QStringApiSymmetry::compare_data(bool hasConceptOfNullAndEmpty) @@ -770,6 +862,7 @@ template String detached(String s) template Str make(const QStringRef &sf, QLatin1String l1, const QByteArray &u8); template <> QChar make(const QStringRef &sf, QLatin1String, const QByteArray &) { return sf.isEmpty() ? QChar() : sf.at(0); } +template <> char16_t make(const QStringRef &sf, QLatin1String, const QByteArray &) { return sf.isEmpty() ? char16_t() : char16_t{sf.at(0).unicode()}; } template <> QStringRef make(const QStringRef &sf, QLatin1String, const QByteArray &) { return sf; } template <> QString make(const QStringRef &sf, QLatin1String, const QByteArray &) { return sf.toString(); } template <> QStringView make(const QStringRef &sf, QLatin1String, const QByteArray &) { return sf; } @@ -812,15 +905,6 @@ void tst_QStringApiSymmetry::compare_impl() const const auto lhs = make(lhsUnicode, lhsLatin1, lhsU8); const auto rhs = make(rhsUnicode, rhsLatin1, rhsU8); -#ifdef Q_COMPILER_NOEXCEPT -# define QVERIFY_NOEXCEPT(expr) do { \ - if (has_nothrow_compare::value) {} else \ - QEXPECT_FAIL("", "Qt is missing a nothrow utf8-utf16 comparator", Continue); \ - QVERIFY(noexcept(expr)); } while (0) -#else -# define QVERIFY_NOEXCEPT(expr) -#endif - #define CHECK(op) \ QVERIFY_NOEXCEPT(lhs op rhs); \ do { if (caseSensitiveCompareResult op 0) { \ @@ -854,11 +938,6 @@ void tst_QStringApiSymmetry::member_compare_impl() const const auto lhs = make(lhsUnicode, lhsLatin1, lhsU8); const auto rhs = make(rhsUnicode, rhsLatin1, rhsU8); -#define QVERIFY_NOEXCEPT(expr) do { \ - if (has_nothrow_compare::value) {} else \ - QEXPECT_FAIL("", "Qt is missing a nothrow utf8-utf16 comparator", Continue); \ - QVERIFY(noexcept(expr)); } while (0) - QVERIFY_NOEXCEPT(lhs.compare(rhs, Qt::CaseSensitive)); QCOMPARE(sign(lhs.compare(rhs)), caseSensitiveCompareResult); From 16f927a4f1ffeff399351b625d73ac3cd7bccd51 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 19 Aug 2019 23:17:48 +0200 Subject: [PATCH 10/38] QLoggingRegistry: use QStringView/QLatin1String more - QLoggingRule::parse() and the ctor take pattern as QStringView - parseNextLine takes lines as QStringView and produces the pattern as QStringView for QLoggingRule - (setContent has to wait for QStringTokenizer) - QLoggingRule::pass()'s first argument is always QLatin1String, so take it as one Use chopped() more, add a std::move(). Change-Id: Ic95ea77464a9922fef452846bc6d5053bd5de56e Reviewed-by: Volker Hilsheimer --- src/corelib/io/qloggingregistry.cpp | 40 +++++++++---------- src/corelib/io/qloggingregistry_p.h | 8 ++-- .../qloggingregistry/tst_qloggingregistry.cpp | 7 +++- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index e8eb18b4c17..cacebfbda6b 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -75,7 +75,7 @@ QLoggingRule::QLoggingRule() : \internal Constructs a logging rule. */ -QLoggingRule::QLoggingRule(const QStringRef &pattern, bool enabled) : +QLoggingRule::QLoggingRule(QStringView pattern, bool enabled) : messageType(-1), enabled(enabled) { @@ -87,7 +87,7 @@ QLoggingRule::QLoggingRule(const QStringRef &pattern, bool enabled) : Return value 1 means filter passed, 0 means filter doesn't influence this category, -1 means category doesn't pass this filter. */ -int QLoggingRule::pass(const QString &cat, QtMsgType msgType) const +int QLoggingRule::pass(QLatin1String cat, QtMsgType msgType) const { // check message type if (messageType > -1 && messageType != msgType) @@ -113,7 +113,7 @@ int QLoggingRule::pass(const QString &cat, QtMsgType msgType) const return (enabled ? 1 : -1); } else if (flags == RightFilter) { // matches right - if (idx == (cat.count() - category.count())) + if (idx == (cat.size() - category.count())) return (enabled ? 1 : -1); } } @@ -129,26 +129,22 @@ int QLoggingRule::pass(const QString &cat, QtMsgType msgType) const *.io.warning RightFilter, QtWarningMsg *.core.* MidFilter */ -void QLoggingRule::parse(const QStringRef &pattern) +void QLoggingRule::parse(QStringView pattern) { - QStringRef p; + QStringView p; // strip trailing ".messagetype" if (pattern.endsWith(QLatin1String(".debug"))) { - p = QStringRef(pattern.string(), pattern.position(), - pattern.length() - 6); // strlen(".debug") + p = pattern.chopped(6); // strlen(".debug") messageType = QtDebugMsg; } else if (pattern.endsWith(QLatin1String(".info"))) { - p = QStringRef(pattern.string(), pattern.position(), - pattern.length() - 5); // strlen(".info") + p = pattern.chopped(5); // strlen(".info") messageType = QtInfoMsg; } else if (pattern.endsWith(QLatin1String(".warning"))) { - p = QStringRef(pattern.string(), pattern.position(), - pattern.length() - 8); // strlen(".warning") + p = pattern.chopped(8); // strlen(".warning") messageType = QtWarningMsg; } else if (pattern.endsWith(QLatin1String(".critical"))) { - p = QStringRef(pattern.string(), pattern.position(), - pattern.length() - 9); // strlen(".critical") + p = pattern.chopped(9); // strlen(".critical") messageType = QtCriticalMsg; } else { p = pattern; @@ -159,11 +155,11 @@ void QLoggingRule::parse(const QStringRef &pattern) } else { if (p.endsWith(QLatin1Char('*'))) { flags |= LeftFilter; - p = QStringRef(p.string(), p.position(), p.length() - 1); + p = p.chopped(1); } if (p.startsWith(QLatin1Char('*'))) { flags |= RightFilter; - p = QStringRef(p.string(), p.position() + 1, p.length() - 1); + p = p.mid(1); } if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end flags = PatternFlags(); @@ -208,7 +204,7 @@ void QLoggingSettingsParser::setContent(QTextStream &stream) _rules.clear(); QString line; while (stream.readLineInto(&line)) - parseNextLine(QStringRef(&line)); + parseNextLine(qToStringViewIgnoringNull(line)); } /*! @@ -216,7 +212,7 @@ void QLoggingSettingsParser::setContent(QTextStream &stream) Parses one line of the configuation file */ -void QLoggingSettingsParser::parseNextLine(QStringRef line) +void QLoggingSettingsParser::parseNextLine(QStringView line) { // Remove whitespace at start and end of line: line = line.trimmed(); @@ -227,7 +223,7 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) { // new section - auto sectionName = line.mid(1, line.size() - 2).trimmed(); + auto sectionName = line.mid(1).chopped(1).trimmed(); m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0; return; } @@ -240,9 +236,9 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) #if QT_CONFIG(settings) QString tmp; QSettingsPrivate::iniUnescapedKey(key.toUtf8(), 0, key.length(), tmp); - QStringRef pattern = QStringRef(&tmp, 0, tmp.length()); + QStringView pattern = qToStringViewIgnoringNull(tmp); #else - QStringRef pattern = key; + QStringView pattern = key; #endif const auto valueStr = line.mid(equalPos + 1).trimmed(); int value = -1; @@ -252,7 +248,7 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line) value = 0; QLoggingRule rule(pattern, (value == 1)); if (rule.flags != 0 && (value != -1)) - _rules.append(rule); + _rules.append(std::move(rule)); else warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); } else { @@ -460,7 +456,7 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat) debug = false; } - QString categoryName = QLatin1String(cat->categoryName()); + const auto categoryName = QLatin1String(cat->categoryName()); for (const auto &ruleSet : reg->ruleSets) { for (const auto &rule : ruleSet) { diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index 12a1f166b3a..3ac429b147a 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -67,8 +67,8 @@ class Q_AUTOTEST_EXPORT QLoggingRule { public: QLoggingRule(); - QLoggingRule(const QStringRef &pattern, bool enabled); - int pass(const QString &categoryName, QtMsgType type) const; + QLoggingRule(QStringView pattern, bool enabled); + int pass(QLatin1String categoryName, QtMsgType type) const; enum PatternFlag { FullText = 0x1, @@ -84,7 +84,7 @@ public: bool enabled; private: - void parse(const QStringRef &pattern); + void parse(QStringView pattern); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QLoggingRule::PatternFlags) @@ -101,7 +101,7 @@ public: QVector rules() const { return _rules; } private: - void parseNextLine(QStringRef line); + void parseNextLine(QStringView line); private: bool m_inRulesSection = false; diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp index a10e706ed7c..4c269822d64 100644 --- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp +++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp @@ -158,10 +158,13 @@ private slots: QFETCH(QtMsgType, msgType); QFETCH(LoggingRuleState, result); - QLoggingRule rule(QStringRef(&pattern), true); + const auto categoryL1 = category.toLatin1(); + const auto categoryL1S = QLatin1String(categoryL1); + + QLoggingRule rule(pattern, true); LoggingRuleState state = Invalid; if (rule.flags != 0) { - switch (rule.pass(category, msgType)) { + switch (rule.pass(categoryL1S, msgType)) { case -1: QFAIL("Shoudn't happen, we set pattern to true"); break; case 0: state = NoMatch; break; case 1: state = Match; break; From a539e53eb0acadc6759d87378e27524718db4a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 11 Feb 2020 12:35:52 +0100 Subject: [PATCH 11/38] Add 'pass' test to testlib selftests Change-Id: I858cd5e6ef7ad1064166efb7325c62065d46eb27 Reviewed-by: Fawzi Mohamed --- .../testlib/selftests/expected_pass.junitxml | 14 +++++ .../testlib/selftests/expected_pass.lightxml | 26 +++++++++ .../auto/testlib/selftests/expected_pass.tap | 11 ++++ .../testlib/selftests/expected_pass.teamcity | 12 ++++ .../auto/testlib/selftests/expected_pass.txt | 9 +++ .../auto/testlib/selftests/expected_pass.xml | 29 ++++++++++ tests/auto/testlib/selftests/pass/pass.pro | 9 +++ .../auto/testlib/selftests/pass/tst_pass.cpp | 56 +++++++++++++++++++ tests/auto/testlib/selftests/selftests.pri | 1 + .../auto/testlib/selftests/tst_selftests.cpp | 5 +- 10 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 tests/auto/testlib/selftests/expected_pass.junitxml create mode 100644 tests/auto/testlib/selftests/expected_pass.lightxml create mode 100644 tests/auto/testlib/selftests/expected_pass.tap create mode 100644 tests/auto/testlib/selftests/expected_pass.teamcity create mode 100644 tests/auto/testlib/selftests/expected_pass.txt create mode 100644 tests/auto/testlib/selftests/expected_pass.xml create mode 100644 tests/auto/testlib/selftests/pass/pass.pro create mode 100644 tests/auto/testlib/selftests/pass/tst_pass.cpp diff --git a/tests/auto/testlib/selftests/expected_pass.junitxml b/tests/auto/testlib/selftests/expected_pass.junitxml new file mode 100644 index 00000000000..b148593bd0f --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pass.junitxml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_pass.lightxml b/tests/auto/testlib/selftests/expected_pass.lightxml new file mode 100644 index 00000000000..4d344e93cf0 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pass.lightxml @@ -0,0 +1,26 @@ + + @INSERT_QT_VERSION_HERE@ + + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_pass.tap b/tests/auto/testlib/selftests/expected_pass.tap new file mode 100644 index 00000000000..a01755dc25d --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pass.tap @@ -0,0 +1,11 @@ +TAP version 13 +# tst_Pass +ok 1 - initTestCase() +ok 2 - testNumber1() +ok 3 - testNumber2() +ok 4 - testNumber3() +ok 5 - cleanupTestCase() +1..5 +# tests 5 +# pass 5 +# fail 0 diff --git a/tests/auto/testlib/selftests/expected_pass.teamcity b/tests/auto/testlib/selftests/expected_pass.teamcity new file mode 100644 index 00000000000..11dc666fb75 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pass.teamcity @@ -0,0 +1,12 @@ +##teamcity[testSuiteStarted name='tst_Pass' flowId='tst_Pass'] +##teamcity[testStarted name='initTestCase()' flowId='tst_Pass'] +##teamcity[testFinished name='initTestCase()' flowId='tst_Pass'] +##teamcity[testStarted name='testNumber1()' flowId='tst_Pass'] +##teamcity[testFinished name='testNumber1()' flowId='tst_Pass'] +##teamcity[testStarted name='testNumber2()' flowId='tst_Pass'] +##teamcity[testFinished name='testNumber2()' flowId='tst_Pass'] +##teamcity[testStarted name='testNumber3()' flowId='tst_Pass'] +##teamcity[testFinished name='testNumber3()' flowId='tst_Pass'] +##teamcity[testStarted name='cleanupTestCase()' flowId='tst_Pass'] +##teamcity[testFinished name='cleanupTestCase()' flowId='tst_Pass'] +##teamcity[testSuiteFinished name='tst_Pass' flowId='tst_Pass'] diff --git a/tests/auto/testlib/selftests/expected_pass.txt b/tests/auto/testlib/selftests/expected_pass.txt new file mode 100644 index 00000000000..0d7265f9707 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pass.txt @@ -0,0 +1,9 @@ +********* Start testing of tst_Pass ********* +Config: Using QtTest library +PASS : tst_Pass::initTestCase() +PASS : tst_Pass::testNumber1() +PASS : tst_Pass::testNumber2() +PASS : tst_Pass::testNumber3() +PASS : tst_Pass::cleanupTestCase() +Totals: 5 passed, 0 failed, 0 skipped, 0 blacklisted, 0ms +********* Finished testing of tst_Pass ********* diff --git a/tests/auto/testlib/selftests/expected_pass.xml b/tests/auto/testlib/selftests/expected_pass.xml new file mode 100644 index 00000000000..b221cb5411e --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pass.xml @@ -0,0 +1,29 @@ + + + + @INSERT_QT_VERSION_HERE@ + + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/pass/pass.pro b/tests/auto/testlib/selftests/pass/pass.pro new file mode 100644 index 00000000000..dd00a1c744a --- /dev/null +++ b/tests/auto/testlib/selftests/pass/pass.pro @@ -0,0 +1,9 @@ +SOURCES += tst_pass.cpp +QT = core testlib + +macos:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = pass + +include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/selftests/pass/tst_pass.cpp b/tests/auto/testlib/selftests/pass/tst_pass.cpp new file mode 100644 index 00000000000..6fa5f6a2099 --- /dev/null +++ b/tests/auto/testlib/selftests/pass/tst_pass.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class tst_Pass: public QObject +{ + Q_OBJECT + +private slots: + void testNumber1() const; + void testNumber2() const; + void testNumber3() const; +}; + +void tst_Pass::testNumber1() const +{ +} + +void tst_Pass::testNumber2() const +{ +} + +void tst_Pass::testNumber3() const +{ +} + +QTEST_MAIN(tst_Pass) + +#include "tst_pass.moc" diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 2cad0b7e17c..b124b219812 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -31,6 +31,7 @@ SUBPROGRAMS = \ longstring \ maxwarnings \ multiexec \ + pass \ pairdiagnostics \ printdatatags \ printdatatagswithglobaltags \ diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index be64752ceb5..cab6589984f 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -422,9 +422,9 @@ void tst_Selftests::initTestCase() { QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString())); //Detect the location of the sub programs - QString subProgram = QLatin1String("float/float"); + QString subProgram = QLatin1String("pass/pass"); #if defined(Q_OS_WIN) - subProgram = QLatin1String("float/float.exe"); + subProgram = QLatin1String("pass/pass.exe"); #endif QString testdataDir = QFINDTESTDATA(subProgram); if (testdataDir.lastIndexOf(subProgram) > 0) @@ -487,6 +487,7 @@ void tst_Selftests::runSubTest_data() << "longstring" << "maxwarnings" << "multiexec" + << "pass" << "pairdiagnostics" << "printdatatags" << "printdatatagswithglobaltags" From 66e905b1c35b5911e6ab7555720045b3029f556a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 5 Mar 2020 14:17:59 +0100 Subject: [PATCH 12/38] Fix deprecation warning in QProcess::execute(QString) Implement this method in terms of splitCommand and QProcess::execute(QString, QStringList). Change-Id: I1fe78fb53d8b6b34a8796f9fbda380a98a840c99 Reviewed-by: Volker Hilsheimer --- src/corelib/io/qprocess.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index df8b306a8d2..9400662b97c 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -2519,12 +2519,10 @@ int QProcess::execute(const QString &program, const QStringList &arguments) */ int QProcess::execute(const QString &command) { - QProcess process; - process.setProcessChannelMode(ForwardedChannels); - process.start(command); - if (!process.waitForFinished(-1) || process.error() == FailedToStart) + QStringList args = splitCommand(command); + if (args.isEmpty()) return -2; - return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1; + return execute(args.takeFirst(), args); } /*! From e1e0862990dbe00462f7faa02845a640a3d84155 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 5 Mar 2020 14:23:48 +0100 Subject: [PATCH 13/38] Fix deprecation warning in QGenericUnixServices Do not use the deprecated method QProcess::start(QString) anymore. Change-Id: I09eae2c8a1dbb53fd2de004e5030da9bb3c07b14 Reviewed-by: Volker Hilsheimer --- .../services/genericunix/qgenericunixservices.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 734bdcaf757..8e9923e208a 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -166,7 +166,8 @@ static inline bool launch(const QString &launcher, const QUrl &url) #if !QT_CONFIG(process) const bool ok = ::system(qPrintable(command + QLatin1String(" &"))); #else - const bool ok = QProcess::startDetached(command); + QStringList args = QProcess::splitCommand(command); + const bool ok = !args.isEmpty() && QProcess::startDetached(args.takeFirst(), args); #endif if (!ok) qWarning("Launch failed (%s)", qPrintable(command)); From c3ae30085e4047ee7d5a945c36e2055c2de5197d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 3 Mar 2020 14:24:11 +0100 Subject: [PATCH 14/38] rhi: Add support for arrays of combined image samplers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces a new QRhiShaderResourceBinding function that takes an array of texture-sampler pairs. The existing function is also available and is equivalent to calling the array-based version with array size 1. It is important to note that for Metal one needs MSL 2.0 for array of textures, so qsb needs --msl 20 instead of --msl 12 for such shaders. Comes with an autotest, and also updates all .qsb files for said test with the latest shadertools. Task-number: QTBUG-82624 Change-Id: Ibc1973aae826836f16d842c41d6c8403fd7ff876 Reviewed-by: Christian Strømme --- src/gui/rhi/qrhi.cpp | 66 ++++++-- src/gui/rhi/qrhi_p.h | 11 +- src/gui/rhi/qrhid3d11.cpp | 92 ++++++----- src/gui/rhi/qrhid3d11_p_p.h | 11 +- src/gui/rhi/qrhigles2.cpp | 59 ++++---- src/gui/rhi/qrhimetal.mm | 112 ++++++++------ src/gui/rhi/qrhimetal_p_p.h | 11 +- src/gui/rhi/qrhivulkan.cpp | 83 +++++----- src/gui/rhi/qrhivulkan_p_p.h | 11 +- tests/auto/gui/rhi/qrhi/data/buildshaders.bat | 1 + tests/auto/gui/rhi/qrhi/data/simple.frag.qsb | Bin 730 -> 740 bytes tests/auto/gui/rhi/qrhi/data/simple.vert.qsb | Bin 791 -> 786 bytes .../gui/rhi/qrhi/data/simpletextured.frag.qsb | Bin 1208 -> 1206 bytes .../gui/rhi/qrhi/data/simpletextured.vert.qsb | Bin 964 -> 983 bytes .../rhi/qrhi/data/simpletextured_array.frag | 17 +++ .../qrhi/data/simpletextured_array.frag.qsb | Bin 0 -> 1693 bytes .../auto/gui/rhi/qrhi/data/textured.frag.qsb | Bin 1574 -> 1590 bytes .../auto/gui/rhi/qrhi/data/textured.vert.qsb | Bin 1342 -> 1368 bytes tests/auto/gui/rhi/qrhi/tst_qrhi.cpp | 143 ++++++++++++++++++ 19 files changed, 450 insertions(+), 167 deletions(-) create mode 100644 tests/auto/gui/rhi/qrhi/data/simpletextured_array.frag create mode 100644 tests/auto/gui/rhi/qrhi/data/simpletextured_array.frag.qsb diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index c805e23ad07..83c1e8eaa27 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2885,16 +2885,57 @@ QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBufferWithDynamicOff \return a shader resource binding for the given binding number, pipeline stages, texture, and sampler specified by \a binding, \a stage, \a tex, \a sampler. + + \note This function is equivalent to calling sampledTextures() with a + \c count of 1. + + \sa sampledTextures() */ QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTexture( int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler) { + const TextureAndSampler texSampler = { tex, sampler }; + return sampledTextures(binding, stage, 1, &texSampler); +} + +/*! + \return a shader resource binding for the given binding number, pipeline + stages, and the array of texture-sampler pairs specified by \a binding, \a + stage, \a count, and \a texSamplers. + + \note \a count must be at least 1, and not larger than 16. + + \note When \a count is 1, this function is equivalent to sampledTexture(). + + This function is relevant when arrays of combined image samplers are + involved. For example, in GLSL \c{layout(binding = 5) uniform sampler2D + shadowMaps[8];} declares an array of combined image samplers. The + application is then expected provide a QRhiShaderResourceBinding for + binding point 5, set up by calling this function with \a count set to 8 and + a valid texture and sampler for each element of the array. + + \warning All elements of the array must be specified. With the above + example, the only valid, portable approach is calling this function with a + \a count of 8. Additionally, all QRhiTexture and QRhiSampler instances must + be valid, meaning nullptr is not an accepted value. This is due to some of + the underlying APIs, such as, Vulkan, that require a valid image and + sampler object for each element in descriptor arrays. Applications are + advised to provide "dummy" samplers and textures if some array elements are + not relevant (due to not being accessed in the shader). + + \sa sampledTexture() + */ +QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTextures( + int binding, StageFlags stage, int count, const TextureAndSampler *texSamplers) +{ + Q_ASSERT(count >= 1 && count <= Data::MAX_TEX_SAMPLER_ARRAY_SIZE); QRhiShaderResourceBinding b; b.d.binding = binding; b.d.stage = stage; b.d.type = SampledTexture; - b.d.u.stex.tex = tex; - b.d.u.stex.sampler = sampler; + b.d.u.stex.count = count; + for (int i = 0; i < count; ++i) + b.d.u.stex.texSamplers[i] = texSamplers[i]; return b; } @@ -3084,10 +3125,14 @@ bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::SampledTexture: - if (da->u.stex.tex != db->u.stex.tex - || da->u.stex.sampler != db->u.stex.sampler) - { + if (da->u.stex.count != db->u.stex.count) return false; + for (int i = 0; i < da->u.stex.count; ++i) { + if (da->u.stex.texSamplers[i].tex != db->u.stex.texSamplers[i].tex + || da->u.stex.texSamplers[i].sampler != db->u.stex.texSamplers[i].sampler) + { + return false; + } } break; case QRhiShaderResourceBinding::ImageLoad: @@ -3162,10 +3207,13 @@ QDebug operator<<(QDebug dbg, const QRhiShaderResourceBinding &b) << ')'; break; case QRhiShaderResourceBinding::SampledTexture: - dbg.nospace() << " SampledTexture(" - << "texture=" << d->u.stex.tex - << " sampler=" << d->u.stex.sampler - << ')'; + dbg.nospace() << " SampledTextures(" + << "count=" << d->u.stex.count; + for (int i = 0; i < d->u.stex.count; ++i) { + dbg.nospace() << " texture=" << d->u.stex.texSamplers[i].tex + << " sampler=" << d->u.stex.texSamplers[i].sampler; + } + dbg.nospace() << ')'; break; case QRhiShaderResourceBinding::ImageLoad: dbg.nospace() << " ImageLoad(" diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 17c911a5ff2..9d906d7bbd8 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -348,6 +348,12 @@ public: static QRhiShaderResourceBinding sampledTexture(int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler); + struct TextureAndSampler { + QRhiTexture *tex; + QRhiSampler *sampler; + }; + static QRhiShaderResourceBinding sampledTextures(int binding, StageFlags stage, int count, const TextureAndSampler *texSamplers); + static QRhiShaderResourceBinding imageLoad(int binding, StageFlags stage, QRhiTexture *tex, int level); static QRhiShaderResourceBinding imageStore(int binding, StageFlags stage, QRhiTexture *tex, int level); static QRhiShaderResourceBinding imageLoadStore(int binding, StageFlags stage, QRhiTexture *tex, int level); @@ -370,9 +376,10 @@ public: int maybeSize; bool hasDynamicOffset; }; + static const int MAX_TEX_SAMPLER_ARRAY_SIZE = 16; struct SampledTextureData { - QRhiTexture *tex; - QRhiSampler *sampler; + int count; + TextureAndSampler texSamplers[MAX_TEX_SAMPLER_ARRAY_SIZE]; }; struct StorageImageData { QRhiTexture *tex; diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 7b583e6fd2a..7c53925aca1 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -627,18 +627,25 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind break; case QRhiShaderResourceBinding::SampledTexture: { - QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.stex.tex); - QD3D11Sampler *samplerD = QRHI_RES(QD3D11Sampler, b->u.stex.sampler); - if (texD->generation != bd.stex.texGeneration - || texD->m_id != bd.stex.texId - || samplerD->generation != bd.stex.samplerGeneration - || samplerD->m_id != bd.stex.samplerId) - { + const QRhiShaderResourceBinding::Data::SampledTextureData *data = &b->u.stex; + if (bd.stex.count != data->count) { + bd.stex.count = data->count; srbUpdate = true; - bd.stex.texId = texD->m_id; - bd.stex.texGeneration = texD->generation; - bd.stex.samplerId = samplerD->m_id; - bd.stex.samplerGeneration = samplerD->generation; + } + for (int elem = 0; elem < data->count; ++elem) { + QD3D11Texture *texD = QRHI_RES(QD3D11Texture, data->texSamplers[elem].tex); + QD3D11Sampler *samplerD = QRHI_RES(QD3D11Sampler, data->texSamplers[elem].sampler); + if (texD->generation != bd.stex.d[elem].texGeneration + || texD->m_id != bd.stex.d[elem].texId + || samplerD->generation != bd.stex.d[elem].samplerGeneration + || samplerD->m_id != bd.stex.d[elem].samplerId) + { + srbUpdate = true; + bd.stex.d[elem].texId = texD->m_id; + bd.stex.d[elem].texGeneration = texD->generation; + bd.stex.d[elem].samplerId = samplerD->m_id; + bd.stex.d[elem].samplerGeneration = samplerD->generation; + } } } break; @@ -1894,31 +1901,38 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD, break; case QRhiShaderResourceBinding::SampledTexture: { - QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.stex.tex); - QD3D11Sampler *samplerD = QRHI_RES(QD3D11Sampler, b->u.stex.sampler); - bd.stex.texId = texD->m_id; - bd.stex.texGeneration = texD->generation; - bd.stex.samplerId = samplerD->m_id; - bd.stex.samplerGeneration = samplerD->generation; - if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { - QPair nativeBinding = mapBinding(b->binding, RBM_VERTEX, nativeResourceBindingMaps); - if (nativeBinding.first >= 0 && nativeBinding.second >= 0) { - res[RBM_VERTEX].textures.append({ nativeBinding.first, texD->srv }); - res[RBM_VERTEX].samplers.append({ nativeBinding.second, samplerD->samplerState }); + const QRhiShaderResourceBinding::Data::SampledTextureData *data = &b->u.stex; + bd.stex.count = data->count; + const QPair nativeBindingVert = mapBinding(b->binding, RBM_VERTEX, nativeResourceBindingMaps); + const QPair nativeBindingFrag = mapBinding(b->binding, RBM_FRAGMENT, nativeResourceBindingMaps); + const QPair nativeBindingComp = mapBinding(b->binding, RBM_COMPUTE, nativeResourceBindingMaps); + // if SPIR-V binding b is mapped to tN and sN in HLSL, and it + // is an array, then it will use tN, tN+1, tN+2, ..., and sN, + // sN+1, sN+2, ... + for (int elem = 0; elem < data->count; ++elem) { + QD3D11Texture *texD = QRHI_RES(QD3D11Texture, data->texSamplers[elem].tex); + QD3D11Sampler *samplerD = QRHI_RES(QD3D11Sampler, data->texSamplers[elem].sampler); + bd.stex.d[elem].texId = texD->m_id; + bd.stex.d[elem].texGeneration = texD->generation; + bd.stex.d[elem].samplerId = samplerD->m_id; + bd.stex.d[elem].samplerGeneration = samplerD->generation; + if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { + if (nativeBindingVert.first >= 0 && nativeBindingVert.second >= 0) { + res[RBM_VERTEX].textures.append({ nativeBindingVert.first + elem, texD->srv }); + res[RBM_VERTEX].samplers.append({ nativeBindingVert.second + elem, samplerD->samplerState }); + } } - } - if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { - QPair nativeBinding = mapBinding(b->binding, RBM_FRAGMENT, nativeResourceBindingMaps); - if (nativeBinding.first >= 0 && nativeBinding.second >= 0) { - res[RBM_FRAGMENT].textures.append({ nativeBinding.first, texD->srv }); - res[RBM_FRAGMENT].samplers.append({ nativeBinding.second, samplerD->samplerState }); + if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { + if (nativeBindingFrag.first >= 0 && nativeBindingFrag.second >= 0) { + res[RBM_FRAGMENT].textures.append({ nativeBindingFrag.first + elem, texD->srv }); + res[RBM_FRAGMENT].samplers.append({ nativeBindingFrag.second + elem, samplerD->samplerState }); + } } - } - if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { - QPair nativeBinding = mapBinding(b->binding, RBM_COMPUTE, nativeResourceBindingMaps); - if (nativeBinding.first >= 0 && nativeBinding.second >= 0) { - res[RBM_COMPUTE].textures.append({ nativeBinding.first, texD->srv }); - res[RBM_COMPUTE].samplers.append({ nativeBinding.second, samplerD->samplerState }); + if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { + if (nativeBindingComp.first >= 0 && nativeBindingComp.second >= 0) { + res[RBM_COMPUTE].textures.append({ nativeBindingComp.first + elem, texD->srv }); + res[RBM_COMPUTE].samplers.append({ nativeBindingComp.second + elem, samplerD->samplerState }); + } } } } @@ -3529,11 +3543,15 @@ static pD3DCompile resolveD3DCompile() static QByteArray compileHlslShaderSource(const QShader &shader, QShader::Variant shaderVariant, QString *error, QShaderKey *usedShaderKey) { - QShaderCode dxbc = shader.shader({ QShader::DxbcShader, 50, shaderVariant }); - if (!dxbc.shader().isEmpty()) + QShaderKey key = { QShader::DxbcShader, 50, shaderVariant }; + QShaderCode dxbc = shader.shader(key); + if (!dxbc.shader().isEmpty()) { + if (usedShaderKey) + *usedShaderKey = key; return dxbc.shader(); + } - const QShaderKey key = { QShader::HlslShader, 50, shaderVariant }; + key = { QShader::HlslShader, 50, shaderVariant }; QShaderCode hlslSource = shader.shader(key); if (hlslSource.shader().isEmpty()) { qWarning() << "No HLSL (shader model 5.0) code found in baked shader" << shader; diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index f749b612b50..33412b80110 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -210,10 +210,13 @@ struct QD3D11ShaderResourceBindings : public QRhiShaderResourceBindings uint generation; }; struct BoundSampledTextureData { - quint64 texId; - uint texGeneration; - quint64 samplerId; - uint samplerGeneration; + int count; + struct { + quint64 texId; + uint texGeneration; + quint64 samplerId; + uint samplerGeneration; + } d[QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE]; }; struct BoundStorageImageData { quint64 id; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index feeb65137ae..3ba83464d2c 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -919,10 +919,12 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind hasDynamicOffsetInSrb = true; break; case QRhiShaderResourceBinding::SampledTexture: - trackedRegisterTexture(&passResTracker, - QRHI_RES(QGles2Texture, b->u.stex.tex), - QRhiPassResourceTracker::TexSample, - QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage)); + for (int elem = 0; elem < b->u.stex.count; ++elem) { + trackedRegisterTexture(&passResTracker, + QRHI_RES(QGles2Texture, b->u.stex.texSamplers[elem].tex), + QRhiPassResourceTracker::TexSample, + QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage)); + } break; case QRhiShaderResourceBinding::ImageLoad: case QRhiShaderResourceBinding::ImageStore: @@ -2574,36 +2576,37 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC break; case QRhiShaderResourceBinding::SampledTexture: { - QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.stex.tex); - QGles2Sampler *samplerD = QRHI_RES(QGles2Sampler, b->u.stex.sampler); QVector &samplers(maybeGraphicsPs ? QRHI_RES(QGles2GraphicsPipeline, maybeGraphicsPs)->samplers : QRHI_RES(QGles2ComputePipeline, maybeComputePs)->samplers); + for (int elem = 0; elem < b->u.stex.count; ++elem) { + QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.stex.texSamplers[elem].tex); + QGles2Sampler *samplerD = QRHI_RES(QGles2Sampler, b->u.stex.texSamplers[elem].sampler); + for (QGles2SamplerDescription &sampler : samplers) { + if (sampler.binding == b->binding) { + f->glActiveTexture(GL_TEXTURE0 + uint(texUnit)); + f->glBindTexture(texD->target, texD->texture); - for (QGles2SamplerDescription &sampler : samplers) { - if (sampler.binding == b->binding) { - f->glActiveTexture(GL_TEXTURE0 + uint(texUnit)); - f->glBindTexture(texD->target, texD->texture); - - if (texD->samplerState != samplerD->d) { - f->glTexParameteri(texD->target, GL_TEXTURE_MIN_FILTER, GLint(samplerD->d.glminfilter)); - f->glTexParameteri(texD->target, GL_TEXTURE_MAG_FILTER, GLint(samplerD->d.glmagfilter)); - f->glTexParameteri(texD->target, GL_TEXTURE_WRAP_S, GLint(samplerD->d.glwraps)); - f->glTexParameteri(texD->target, GL_TEXTURE_WRAP_T, GLint(samplerD->d.glwrapt)); - // 3D textures not supported by GLES 2.0 or by us atm... - //f->glTexParameteri(texD->target, GL_TEXTURE_WRAP_R, samplerD->d.glwrapr); - if (caps.textureCompareMode) { - if (samplerD->d.gltexcomparefunc != GL_NEVER) { - f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_FUNC, GLint(samplerD->d.gltexcomparefunc)); - } else { - f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_MODE, GL_NONE); + if (texD->samplerState != samplerD->d) { + f->glTexParameteri(texD->target, GL_TEXTURE_MIN_FILTER, GLint(samplerD->d.glminfilter)); + f->glTexParameteri(texD->target, GL_TEXTURE_MAG_FILTER, GLint(samplerD->d.glmagfilter)); + f->glTexParameteri(texD->target, GL_TEXTURE_WRAP_S, GLint(samplerD->d.glwraps)); + f->glTexParameteri(texD->target, GL_TEXTURE_WRAP_T, GLint(samplerD->d.glwrapt)); + // 3D textures not supported by GLES 2.0 or by us atm... + //f->glTexParameteri(texD->target, GL_TEXTURE_WRAP_R, samplerD->d.glwrapr); + if (caps.textureCompareMode) { + if (samplerD->d.gltexcomparefunc != GL_NEVER) { + f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_FUNC, GLint(samplerD->d.gltexcomparefunc)); + } else { + f->glTexParameteri(texD->target, GL_TEXTURE_COMPARE_MODE, GL_NONE); + } } + texD->samplerState = samplerD->d; } - texD->samplerState = samplerD->d; - } - f->glUniform1i(sampler.glslLocation, texUnit); - ++texUnit; + f->glUniform1i(sampler.glslLocation + elem, texUnit); + ++texUnit; + } } } } diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 314c58b0b74..0806c8a0521 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -748,30 +748,33 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD break; case QRhiShaderResourceBinding::SampledTexture: { - QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.stex.tex); - QMetalSampler *samplerD = QRHI_RES(QMetalSampler, b->u.stex.sampler); - if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { - const int nativeBindingTexture = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture); - const int nativeBindingSampler = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Sampler); - if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { - res[VERTEX].textures.append({ nativeBindingTexture, texD->d->tex }); - res[VERTEX].samplers.append({ nativeBindingSampler, samplerD->d->samplerState }); + const QRhiShaderResourceBinding::Data::SampledTextureData *data = &b->u.stex; + for (int elem = 0; elem < data->count; ++elem) { + QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.stex.texSamplers[elem].tex); + QMetalSampler *samplerD = QRHI_RES(QMetalSampler, b->u.stex.texSamplers[elem].sampler); + if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { + const int nativeBindingTexture = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[VERTEX].textures.append({ nativeBindingTexture + elem, texD->d->tex }); + res[VERTEX].samplers.append({ nativeBindingSampler + elem, samplerD->d->samplerState }); + } } - } - if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { - const int nativeBindingTexture = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture); - const int nativeBindingSampler = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Sampler); - if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { - res[FRAGMENT].textures.append({ nativeBindingTexture, texD->d->tex }); - res[FRAGMENT].samplers.append({ nativeBindingSampler, samplerD->d->samplerState }); + if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { + const int nativeBindingTexture = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[FRAGMENT].textures.append({ nativeBindingTexture + elem, texD->d->tex }); + res[FRAGMENT].samplers.append({ nativeBindingSampler + elem, samplerD->d->samplerState }); + } } - } - if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { - const int nativeBindingTexture = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture); - const int nativeBindingSampler = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Sampler); - if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { - res[COMPUTE].textures.append({ nativeBindingTexture, texD->d->tex }); - res[COMPUTE].samplers.append({ nativeBindingSampler, samplerD->d->samplerState }); + if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { + const int nativeBindingTexture = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[COMPUTE].textures.append({ nativeBindingTexture + elem, texD->d->tex }); + res[COMPUTE].samplers.append({ nativeBindingSampler + elem, samplerD->d->samplerState }); + } } } } @@ -1020,21 +1023,28 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind break; case QRhiShaderResourceBinding::SampledTexture: { - QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.stex.tex); - QMetalSampler *samplerD = QRHI_RES(QMetalSampler, b->u.stex.sampler); - if (texD->generation != bd.stex.texGeneration - || texD->m_id != bd.stex.texId - || samplerD->generation != bd.stex.samplerGeneration - || samplerD->m_id != bd.stex.samplerId) - { + const QRhiShaderResourceBinding::Data::SampledTextureData *data = &b->u.stex; + if (bd.stex.count != data->count) { + bd.stex.count = data->count; resNeedsRebind = true; - bd.stex.texId = texD->m_id; - bd.stex.texGeneration = texD->generation; - bd.stex.samplerId = samplerD->m_id; - bd.stex.samplerGeneration = samplerD->generation; } - texD->lastActiveFrameSlot = currentFrameSlot; - samplerD->lastActiveFrameSlot = currentFrameSlot; + for (int elem = 0; elem < data->count; ++elem) { + QMetalTexture *texD = QRHI_RES(QMetalTexture, data->texSamplers[elem].tex); + QMetalSampler *samplerD = QRHI_RES(QMetalSampler, data->texSamplers[elem].sampler); + if (texD->generation != bd.stex.d[elem].texGeneration + || texD->m_id != bd.stex.d[elem].texId + || samplerD->generation != bd.stex.d[elem].samplerGeneration + || samplerD->m_id != bd.stex.d[elem].samplerId) + { + resNeedsRebind = true; + bd.stex.d[elem].texId = texD->m_id; + bd.stex.d[elem].texGeneration = texD->generation; + bd.stex.d[elem].samplerId = samplerD->m_id; + bd.stex.d[elem].samplerGeneration = samplerD->generation; + } + texD->lastActiveFrameSlot = currentFrameSlot; + samplerD->lastActiveFrameSlot = currentFrameSlot; + } } break; case QRhiShaderResourceBinding::ImageLoad: @@ -2981,12 +2991,16 @@ bool QMetalShaderResourceBindings::build() break; case QRhiShaderResourceBinding::SampledTexture: { - QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.stex.tex); - QMetalSampler *samplerD = QRHI_RES(QMetalSampler, b->u.stex.sampler); - bd.stex.texId = texD->m_id; - bd.stex.texGeneration = texD->generation; - bd.stex.samplerId = samplerD->m_id; - bd.stex.samplerGeneration = samplerD->generation; + const QRhiShaderResourceBinding::Data::SampledTextureData *data = &b->u.stex; + bd.stex.count = data->count; + for (int elem = 0; elem < data->count; ++elem) { + QMetalTexture *texD = QRHI_RES(QMetalTexture, data->texSamplers[elem].tex); + QMetalSampler *samplerD = QRHI_RES(QMetalSampler, data->texSamplers[elem].sampler); + bd.stex.d[elem].texId = texD->m_id; + bd.stex.d[elem].texGeneration = texD->generation; + bd.stex.d[elem].samplerId = samplerD->m_id; + bd.stex.d[elem].samplerGeneration = samplerD->generation; + } } break; case QRhiShaderResourceBinding::ImageLoad: @@ -3241,8 +3255,12 @@ static inline MTLCullMode toMetalCullMode(QRhiGraphicsPipeline::CullMode c) id QRhiMetalData::createMetalLib(const QShader &shader, QShader::Variant shaderVariant, QString *error, QByteArray *entryPoint, QShaderKey *activeKey) { - QShaderKey key = { QShader::MetalLibShader, 12, shaderVariant }; + QShaderKey key = { QShader::MetalLibShader, 20, shaderVariant }; QShaderCode mtllib = shader.shader(key); + if (mtllib.shader().isEmpty()) { + key.setSourceVersion(12); + mtllib = shader.shader(key); + } if (!mtllib.shader().isEmpty()) { dispatch_data_t data = dispatch_data_create(mtllib.shader().constData(), size_t(mtllib.shader().size()), @@ -3261,16 +3279,20 @@ id QRhiMetalData::createMetalLib(const QShader &shader, QShader::Var } } - key = { QShader::MslShader, 12, shaderVariant }; + key = { QShader::MslShader, 20, shaderVariant }; QShaderCode mslSource = shader.shader(key); if (mslSource.shader().isEmpty()) { - qWarning() << "No MSL 1.2 code found in baked shader" << shader; + key.setSourceVersion(12); + mslSource = shader.shader(key); + } + if (mslSource.shader().isEmpty()) { + qWarning() << "No MSL 2.0 or 1.2 code found in baked shader" << shader; return nil; } NSString *src = [NSString stringWithUTF8String: mslSource.shader().constData()]; MTLCompileOptions *opts = [[MTLCompileOptions alloc] init]; - opts.languageVersion = MTLLanguageVersion1_2; + opts.languageVersion = key.sourceVersion() == 20 ? MTLLanguageVersion2_0 : MTLLanguageVersion1_2; NSError *err = nil; id lib = [dev newLibraryWithSource: src options: opts error: &err]; [opts release]; diff --git a/src/gui/rhi/qrhimetal_p_p.h b/src/gui/rhi/qrhimetal_p_p.h index a5af5611a61..cb4b777d88b 100644 --- a/src/gui/rhi/qrhimetal_p_p.h +++ b/src/gui/rhi/qrhimetal_p_p.h @@ -197,10 +197,13 @@ struct QMetalShaderResourceBindings : public QRhiShaderResourceBindings uint generation; }; struct BoundSampledTextureData { - quint64 texId; - uint texGeneration; - quint64 samplerId; - uint samplerGeneration; + int count; + struct { + quint64 texId; + uint texGeneration; + quint64 samplerId; + uint samplerGeneration; + } d[QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE]; }; struct BoundStorageImageData { quint64 id; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index a92c3e14e9c..ca913475a51 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -2487,7 +2487,8 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i QVkShaderResourceBindings *srbD = QRHI_RES(QVkShaderResourceBindings, srb); QVarLengthArray bufferInfos; - QVarLengthArray imageInfos; + using ArrayOfImageDesc = QVarLengthArray; + QVarLengthArray imageInfos; QVarLengthArray writeInfos; QVarLengthArray, 12> infoIndices; @@ -2530,17 +2531,22 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i break; case QRhiShaderResourceBinding::SampledTexture: { - QVkTexture *texD = QRHI_RES(QVkTexture, b->u.stex.tex); - QVkSampler *samplerD = QRHI_RES(QVkSampler, b->u.stex.sampler); + const QRhiShaderResourceBinding::Data::SampledTextureData *data = &b->u.stex; + writeInfo.descriptorCount = data->count; // arrays of combined image samplers are supported writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - bd.stex.texId = texD->m_id; - bd.stex.texGeneration = texD->generation; - bd.stex.samplerId = samplerD->m_id; - bd.stex.samplerGeneration = samplerD->generation; - VkDescriptorImageInfo imageInfo; - imageInfo.sampler = samplerD->sampler; - imageInfo.imageView = texD->imageView; - imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; + ArrayOfImageDesc imageInfo(data->count); + for (int elem = 0; elem < data->count; ++elem) { + QVkTexture *texD = QRHI_RES(QVkTexture, data->texSamplers[elem].tex); + QVkSampler *samplerD = QRHI_RES(QVkSampler, data->texSamplers[elem].sampler); + bd.stex.d[elem].texId = texD->m_id; + bd.stex.d[elem].texGeneration = texD->generation; + bd.stex.d[elem].samplerId = samplerD->m_id; + bd.stex.d[elem].samplerGeneration = samplerD->generation; + imageInfo[elem].sampler = samplerD->sampler; + imageInfo[elem].imageView = texD->imageView; + imageInfo[elem].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; + } + bd.stex.count = data->count; imageInfoIndex = imageInfos.count(); imageInfos.append(imageInfo); } @@ -2555,10 +2561,10 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; bd.simage.id = texD->m_id; bd.simage.generation = texD->generation; - VkDescriptorImageInfo imageInfo; - imageInfo.sampler = VK_NULL_HANDLE; - imageInfo.imageView = view; - imageInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL; + ArrayOfImageDesc imageInfo(1); + imageInfo[0].sampler = VK_NULL_HANDLE; + imageInfo[0].imageView = view; + imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_GENERAL; imageInfoIndex = imageInfos.count(); imageInfos.append(imageInfo); } @@ -2596,7 +2602,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i if (bufferInfoIndex >= 0) writeInfos[i].pBufferInfo = &bufferInfos[bufferInfoIndex]; else if (imageInfoIndex >= 0) - writeInfos[i].pImageInfo = &imageInfos[imageInfoIndex]; + writeInfos[i].pImageInfo = imageInfos[imageInfoIndex].constData(); } df->vkUpdateDescriptorSets(dev, uint32_t(writeInfos.count()), writeInfos.constData(), 0, nullptr); @@ -4210,24 +4216,30 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin break; case QRhiShaderResourceBinding::SampledTexture: { - QVkTexture *texD = QRHI_RES(QVkTexture, b->u.stex.tex); - QVkSampler *samplerD = QRHI_RES(QVkSampler, b->u.stex.sampler); - texD->lastActiveFrameSlot = currentFrameSlot; - samplerD->lastActiveFrameSlot = currentFrameSlot; - trackedRegisterTexture(&passResTracker, texD, - QRhiPassResourceTracker::TexSample, - QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage)); - - if (texD->generation != bd.stex.texGeneration - || texD->m_id != bd.stex.texId - || samplerD->generation != bd.stex.samplerGeneration - || samplerD->m_id != bd.stex.samplerId) - { + const QRhiShaderResourceBinding::Data::SampledTextureData *data = &b->u.stex; + if (bd.stex.count != data->count) { + bd.stex.count = data->count; rewriteDescSet = true; - bd.stex.texId = texD->m_id; - bd.stex.texGeneration = texD->generation; - bd.stex.samplerId = samplerD->m_id; - bd.stex.samplerGeneration = samplerD->generation; + } + for (int elem = 0; elem < data->count; ++elem) { + QVkTexture *texD = QRHI_RES(QVkTexture, data->texSamplers[elem].tex); + QVkSampler *samplerD = QRHI_RES(QVkSampler, data->texSamplers[elem].sampler); + texD->lastActiveFrameSlot = currentFrameSlot; + samplerD->lastActiveFrameSlot = currentFrameSlot; + trackedRegisterTexture(&passResTracker, texD, + QRhiPassResourceTracker::TexSample, + QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage)); + if (texD->generation != bd.stex.d[elem].texGeneration + || texD->m_id != bd.stex.d[elem].texId + || samplerD->generation != bd.stex.d[elem].samplerGeneration + || samplerD->m_id != bd.stex.d[elem].samplerId) + { + rewriteDescSet = true; + bd.stex.d[elem].texId = texD->m_id; + bd.stex.d[elem].texGeneration = texD->generation; + bd.stex.d[elem].samplerId = samplerD->m_id; + bd.stex.d[elem].samplerGeneration = samplerD->generation; + } } } break; @@ -6065,7 +6077,10 @@ bool QVkShaderResourceBindings::build() memset(&vkbinding, 0, sizeof(vkbinding)); vkbinding.binding = uint32_t(b->binding); vkbinding.descriptorType = toVkDescriptorType(b); - vkbinding.descriptorCount = 1; // no array support yet + if (b->type == QRhiShaderResourceBinding::SampledTexture) + vkbinding.descriptorCount = b->u.stex.count; + else + vkbinding.descriptorCount = 1; vkbinding.stageFlags = toVkShaderStageFlags(b->stage); vkbindings.append(vkbinding); } diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index fd65417e754..62516e268d9 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -254,10 +254,13 @@ struct QVkShaderResourceBindings : public QRhiShaderResourceBindings uint generation; }; struct BoundSampledTextureData { - quint64 texId; - uint texGeneration; - quint64 samplerId; - uint samplerGeneration; + int count; + struct { + quint64 texId; + uint texGeneration; + quint64 samplerId; + uint samplerGeneration; + } d[QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE]; }; struct BoundStorageImageData { quint64 id; diff --git a/tests/auto/gui/rhi/qrhi/data/buildshaders.bat b/tests/auto/gui/rhi/qrhi/data/buildshaders.bat index 5b8a77b8337..0cfeaaaff33 100644 --- a/tests/auto/gui/rhi/qrhi/data/buildshaders.bat +++ b/tests/auto/gui/rhi/qrhi/data/buildshaders.bat @@ -44,5 +44,6 @@ qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simple.vert.qsb simple.vert qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simple.frag.qsb simple.frag qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simpletextured.vert.qsb simpletextured.vert qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simpletextured.frag.qsb simpletextured.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 20 -o simpletextured_array.frag.qsb simpletextured_array.frag qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o textured.vert.qsb textured.vert qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o textured.frag.qsb textured.frag diff --git a/tests/auto/gui/rhi/qrhi/data/simple.frag.qsb b/tests/auto/gui/rhi/qrhi/data/simple.frag.qsb index c235108d39efc5b4850365823fc9d3ff9606c99f..43edbdffd90541ace686be3142c07ae6f1a98719 100644 GIT binary patch literal 740 zcmVPbf8A;FSvN?L@pshXs%SgSNa0wKoj z?j{-8?1tS<5sQ$M2ah72y-F|Q$q&%a;3w!!Po6{&eQ$R*yNyLD_?F+yyf^RPzL|N1 zkT@Y^lK3P6E|4~{i9$N0L@Z(e>_Fp}AaXjI5}w~iWRFvOy6tewWVt1oQfuI{JzdSS zwyktZmSNciO7|?Tv7W-sbcXIz1~l4btDbr~mzC$4JQ{$_6zB^|F=Mn8ku@9AbCQ+ofpaj*XIbLA^P+WqqC2@EuT0%(H;%qgG9^JGx5_4yv1#I_C0F>^)5oNeA_BY|hhP23Ns);uem> zwb1Kutq9?&wcE8fxF3lpk>fPZ|BFtm{}&3*7b$Wy(v#Rk>I_Coz;{+i&%<9}>}hz6 zIB!7pvyQ7}^Gh=BpA(hDy;;z~=Z*+sBmr}vgEDXqtC&}pPu`uGJf<6m5A{cn72|;h z%C3rhE`l}MU-LZqHNFHZY!wV}8T2vEl*og@m>~Xnqr4#aq>$YJ9(AebeYh6z(<0tH zSfSmF(3uv%^)lo;LBb}8{=S0*-$D_%q_F!5)w$`PU{L!>5?*hlA1Q9C#z52AN>6tc zqXi{4_->Jga)BUms?Izs=roRN4^-Fd0CEeOW6=MwJ4Ko# zYcy1x({iTSgoh87xYyIoh^@aGHIh({SY`WQg>vAs(f;bkI=RE3zOB0h+eEXV7Y%>F3_#dui& literal 730 zcmV<00ww(b00w7xoUK$(PZL2DpHd2CKtWB^lNp1DHj=U>KuiinZTVwFG?W;U2J5oB zZP#pfo82uj5))1yJR0NKtKnii`2qM0egbZK@?=bm{@!-ByC6|Xe9dp(yf^P(-^@P7 zSU>B6C;^;jb>=daHCTx`%mUod;-@6`?=&EzzKQ7`jqez)XF9gX&nTQb9bfDi+O(*< zYNO;>j$7b-$1!!$QcXLP<-1&fdZ%JOFwf+3%7jpQ3&d=JKj)mPB~O`Imz?NXlvz=D z+ch*ZkeX(r*%o!nQT@ViYSZ>lEU01CmQYh!_0_7fb;_!q#`>`qRW+sj*Gx%ZDoT_% zC~w{_y?a%?yZPbM;urI9`}4~elT^+DmK69j@D_Lv90D2W*UO7b`mt-Bqa}rxkm&B$ z%lSO<%YYz1;2JO@?eCeI>v&Gx7n${}SXr&Cib_+}4Of($R@=0&$t$@$yHi0FYvVPY$MPlEQ93UFjZSO-2MX_(D0Vf8$H~6&LCQ3UZk>_ZbNCmOdl(-h z@nv*B=lObWdPbr1v$B(PHVT_?AcQ%FfHByR4#BZY27UP$yqW$ZwkiC`zW1?GK3I_M zimc}XyvhG+5UJbai`dbq5WpqaQ=S1?hrpU<-TNkeLCQl?cO5d>@*w)&LMRW*d=u~@ zzY%FOEJ6EO)Z53R0Z8$_K||j{5z>(K`+@G<=-y!1`+gQZZ=&zxrma~W-4Jsv!&j{u zT5OryMIPxrv!zecl4}+@?|7!&5VqPfytb+tBJjeb@qD+V`N0HGY8Z~;{G;g<8L2h&_~?tjz!#o)A|{IG%${YJCYq4wX{Iyto%5aZ&1Hu% zmS%xz&~mK9T;?;uBs7;ffThrRM#e60SE#olNIOj?Ml)D43%?tL4zq+3F#r_omsgF| zf-kMYEpTMn2aUQn(JpCsp2nn^yTdp%ZKcu#h)E{W5S6OQ>;5aYo2@6HvtOE0saaZ5ZJu zacFlSK0}+9QoJBnM)_0hs#+gY*bL2e!fwHQfb!rTJ)rqDs*U_X@@0rWNPDJ{KS#OH zKMiY3kPb%pDIj=Z=1Aud@#g`}sWS}pV9hcxhAHMJRCuDQuoRs|DkcpT%#RAE(dt?@ zpKaUHY}MiDTVl7YN4PKA)?@rD?3Z=D>kFsJ9kXrw9kXF`#hTG|UwYk!NZ7ngHb-r#RU?5 zX*O+`)oSCEJc`FQ$B!Tv;xH@3#m+&3LMR~!@od@k9E=17I_`T~WupWA5bZ8o8wGhj z<|$1Tbse-E*o|mODBl&95|a;=U92932BpGt#7Y+RXfLBmMW}SXQ~$K!VQgu!f)oFx zAYS~5*iAjIY(HE0_U_)9@#x2w*-x*JdvC|SqpD*qcupsweT4QEzf{0Bpj9i2OR*Xq(wqPnr3O2 zGTQDoyVJ&m_$TPec=qC{|A2plM=$;bUN~_gCW`OPzG1f-O-OW_w=?s5pY!I;D`PCq z{1E|4vkr5Z#{`o=4zn5Y&uFlVjUlr8GK4*w=vl5O9GmB-bB19`>5BcXw0O^|7kJ0< zgaqcCVe}l);B8abnJMGQ;4qr4+7|KoLP+$LVPK#r3v&!;I`9`cF6};E`ts)XS>^t> zPxBvM9QR*Oe#NMc;gf*50Q4T{Gte+#TR`Q~@=D{E)6C;1@#74SgzIuCpU3$Y5C_Tt zO#)pe`KO}pI-YYNd8RzY*VZfRymDwZESE1i?T%={BA?6V*^|oZ#y!f^Fxk>0Msq5~ z*!J@7(&lEl#QOdI<{xw-VI82#&UwmMWo>!)5nx*&m4^BGFpJbc{3M-L@=eI$2~VHf znT6Bp{mQsM7lBpTUfg~Q>u4y>@LKC%WL#AKFGJS>j?fiGPGixDBzj6h#;y`N29cxh z5vWz1SK*ejo@`_bGdbj6p==^A1)9nMkoI9H8O(W1<=~^LsrZ0Q0&L?QVfk9_j^#>A zJ%}N~8S(TzCBT+JcmjTCUl%)KYk+CJ5t>&)2eGJH$Cb`F@vZ@i_#G9cFLMJ{_&Pbz zO^{DA|Fy=Io^LCu_;GfL`89>u9PJIluETzW>|l=W(q6v-)E^~YlJrL@XA$D3$rkcw z;cQVBbS1=30l{~=Kyju>e-Y5Mx!r%(}&u7BnkQy4|`|?J8Gux{^B9 zLCY~^VW4sC?diL$R-twMsw?b4)lQ&y-YPS>DXrU6)fD*kR~c=K3sm%^*|cC+t?Eu1 z$RjQABd~=y?6QMhR@m8~(V~cJ$*yaoq;9+kWsNTMU65V25w!XlX!Q`wzv}VmslkG_ V5&Bcf{g*$L$nV9&*iR34C!Vffm8<{& diff --git a/tests/auto/gui/rhi/qrhi/data/simpletextured.frag.qsb b/tests/auto/gui/rhi/qrhi/data/simpletextured.frag.qsb index 397961c2388f94eb8dfe0b00727127c6f1f1b958..7749f3caad10f73e1aeb31449e9d01152cbd78e3 100644 GIT binary patch literal 1206 zcmV;n1WEe<01Pd7oYhuKZyQw$La?g%0jwhB4|IpbqD%IOKY-L-g-|zD`Oe%k_SB_mS+L;R z$M?MNIp4i=$3&DMqJB_cFt@0UIR>J~GU&;{ey3@NJTj?Dd2*=+@+8Z%qIxq7kWUuv zflEEdJ30nrmE)0Qe@xjeJ(lF`*S?Rw=+{>khv8AhvVJ5}YF zb*tGh%a#hF<_)9id#$ps>Za{vOK!_IZW{_?r{>s!WUOHfoBrTZRf5GCDLBCQGBJOshQ| z@x7!&A0Pseo7zwymo2)v)}LE`R#tzU>FW!`Ual`{mHi}lplkRL%&v7 zUb!2AiEs4g{gBH?AuwiBQd&@0JC z5O{jmE_-g%-SJgwZCYKwQM{pwyJiI!R^F{QY`(c>vY8n=JUo1-cb|u}_8{b`hwmN#WIM|LUykq$^Qd&y@%4CYD#>ON0zh&)RAx#IXSsdYf|PY55{&kLWF{O2Vf>#hLvnDkDfdk9TJd>M-& ziCu)uJ)M+(7NwWdQtyX|N(Pu~AJ#9)zO(Ks>|;TVI_Ie5;9AE;zbN~0R(w`b!9;+u z)}4)D&vpNRoNPZQKI4%buXb__1@ffm&Pl(C2u@+0lacrf63;dz@*}J~r*}U3&gl7b U{M1q5QgcVx<44*520s(;nYbu)+W-In literal 1208 zcmV;p1V{S-01M%GoYhuOZyQAvf3a&j+5U-JNa~c5P6-F6SjKVFD#Ed)Vkd2-LQw2L zM6k?uy|x$GyJmN7l9nRG4IwyHd;m_7@&$TB;=qwR;tN#jtwN|51n=#>@or2A<-mc7 zUgrJ%&3kWlJOcnHz^4gs9>5Ui2on6k1A;+5=b!~PsL+NoSkOhX8R4i17>kaB3p(r~ zmp;ZbJmMVrZAkai!ceyz!!pIvwVa|1OrvGlJ>jUmepk2i72)c;1w}DTG1RrZ7z_)F zHE>B-7A;$Cm#wa4qr=cLnxdx~W_nS%uLvBTizbSM;0|m(jdKP877NmRRW$M|=%8hH z_wI=+IDg{XD2l?zd(7 z9i!dpi&ocC-NIkghKb5iSA5-gZ-%P9XPE7vLC?{QeC0oAN4wit$BtA~SKZ0g|E?#y zq22#6=t=&V-Txm|7)8nl1xEHO+i#Z7f0x<+e)DST<6oXU{P{^vp*HN}$&BH=jPxrV zB2<2WbPDyGm9_Opp*GPWUL_`m=L~(m2J%^2B3%keP(0GBNT)dFQ%>fnqf7K9<5CWE z#F(Ml(=H zYthI;f>ui4&b-3fvzR%peG-4xX}*acMAmVe+2w0FvY+8yBil4a%F9WvaTfeN#x3#m z30evNs2`6e=({{|$Ula*DV#Ot=^Lfbl6b-z3`rmJFh{@3loz6qugqJ@mqRke&xd3Y zl3&1#BA$QLtBCknzFdGx2;<6NJ>|C3w~(Hv&2Kydkmhm>DJypuR9952r>=?W~L zW*x0J&3F;^PmcQR`zN`-q?x;Y}7uaV5Gnn&w?CUOsdQW+OgP3H$$UdnM#>*p&DNmkf-9@f97V4ACb3PP*nd8YO zSpFSXUh#Kco;QM$TTYohUNB6pJ80@+wWqskw}Hp1Yuqg z=ytkmX=V^afIZy|E$DM;34_lWjC5SJt)o=0XGWKGbJfExkpf-hlZ~)5@;N}ZDsq%B zt2_t!0ti+mDvJ9L3gL43ZIJat(-JI$No7Zm1kd-_XM&IRPY(smAUpOtB(<$$SteQK WyCLRf4f4@`=tDUCd+{em4DTuca%uwr diff --git a/tests/auto/gui/rhi/qrhi/data/simpletextured.vert.qsb b/tests/auto/gui/rhi/qrhi/data/simpletextured.vert.qsb index a9067949a5739fb18ecb73192d15979555126eae..c87d4b2fc1e611356bb13ff261e9987caced0a21 100644 GIT binary patch literal 983 zcmV;|11S6e014%IoXu5RYZFlrKG`I--L@vRwJj)eq&}nwF)6hadcoTCBB&`%kU}YC zo87iYlHIU3Dy86W5b?R_V|~|0e}Ld0@yRD&yv&?4+ua1J^g(dKWarF$b2)ov&oIWa zOpykhXFjvo5o<69el9afpZZ0_Iw{ZEfb*CDKLL^rx(pgFz^9}=U?Ii52=_PYp;&Jc zx|b87<$A)gdHH@x*PX!Uq1Bk;K{%%iTgkq4)NmZvj5O1{?Rdfmr#W2@9bxj8A?(7W zeynq#Amj@PA5XogB%by;I>OlU>+xF}`qx#|VP25slQ_VdMd~x)fP<<%B5nNJ*uretx&`F0?#ILrsDSaxTM>!2bePwI8THUO$v$L}* z#M<~vtTYt3L~<$-E5{PCYR}H!HO8&2uWU8Jz5&P^@O<9OQoG>#EuWWhP@V!A<5(zj zr9Xgk`NowVc?RBKWLqUX>LSeQEoEB-c&)xvf1RisDbsZ(DRw#1E{XpGMg4}9Xcg^! zTAR3nmG#1JoU}ub8Efr_s|lZL&<#b;H;dEvOK87JyHw}UrxE~1Ir^k8UZ{+XFnlLz zxfkr!EFhEEEZ7hqgeYgFU-TgrpP`@vCuvP?@D8FpQHXeXz-p|pnVTe?Td8I17sVN^{CiO;4v!qrfR)L z_%Xu#fb6sC>xud}!{Vz8t2><#cB2`X7N2ifzR}!;c5RBiMLpJgqGjI0zvAJdt_L1Y z0o!OB2!Y+0WH?(vPIDo`64k51P2d<6CXy#>Q9_o{>!6&KfP$g;IxZmB+ FqBUT1_A~$h literal 964 zcmV;#13UZx012^poXu5VYZE~bpSvVhudRu#)`C)2>O+bUlTf8lTdYlMg=$I@N}-f; z=Favc$%Xq9DkAt9M0_s#Sl{*04y#|9F*F?u};8h(iTFOw1>5pTm3ryUm?7+uN``G^%2h9@yskPT;t0 z8863ribwf7k&$Y_?38bUF*G0KIn}d*K2hAk9wsGqI^!=V{6|qs`Wv!Jg&9MM7F%Gy ziueIud|m3&xY8i8q@U&a1=f+>U@no}U@jWR8|HXv$wP4)X5TEwxyZg*-UrfM!TBZT zMX_%2e1vNu|53ILv;QdXp~m(xjz#vnxK=vE9{}lppeBRk9M?U>+~;|phuAhO`KZ_n z=rJa1Q(Q+Ff0Z#mG5d^U0BJrqX%59rJD7CZjb>=s;$F)R%;pXr*QWDy-iYU zUtw?FFhbvH?~1nBvi*+Pu!Z!RH4H!S!bTt{O>xH!1LLJ3usv(KW>6MkS8Q#CzU}3k zZlhhC+TNax&C?=r5D^z0I|98r9@=RqBTtJ?>}Ljn=R6GqJAW)eSwvq(AF4DJW$4P! zBPOq;e3Vf*6y6WaT^ncH+fz&-##5gYFJGyoI4fYqbLdxyGRKx=u@VxMpdg+dgkGDF z$jzW5oRN9>EWL|24_;3qai8Lp?i3A!NObK6t@f;el%*W!SDJXmsBYJ>WEJ_SBuTrU zb3fnMTak+n7ICw9r1mD}Rzz-H(|bV&r^m0i4aaHr8U7{P{lrQp*p~l4wsb#~W3qa^ zviV@~%YCOhl>7F+GxNc$e)@WyN~-H1FOg~N2iU)3uW0H4S+6WDCtfhw?$KZ7*Kb-6 zlGiJx5{=`0+2yg{OxzfcordT7?z2GT*Qdk^K5wG7XIi!=7Ts3IX`)an7E17__V7ss z)WuDg^h_dWipOkL>9vHO+wRTFZ)DT^Ue5EB~(IwuCRojSP zJB(XfS=wx(eGQSkLk%Bg3N$0k`Q{Vwjykx+W-cX0(H+cM)x7h#qs mlx-g2wfaK+ZGtzoH1szO&errZ;{Vc;U&pbB0^kp=)}hEcm+V~t diff --git a/tests/auto/gui/rhi/qrhi/data/simpletextured_array.frag b/tests/auto/gui/rhi/qrhi/data/simpletextured_array.frag new file mode 100644 index 00000000000..c5ee2057d8d --- /dev/null +++ b/tests/auto/gui/rhi/qrhi/data/simpletextured_array.frag @@ -0,0 +1,17 @@ +#version 440 + +layout(location = 0) in vec2 uv; +layout(location = 0) out vec4 fragColor; + +layout(binding = 0) uniform sampler2D tex[3]; + +void main() +{ + vec4 c0 = texture(tex[0], uv); + vec4 c1 = texture(tex[1], uv); + vec4 c2 = texture(tex[2], uv); + vec4 cc = c0 + c1 + c2; + vec4 c = vec4(clamp(cc.r, 0.0, 1.0), clamp(cc.g, 0.0, 1.0), clamp(cc.b, 0.0, 1.0), clamp(cc.a, 0.0, 1.0)); + c.rgb *= c.a; + fragColor = c; +} diff --git a/tests/auto/gui/rhi/qrhi/data/simpletextured_array.frag.qsb b/tests/auto/gui/rhi/qrhi/data/simpletextured_array.frag.qsb new file mode 100644 index 0000000000000000000000000000000000000000..362e220d25dd6e9f6354f4ed71a9daf1a180396f GIT binary patch literal 1693 zcmV;O24eXD02JqVob6c6ZyQAvpSAN;Z8og7z1ft3w}v#{Qy*H9v?u!Zw-3G*)0~R$)bG7O`~l z@-y@>n;C2eMrsE%qJnMoJ)}=~s;={y^_%J1Viw*&~W8izJCyq3s~Fi8gjcvd^@!2PAvWHgQ<#%*|fQOFU*(kWbg3omXpJ$STxRFym)adyYy~^=I^7JibupD z2!pkS_4MlMy$t%S?!#vgTK2u%nr0OY8=SJs3+vn9a2NC+Li@OnDIXyGqag<`#)>q? zxU8RqFm1b-`}aLr@yP*_9}cl#V#viC!1I#3<1Gj~Vip+t;ycEkrSBhSFPUpwB>dth zZZFp4$0|OoLRc!<-UimryWg6!_bvhf-HZcd@87t7BL>zsuv%jDdk8c$`lU+^tZm=DIUXQtB zj4GTkXN+96x~o5fn7BJ0#c{$NU&OKQjxXcb;p}$SuxV+9bfs9qYkCQ0MecL7Pa%&= zGS2s=B(F&FQP@Gi!3UiP;CL8Dcz<$eCjgIo?V)&Z`0b<=A43XWRTOpqTzJBNt zcO3i&n0M~SNj}KjdKm%vkdr4@hw}{*7WGMz>9jd~hlx)iK9rA;9sQ5exS#ejOzRDh z{RH_A6aNXyx6C)B&;XftuqkNtCalL8gy(p3Y z7L9vpy(q7c?kdzsfO5r1_XlXY35&TqAo=z=`DvC%eey-0e3|5VV8z%TqkLe@=K$01 zAkGnq^G(tV&a*yFPMEXAd4_a?bBs98Nu1|N zFE}swINu`71>zhf-5i|@mEtMnFvasz^1nowu!I?>7z<2}cOB_kk3yxWdBiV*yjyMiV z94XQZjvEq3O5(T+(ZYDWP5Ygu`EF3$E|X2nHP75ymFK!idXb9^VOC*oJZB4}!^UVG zc%HrlPP8u)=BC84)ZjSa$jhWdES^I=d*b|xbuLT(x5*!EDx5H{N&{@77J}#hHg62mRZ=^=9|TeW+z+J zW*L-?e7m|fS+8r>u30X4sozhU6PbM^nm~J}nn3^UWEYCLMaXwXvo(lWyNu%naLhZk z!DC})SufV|2A?e%wpPr+M`+P}m3i4dVB$l<3QQg*bgF9Z3%&KkG zblXX1EC;8WGV0Wfbh`P22Rim@EW80#@zn2WmSsmQ6!5534NEOn^s?uKge9XaP3VqP zK?7w8o>f~b7$9vx+BM74c4tL7}0jEM1s4Pgh2U0swQM}$t zu+8x&Pm^*8L|H>(qOQ9t2%Y*i%h5(*3KuGJDD4)Pcn23Mc_{Q2mqZ7bP6t5P!R!vz zO|5Fr%yc*kKI86Q#>aaZ+Z+yO{ymQet?)Gm1Tqu#-H52R3`l$#t>V0NJK3bGaYuU1 nedAq`iM?NQ|6h3jh6^vqTK-F~?nJZEy?)-oXAr2IHZ|046lcsJY zq#l^$dFH)&U-RCZ*%`)Ilrh!<5E6ZzZ9yLfVE<5KdmHi{XGP{Rot0RIIjjuel9pyt zt!xAI7h%*6y&7i&Txjgjy@{Z3mPM4Q`ok&2nr$K9SV4n&;LHk8jkA+HH+PtLR<|e_U%jEeOT3 zqkG(`>W1a*q_sO~O{?2h(Qzv%#q01BAl39rwQRZ*S?-yjK-<#Y9m_89Ez_9b^(~}0 zRsjrHb}UXNVJ^iDK8+$?-8Cn&F&K>idtAC;BtGRAr-i9R!x55vljl?8AZsMHcW&{E z$V);%M9ndnPk=V;c4T*J1ldS=shpp8^-@;%^tI$VYJx>-8fFE(ggyc=;fFBtIJ^2z z=I`rYzun#Y-7j5FCx89%;TOMQoF7MIg{A<02SN-=xx<`=hiq!kV=Dy6e?`KBZD^?-{>F&f4PK+|BXH7UzW~*fsCk7%YBGuQ z$0*A<*U8#M%n+1~Zh%pSUx*tL@e;Eh*H%n{wU0KKyT0(_cU%(9HXxKmZbN< z7`JXKU_In3ZL0FOc*USUVkS{mOI)Hh6cKjA2Uig;Uz|8?e{Rl|g1 zJR`(^n*3>{^<1E_njfKY8~KCyDA6uKe#6Ya@*wR`phSrmW8Xot(|}_Pk5T-lDR##x zJ|BWqo5-=`LHZ2s5u{y#`BNf4G9LY;1AQGJI`W*R^>)xY70(%>e-1o|pC#HrKyEM~ zhqecaPtBh@K<{~?PgCs;5zi8=9%C6J+7QJkMESW7I&nTuJm&*CE;e*@2z;1maf)>` zkRuhN;edRCC~11-mS$db=?2#lerm*>8_BK->$P!K-NB<`IkX2J_=Oi5^WQO(FX0^n zNo_n~Fs|aw(pbTvo;5G?QL`_$d*3q{$^vVAzCt(rP$rXF)in)EV4GHHvnu13euiw> o-a)(eKZafE{=YsV_dO)Vnf}b(l^#R;4%()?;lt|v7qlP5B6+t9TmS$7 literal 1574 zcmV+>2HE)l01)1IoZVQ>ZyQAvAKP(0wzNr0)3hbfZPO3Caa_l^RfUr%#ZDTeLQtJT zXd9W0y-pU{YiqqWNvoo&5+|gJ1LDL5sTUOW#(^V(D;F*(e@BH7LZI?{J8!((kdGpv z9$0BS^WMDodvD&%ynSmSM3;~)sNSQAKKo>^Zrqi_QwmyC_rD;vqX_Z`kxmD5bYC4{p;b!Q^vDUI4qf)IK zu3m2#CCgpUYWK35*0QZi-Kmk5-oj6S)ii32s_CTjx@!VJvuwR>meP8woz?0smxzpB zag3E*y;^r5(5_o$*t6_doIUVFO8O)rxGl$wp-%uHF8wJbKi1DrdUlf?uUPMOy_gw? zW+}P0en&q~vaAFq;l?nZ1R8bgvb&QYF$V8=Mj%+MrqRxjdmPHLANJ4(ekfBZt>Ks@ z%cEAUmDPrfTlODp%Lem554*(P8vM55tXuYqzXQ(^?R5S{#(Sk&oJGj(FAW`6O_Tw>TsKbpzi{Ql7&KmPLb)2}Jcn~;p6&!GJZ zMhxlgHrfRE*Yh*8--YCUe9NE{1Q$gr0`v0_$&8N^?f7O zAu}rZKea@%vy%*hq3CeT@rjO#JYSqq_WtcXoYsk@+PLcS7gmk3>FBw7tzjV&$WF;|@mAsLI|+_cuaNtr9IbJr;gx{;PEI<2+#8KFn;r0WTd4qfHzVxF@ z&i6Qs|64y}gk=xkqYw0Fb*B)D!orn>FL)hlXTsdnv)g-lyScsI*N48uW4hCHO=(P6t+wP3VoX=J8`L2C%GavHBcIfDAv;4t-XUox z>iN}qo737LL-tNFo}y1O7SZIxYdk*(TG@_zwC~GEN5<#%2wCOL1^gqqX%AbjDa>|; zw)io`ekgh@;K$3*3VZVrZ#QUs1S6{LbhIJJlkINa8y&yB><_hLh`1*FS}^!1`W4_& z)vB?+%GbopGQFR9WUrs`!Yn@^)ESZTL?2`xUGKx}OP9AU8P~&%LHb7+YmoJicy<)8 ztMfh~yiul)F-`i%S+<+yUlo3?8fBW|8DaSo>`ynZ=PZxae1gY4><`gn%)5mB4GX_q zC*JSiL|K+%-^aR>pecq2IDV5HyF(nG_o3C}?Xi?0{uJL4;$6Y~ac_TQJdQC2`8v#e zk~zWa?c;SSnUl=_6f#7gV%~5-ZzP~cwntb_&7a-|_YCtV`RtuznR%?9Vi{xJIgU|? z_vaxnX+F*}X95`KI~aW)J<7Z|$2uC=BNe03fPRwoX>N?^zhL>YJmo4c5|ldLHUk% zAl@n9m0#2*^}F}7!GLg`os_CE1(tx@$-N714`kPpTbkLc=!R>_E#Hd7c1*0-rdd^k YN4@0;^)JOUhtIDWwtmn54X9|l;5Mx%ivR!s diff --git a/tests/auto/gui/rhi/qrhi/data/textured.vert.qsb b/tests/auto/gui/rhi/qrhi/data/textured.vert.qsb index 44454d226ead62d5bc16f34c14892076b867bc81..d4ba4747772dcc0f69bd0cd82c66498d1760cb1b 100644 GIT binary patch literal 1368 zcmV-e1*iG|01no8oaI-|Pa8)RpY__tEa5ABHl$%vs>(ExYa=I$WIzziN2D|$j1Uz? z)Yxm-%HBomUCSuqPiWOjRnI;3f_km`A2feJ)pL(k)dS*C_0p#A&Ajoh9UzKS_0q9s zciz|Uy?Og~_L(sjV{$}b4ls|ItjS8ufuGCD#MfTZVC`do9fMw-Szu?u$_8E(1y|^6 zLhiE$;a;Z~X9u8JfmH(TYMl>hA;Jw-V@2@pg8wGaJtSLbi;_kkgm?_yb<44NW+rVIb~|URiSoR@rn57x+H*!YN1Be6PGbPJ2nF&KX&St z2jL)wW0k?RWhbX87{9^iLZ-+%tnP1+3CPfUN=D1y4`H1e1||%_;I6}*2~wb+=XV}2 zO-9FlynpYD-@cpu{>f)A`fW_qxh_jB3-cRb{0=h@PjCzPoB8FHvL+My2_<$G;bMQk zL}FG$olFLK<1jhQB+Pe30m$+36%R_I3A+(G5qfAFA)Oa=Um*D}M61eF_o&uhE#und zdYHO>nK~w(akiOdXJ=;-NLTclTKh@aQb|Z-c7|!zn0BSzAc#J+O0H9PDjrX6PV=>= zg{Qo5R4kh=Uvg^4RuvYRbSlH16jq<*X`cz0k3u*)-TV6`UkmYZt;1q#d1q;TeKU{y zSqH3**I?=JfEH=3g|NUyfK}LTRUYCN)|Ph?8a^Y9JqEo`6HNOE(!TOJ7dV)~eSo?c zkgqnbXJC!ECa$^UAA;%yA86IU5rm5OhfrBcXNBw__QVAp726{uBY!A|A~%#gKF}@~ z>psZ~>wSBxT`$t9N3s1e*{-LD^ya~RVQX>gD;69&DhJ_8y1F_pA8)FE%}{3nj&i`( z&-KVu7kWy-j}vzgvVgvOU^jSQg-T7;y>cr1AdT`qsvKD(-O>R}<)fR)Lmsm;fnMN; zdHq4d^CjA*8v_~Y`wd*jgq=F_q&yD(pibc6Gu>^|1tId|#AhT^rHOdzV}k2pCeM{P zP{YKh*S^KWeW=$N;~Qo29hVp}u?KayB5xIRFy=dihjb6oh_wbbDz=`MjxKl+A&<6V ziIKjdr|2H$bx|(YLh+*B0^tr5?kdIpPAD#JW*Va!U}7c!yE(s zE+%U_B6v}8hUgSij_7XUq1>SOl-!^kXoS~Gcu^6D%t96Q(YMG~FX)Qi}-Vtx7+0ZORz!uZPK|-I2g|) zUwYs1y|6jXhvC^xj?w zDBIQ=?e41g6_s9rw(PdRTAdTvwfeJUhl8MrYtzb1D-R8EHU+`URZ@B67Q)xP;-LxD z-rjv)a%>=Nk*N1XF9!;6t-ub^`E;u%Rfss}`14a47EmeCB3gE;y-P&Nb)6y@1kEBE zxTfd3HrlD?F($lHv40&@3Hv$dpdb8;9W-vO)jdP1I@)H*`EUAV+;N!&pWo1bhV=jG aKSRg=hM*mx9=hZFctsw$&i)_c_;T9mcdLQ` literal 1342 zcmV-E1;P3N01k?HoaI-`Pa8)VpY_@XmWLrc8&a5*sxnRFVnm`yUbb|N>H%@6dTG<|oB77OCO}%L>ZOCm z`@J8(nVlUNV{s-&3}!#`nZ=r{$XxjISc&A?OByU3{j3Hyb!LN)4V1$u)+M%@&;_hP z@vgE-vO};c1JwynMdu?{=-tDr%!I5SS**qX*Dn}ib78)(Gm+A|Jx%; zPCb!wx~6QWSP4oNU#MEXSvjctrHXyHXoT{*T`j$bKbhl2!wBlObHp99YSn9I(c;2u z-Z1LE7ZiPd7?h1?28U6uxTZhXoa0r~_w43;DC919+WyJB@jP^_nzl1@;0AuweU=9e z{`6^3x4d-4EjlyP`}>hVbNr}su;tcm-*z3as}YGtuY|Upw!(NV^fP^^@G$VL^o0bo z+_#!V*Y!$mR@rHlp<#Jo5f(40w93eB3}5%nBMZ3w{ky#AI>0&tsCRe(zhD5rW#|x- zPg9X$M4UPP?71upxC~&DgUA_GTd0Y`krUA~5`F$II;fVVgJ=1H=b#_-Vi>R+5+W;Y zu`eS#=f^2%w2o1;_hv3x>nZ~Jnsp8wyX<;Z^b(bU2wQ7dMO@{11E3Og*p-xoD}{Kw zc1d89RzL|b+L5>pg)o+EIgY`o;}Sh_{2X>X^DlPXFufCee_CC)Hr2)E+Z6vD2F=K- zM=+TEzhI!loDCt+&+>Z@S0>}5-`~CS*)QKLeEaB=7bypUIs?lDJm+A31%h8;=HYbT z0r_@*b*-dHKtCd27cgAn&zHz7XlRqoqHGK%hna@?cI0sW@QOoRqY2#zn;0$HR>bB7 zJ(o!T6Y=VcrJixE{Yx^YU2cca9Z2YyI@a0g>1hn$ieK{``a${9mXOZu6k*m{uiC3) z095bWMbE9fWuK?Fr}@U?!ed@IHcOVrSKMmNt^kpp$z<81!updu_1OvYK_re&&s0jv zwTK*P9f+OPy_L<)?L79g39+_b6HA8$S|(bH#DWxItio<<=V9E!#_C?DhHIp;hhX<{ zC(}Lv*w;SgA`T*W0HMzNo7_RWV@Xnv0H@ng`MS{FPOZLs5ObR z_8ZOByW{flPwlT6>MX!f3dQ=F9-HdGOdYU0I7tTp1Y|DC5R>Oh61X9f(`(<7VIS&s#`;E>e8**sgy=yXt|(gv8?1SP z;vwHnJjU7pA5~j-%SIQnn9#>twIs-1@l*7S$~p+kjYz#{w?uJ=DDFDd{#K+ekjcZsFyL|2Pu|}EioRXd>DV2`WT}4!=m4?w^5=8 ziN8s?ddVL7agw2af@(wkeOQ|q3*UE?{|*vd-yGrCLs%@*o=1KeEJm69W{yxlIqKyN zlIIAwTa^EE@In4fvbjZZu%1c6>;~nTB)dPL>Id>fiQbJa{O=SVIryFY3sw 2 * qBlue(result.pixel(214, 191))); } +void tst_QRhi::renderToTextureArrayOfTexturedQuad_data() +{ + rhiTestData(); +} + +void tst_QRhi::renderToTextureArrayOfTexturedQuad() +{ + QFETCH(QRhi::Implementation, impl); + QFETCH(QRhiInitParams *, initParams); + + QScopedPointer rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr)); + if (!rhi) + QSKIP("QRhi could not be created, skipping testing rendering"); + + QImage inputImage; + inputImage.load(QLatin1String(":/data/qt256.png")); + QVERIFY(!inputImage.isNull()); + + QScopedPointer texture(rhi->newTexture(QRhiTexture::RGBA8, inputImage.size(), 1, + QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource)); + QVERIFY(texture->build()); + + QScopedPointer rt(rhi->newTextureRenderTarget({ texture.data() })); + QScopedPointer rpDesc(rt->newCompatibleRenderPassDescriptor()); + rt->setRenderPassDescriptor(rpDesc.data()); + QVERIFY(rt->build()); + + QRhiCommandBuffer *cb = nullptr; + QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess); + QVERIFY(cb); + + QRhiResourceUpdateBatch *updates = rhi->nextResourceUpdateBatch(); + + static const float verticesUvs[] = { + -1.0f, -1.0f, 0.0f, 0.0f, + 1.0f, -1.0f, 1.0f, 0.0f, + -1.0f, 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f + }; + QScopedPointer vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(verticesUvs))); + QVERIFY(vbuf->build()); + updates->uploadStaticBuffer(vbuf.data(), verticesUvs); + + // In this test we pass 3 textures (and samplers) to the fragment shader in + // form of an array of combined image samplers. + + QScopedPointer inputTexture(rhi->newTexture(QRhiTexture::RGBA8, inputImage.size())); + QVERIFY(inputTexture->build()); + updates->uploadTexture(inputTexture.data(), inputImage); + + QImage redImage(inputImage.size(), QImage::Format_RGBA8888); + redImage.fill(Qt::red); + + QScopedPointer redTexture(rhi->newTexture(QRhiTexture::RGBA8, inputImage.size())); + QVERIFY(redTexture->build()); + updates->uploadTexture(redTexture.data(), redImage); + + QImage greenImage(inputImage.size(), QImage::Format_RGBA8888); + greenImage.fill(Qt::green); + + QScopedPointer greenTexture(rhi->newTexture(QRhiTexture::RGBA8, inputImage.size())); + QVERIFY(greenTexture->build()); + updates->uploadTexture(greenTexture.data(), greenImage); + + QScopedPointer sampler(rhi->newSampler(QRhiSampler::Nearest, QRhiSampler::Nearest, QRhiSampler::None, + QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge)); + QVERIFY(sampler->build()); + + QScopedPointer srb(rhi->newShaderResourceBindings()); + QRhiShaderResourceBinding::TextureAndSampler texSamplers[3] = { + { inputTexture.data(), sampler.data() }, + { redTexture.data(), sampler.data() }, + { greenTexture.data(), sampler.data() } + }; + srb->setBindings({ + QRhiShaderResourceBinding::sampledTextures(0, QRhiShaderResourceBinding::FragmentStage, 3, texSamplers) + }); + QVERIFY(srb->build()); + + QScopedPointer pipeline(rhi->newGraphicsPipeline()); + pipeline->setTopology(QRhiGraphicsPipeline::TriangleStrip); + QShader vs = loadShader(":/data/simpletextured.vert.qsb"); + QVERIFY(vs.isValid()); + QShader fs = loadShader(":/data/simpletextured_array.frag.qsb"); + QVERIFY(fs.isValid()); + pipeline->setShaderStages({ { QRhiShaderStage::Vertex, vs }, { QRhiShaderStage::Fragment, fs } }); + QRhiVertexInputLayout inputLayout; + inputLayout.setBindings({ { 4 * sizeof(float) } }); + inputLayout.setAttributes({ + { 0, 0, QRhiVertexInputAttribute::Float2, 0 }, + { 0, 1, QRhiVertexInputAttribute::Float2, 2 * sizeof(float) } + }); + pipeline->setVertexInputLayout(inputLayout); + pipeline->setShaderResourceBindings(srb.data()); + pipeline->setRenderPassDescriptor(rpDesc.data()); + + QVERIFY(pipeline->build()); + + cb->beginPass(rt.data(), Qt::black, { 1.0f, 0 }, updates); + cb->setGraphicsPipeline(pipeline.data()); + cb->setShaderResources(); + cb->setViewport({ 0, 0, float(texture->pixelSize().width()), float(texture->pixelSize().height()) }); + QRhiCommandBuffer::VertexInput vbindings(vbuf.data(), 0); + cb->setVertexInput(0, 1, &vbindings); + cb->draw(4); + + QRhiReadbackResult readResult; + QImage result; + readResult.completed = [&readResult, &result] { + result = QImage(reinterpret_cast(readResult.data.constData()), + readResult.pixelSize.width(), readResult.pixelSize.height(), + QImage::Format_RGBA8888_Premultiplied); + }; + QRhiResourceUpdateBatch *readbackBatch = rhi->nextResourceUpdateBatch(); + readbackBatch->readBackTexture({ texture.data() }, &readResult); + cb->endPass(readbackBatch); + + rhi->endOffscreenFrame(); + + QVERIFY(!result.isNull()); + + if (impl == QRhi::Null) + return; + + // Flip with D3D and Metal because these have Y down in images. Vulkan does + // not need this because there Y is down both in images and in NDC, which + // just happens to give correct results with our OpenGL-targeted vertex and + // UV data. + if (rhi->isYUpInFramebuffer() != rhi->isYUpInNDC()) + result = std::move(result).mirrored(); + + // we added the input image + red + green together, so red and green must be all 1 + for (int y = 0; y < result.height(); ++y) { + for (int x = 0; x < result.width(); ++x) { + const QRgb pixel = result.pixel(x, y); + QCOMPARE(qRed(pixel), 255); + QCOMPARE(qGreen(pixel), 255); + } + } +} + void tst_QRhi::renderToTextureTexturedQuadAndUniformBuffer_data() { rhiTestData(); From a2446c0eede445eb40905487b1ba7c689aa8baef Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Fri, 6 Mar 2020 07:29:12 +0100 Subject: [PATCH 15/38] Doc: Let SQL Drill Down example show correct use of qgraphicsitem_cast For qgraphicsitem_cast to work correctly with custom items, one must reimplement the type() function for each custom QGraphicsItem subclass. Do that in the example code. Fixes: QTBUG-7357 Change-Id: Ibf221817908355f0347cddfc46747b6955958f5f Reviewed-by: Andy Shaw --- examples/sql/doc/src/drilldown.qdoc | 3 +++ examples/sql/drilldown/imageitem.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/examples/sql/doc/src/drilldown.qdoc b/examples/sql/doc/src/drilldown.qdoc index 8beb515a839..a7a9601c26d 100644 --- a/examples/sql/doc/src/drilldown.qdoc +++ b/examples/sql/doc/src/drilldown.qdoc @@ -437,6 +437,9 @@ \snippet drilldown/imageitem.h 0 + We declare a \c Type enum value for our custom item and reimplement + \l{QGreaphicsItem::}{type()}. This is done so we can safely use + qgraphicsitem_cast(). In addition, we implement a public \c id() function to be able to identify the associated location and a public \c adjust() function that can be called to ensure that the image item is given the diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h index abb9103c7eb..324c847b122 100644 --- a/examples/sql/drilldown/imageitem.h +++ b/examples/sql/drilldown/imageitem.h @@ -60,8 +60,11 @@ class ImageItem : public QObject, public QGraphicsPixmapItem Q_OBJECT public: + enum { Type = UserType + 1 }; + ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = nullptr); + int type() const override { return Type; } void adjust(); int id() const; From b80503b377abb04d5b6f9b243fa9d1ab503c7110 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 26 Feb 2020 14:03:19 +0100 Subject: [PATCH 16/38] Doc: Fix \sa link for QResource::uncompressedData() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No point in linking to itself. Change-Id: Id0bf3fa6878417e541ec0997d34758b0c59e99b3 Reviewed-by: Mårten Nordheim Reviewed-by: Thiago Macieira --- src/corelib/io/qresource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 225ee0a7695..8bf63e8a63c 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -732,7 +732,7 @@ const uchar *QResource::data() const \note If the data was compressed, this function will decompress every time it is called. The result is not cached between calls. - \sa uncompressedData(), size(), isCompressed(), isFile() + \sa uncompressedSize(), size(), isCompressed(), isFile() */ QByteArray QResource::uncompressedData() const From 1a9c29289a76454e8b361430dd7f025f8fdc3061 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 26 Feb 2020 14:19:18 +0100 Subject: [PATCH 17/38] Doc: Mark QColorSpace enum as introduced in Qt 5.15 Change-Id: Ibf2da1ebb4eb9520a2a507ed6afb89f7176391bb Reviewed-by: Allan Sandfeld Jensen --- src/corelib/kernel/qmetatype.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 662283f7374..99452eb6061 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -252,7 +252,7 @@ struct DefinedTypesFilter { \value QPolygon QPolygon \value QPolygonF QPolygonF \value QColor QColor - \value QColorSpace QColorSpace + \value QColorSpace QColorSpace (introduced in Qt 5.15) \value QSizeF QSizeF \value QRectF QRectF \value QLine QLine @@ -299,7 +299,7 @@ struct DefinedTypesFilter { \value QCborMap QCborMap \value QCborSimpleType QCborSimpleType \value QModelIndex QModelIndex - \value QPersistentModelIndex QPersistentModelIndex (since 5.5) + \value QPersistentModelIndex QPersistentModelIndex (introduced in Qt 5.5) \value QUuid QUuid \value QByteArrayList QByteArrayList From 249a2e3271c3cc36edb88c993d277d93de2cf1c0 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 4 Mar 2020 15:21:40 +0100 Subject: [PATCH 18/38] Disable warnings for the deprecated QLinkedList QLinkedList has been deprecated, but we still need to test it. Suppress the warnings for QLinkedList used in tests. Note, that I had to move some of the test code, to avoid repeating QT_WARNING_PUSH/QT_WARNING_POP everywhere. Change-Id: I4203b3ef50045c4f45475a08638dbdc60f68761d Reviewed-by: Lars Knoll --- .../tst_qtconcurrentfilter.cpp | 114 +- .../qtconcurrentmap/tst_qtconcurrentmap.cpp | 1203 +++++++++-------- .../corelib/kernel/qvariant/tst_qvariant.cpp | 5 + .../qdatastream/tst_qdatastream.cpp | 99 +- .../tools/collections/tst_collections.cpp | 52 + .../tst_containerapisymmetry.cpp | 50 +- .../tools/qlinkedlist/tst_qlinkedlist.cpp | 15 + 7 files changed, 918 insertions(+), 620 deletions(-) diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp index 84ebd468861..bd554465151 100644 --- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp +++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp @@ -62,18 +62,6 @@ void tst_QtConcurrentFilter::filter() QtConcurrent::blockingFilter(list, KeepEvenIntegers()); QCOMPARE(list, QList() << 2 << 4); } - { - QLinkedList linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::filter(linkedList, KeepEvenIntegers()).waitForFinished(); - QCOMPARE(linkedList, QLinkedList() << 2 << 4); - } - { - QLinkedList linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(linkedList, KeepEvenIntegers()); - QCOMPARE(linkedList, QLinkedList() << 2 << 4); - } { QVector vector; vector << 1 << 2 << 3 << 4; @@ -100,18 +88,6 @@ void tst_QtConcurrentFilter::filter() QtConcurrent::blockingFilter(list, keepEvenIntegers); QCOMPARE(list, QList() << 2 << 4); } - { - QLinkedList linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::filter(linkedList, keepEvenIntegers).waitForFinished(); - QCOMPARE(linkedList, QLinkedList() << 2 << 4); - } - { - QLinkedList linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(linkedList, keepEvenIntegers); - QCOMPARE(linkedList, QLinkedList() << 2 << 4); - } // bound function { @@ -126,18 +102,6 @@ void tst_QtConcurrentFilter::filter() QtConcurrent::blockingFilter(list, keepEvenIntegers); QCOMPARE(list, QList() << 2 << 4); } - { - QLinkedList linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::filter(linkedList, keepEvenIntegers).waitForFinished(); - QCOMPARE(linkedList, QLinkedList() << 2 << 4); - } - { - QLinkedList linkedList; - linkedList << 1 << 2 << 3 << 4; - QtConcurrent::blockingFilter(linkedList, keepEvenIntegers); - QCOMPARE(linkedList, QLinkedList() << 2 << 4); - } // member { @@ -152,6 +116,54 @@ void tst_QtConcurrentFilter::filter() QtConcurrent::blockingFilter(list, &Number::isEven); QCOMPARE(list, QList() << 2 << 4); } + +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + + // functor + { + QLinkedList linkedList; + linkedList << 1 << 2 << 3 << 4; + QtConcurrent::filter(linkedList, KeepEvenIntegers()).waitForFinished(); + QCOMPARE(linkedList, QLinkedList() << 2 << 4); + } + { + QLinkedList linkedList; + linkedList << 1 << 2 << 3 << 4; + QtConcurrent::blockingFilter(linkedList, KeepEvenIntegers()); + QCOMPARE(linkedList, QLinkedList() << 2 << 4); + } + + // function + { + QLinkedList linkedList; + linkedList << 1 << 2 << 3 << 4; + QtConcurrent::filter(linkedList, keepEvenIntegers).waitForFinished(); + QCOMPARE(linkedList, QLinkedList() << 2 << 4); + } + { + QLinkedList linkedList; + linkedList << 1 << 2 << 3 << 4; + QtConcurrent::blockingFilter(linkedList, keepEvenIntegers); + QCOMPARE(linkedList, QLinkedList() << 2 << 4); + } + + // bound function + { + QLinkedList linkedList; + linkedList << 1 << 2 << 3 << 4; + QtConcurrent::filter(linkedList, keepEvenIntegers).waitForFinished(); + QCOMPARE(linkedList, QLinkedList() << 2 << 4); + } + { + QLinkedList linkedList; + linkedList << 1 << 2 << 3 << 4; + QtConcurrent::blockingFilter(linkedList, keepEvenIntegers); + QCOMPARE(linkedList, QLinkedList() << 2 << 4); + } + + // member { QLinkedList linkedList; linkedList << 1 << 2 << 3 << 4; @@ -164,6 +176,9 @@ void tst_QtConcurrentFilter::filter() QtConcurrent::blockingFilter(linkedList, &Number::isEven); QCOMPARE(linkedList, QLinkedList() << 2 << 4); } + +QT_WARNING_POP +#endif } void tst_QtConcurrentFilter::filtered() @@ -219,19 +234,6 @@ void tst_QtConcurrentFilter::filtered() QCOMPARE(f.results(), QList() << 2 << 4); } - { - QLinkedList linkedList; - linkedList << 1 << 2 << 3 << 4; - QLinkedList linkedList2 = QtConcurrent::blockingFiltered(linkedList, KeepEvenIntegers()); - QCOMPARE(linkedList2, QLinkedList() << 2 << 4); - } - { - QLinkedList linkedList; - linkedList << 1 << 2 << 3 << 4; - QFuture f = QtConcurrent::filtered(linkedList, KeepEvenIntegers()); - QCOMPARE(f.results(), QList() << 2 << 4); - } - // function { QFuture f = QtConcurrent::filtered(list, keepEvenIntegers); @@ -352,6 +354,10 @@ void tst_QtConcurrentFilter::filtered() QCOMPARE(list2, QList() << 2 << 4); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + // same thing on linked lists QLinkedList linkedList; @@ -517,6 +523,9 @@ void tst_QtConcurrentFilter::filtered() &Number::isEven); QCOMPARE(linkedList2, QLinkedList() << 2 << 4); } + +QT_WARNING_POP +#endif } void tst_QtConcurrentFilter::filteredReduced() @@ -952,6 +961,10 @@ void tst_QtConcurrentFilter::filteredReduced() QCOMPARE(sum, 6); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + // same as above on linked lists QLinkedList linkedList; linkedList << 1 << 2 << 3 << 4; @@ -1378,6 +1391,9 @@ void tst_QtConcurrentFilter::filteredReduced() QCOMPARE(sum, 6); } +QT_WARNING_POP +#endif + // ### the same as above, with an initial result value } diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp index 383de0b2ce4..ad62f6cdf1c 100644 --- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -164,6 +164,9 @@ void tst_QtConcurrentMap::map() QCOMPARE(list, QList() << 1 << 2 << 3); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED // Linked lists and forward iterators { QLinkedList list; @@ -195,6 +198,8 @@ void tst_QtConcurrentMap::map() QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); QCOMPARE(numberList, QLinkedList() << 4 << 8 << 12); } +QT_WARNING_POP +#endif #if 0 // not allowed: map() with immutable sequences makes no sense @@ -296,6 +301,9 @@ void tst_QtConcurrentMap::blocking_map() QCOMPARE(list, QList() << 1 << 2 << 3); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED // Linked lists and forward iterators { QLinkedList list; @@ -327,6 +335,8 @@ void tst_QtConcurrentMap::blocking_map() QtConcurrent::blockingMap(numberList.begin(), numberList.end(), &Number::multiplyBy2); QCOMPARE(numberList, QLinkedList() << 4 << 8 << 12); } +QT_WARNING_POP +#endif #if 0 // not allowed: map() with immutable sequences makes no sense @@ -424,12 +434,8 @@ void tst_QtConcurrentMap::mapped() { QList list; list << 1 << 2 << 3; - QLinkedList linkedList; - linkedList << 1 << 2 << 3; QList numberList; numberList << 1 << 2 << 3; - QLinkedList numberLinkedList; - numberLinkedList << 1 << 2 << 3; // functor { @@ -447,22 +453,6 @@ void tst_QtConcurrentMap::mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 2 << 4 << 6); } - { - QList list2 = QtConcurrent::mapped(linkedList, MultiplyBy2()).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 2 << 4 << 6); - - QList list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - MultiplyBy2()).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 2 << 4 << 6); - - QList list4 = - QtConcurrent::mapped(QLinkedList(linkedList), MultiplyBy2()).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 2 << 4 << 6); - } // function { @@ -480,22 +470,6 @@ void tst_QtConcurrentMap::mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 2 << 4 << 6); } - { - QList list2 = QtConcurrent::mapped(linkedList, multiplyBy2).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 2 << 4 << 6); - - QList list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - multiplyBy2).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 2 << 4 << 6); - - QList list4 = - QtConcurrent::mapped(QLinkedList(linkedList), multiplyBy2).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 2 << 4 << 6); - } // bound function { @@ -513,23 +487,6 @@ void tst_QtConcurrentMap::mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 2 << 4 << 6); } - { - QList list2 = QtConcurrent::mapped(linkedList, multiplyBy2).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 2 << 4 << 6); - - QList list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - multiplyBy2) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 2 << 4 << 6); - - QList list4 = QtConcurrent::mapped(QLinkedList(linkedList), multiplyBy2) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 2 << 4 << 6); - } // const member function { @@ -551,25 +508,6 @@ void tst_QtConcurrentMap::mapped() QCOMPARE(numberList, QList() << 1 << 2 << 3); QCOMPARE(numberList4, QList() << 2 << 4 << 6); } - { - QList numberList2 = QtConcurrent::mapped(numberLinkedList, &Number::multipliedBy2) - .results(); - QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(numberList2, QList() << 2 << 4 << 6); - - QList numberList3 = QtConcurrent::mapped(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::multipliedBy2) - .results(); - QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(numberList3, QList() << 2 << 4 << 6); - - QList numberList4 = QtConcurrent::mapped(QLinkedList(numberLinkedList), - &Number::multipliedBy2) - .results(); - QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(numberList4, QList() << 2 << 4 << 6); - } // change the value_type, same container @@ -592,24 +530,6 @@ void tst_QtConcurrentMap::mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); } - { - QList list2 = QtConcurrent::mapped(linkedList, IntToDouble()).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 1.0 << 2.0 << 3.0); - - QList list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - IntToDouble()) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 1.0 << 2.0 << 3.0); - - QList list4 = QtConcurrent::mapped(QLinkedList(linkedList), - IntToDouble()) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); - } // function { @@ -628,23 +548,6 @@ void tst_QtConcurrentMap::mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); } - { - QList list2 = QtConcurrent::mapped(linkedList, intToDouble).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 1.0 << 2.0 << 3.0); - - QList list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - intToDouble) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 1.0 << 2.0 << 3.0); - - QList list4 = QtConcurrent::mapped(QLinkedList(linkedList), intToDouble) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); - } // bound function { @@ -666,25 +569,6 @@ void tst_QtConcurrentMap::mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); } - { - QList list2 = QtConcurrent::mapped(linkedList, intToDouble).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 1.0 << 2.0 << 3.0); - - QList list3 = QtConcurrent::mapped(linkedList.constBegin(), - linkedList.constEnd(), - intToDouble) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 1.0 << 2.0 << 3.0); - - - QList list4 = QtConcurrent::mapped(QLinkedList(linkedList), - intToDouble) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); - } // const member function { @@ -704,24 +588,6 @@ void tst_QtConcurrentMap::mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << "1" << "2" << "3"); } - { - QList list2 = QtConcurrent::mapped(numberLinkedList, &Number::toString).results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << "1" << "2" << "3"); - - QList list3 = QtConcurrent::mapped(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::toString) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << "1" << "2" << "3"); - - QList list4 = QtConcurrent::mapped(QLinkedList(numberLinkedList), - &Number::toString) - .results(); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << "1" << "2" << "3"); - } // change the value_type { @@ -780,18 +646,183 @@ void tst_QtConcurrentMap::mapped() .results(); QCOMPARE(list2, QList() << 1 << 2 << 3); } + +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + + QLinkedList linkedList; + linkedList << 1 << 2 << 3; + QLinkedList numberLinkedList; + numberLinkedList << 1 << 2 << 3; + + // functor + { + QList list2 = QtConcurrent::mapped(linkedList, MultiplyBy2()).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 2 << 4 << 6); + + QList list3 = QtConcurrent::mapped(linkedList.constBegin(), + linkedList.constEnd(), + MultiplyBy2()).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 2 << 4 << 6); + + QList list4 = + QtConcurrent::mapped(QLinkedList(linkedList), MultiplyBy2()).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 2 << 4 << 6); + } + + // function + { + QList list2 = QtConcurrent::mapped(linkedList, multiplyBy2).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 2 << 4 << 6); + + QList list3 = QtConcurrent::mapped(linkedList.constBegin(), + linkedList.constEnd(), + multiplyBy2).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 2 << 4 << 6); + + QList list4 = + QtConcurrent::mapped(QLinkedList(linkedList), multiplyBy2).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 2 << 4 << 6); + } + + // bound function + { + QList list2 = QtConcurrent::mapped(linkedList, multiplyBy2).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 2 << 4 << 6); + + QList list3 = QtConcurrent::mapped(linkedList.constBegin(), + linkedList.constEnd(), + multiplyBy2) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 2 << 4 << 6); + + QList list4 = QtConcurrent::mapped(QLinkedList(linkedList), multiplyBy2) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 2 << 4 << 6); + } + + // const member function + { + QList numberList2 = QtConcurrent::mapped(numberLinkedList, &Number::multipliedBy2) + .results(); + QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(numberList2, QList() << 2 << 4 << 6); + + QList numberList3 = QtConcurrent::mapped(numberLinkedList.constBegin(), + numberLinkedList.constEnd(), + &Number::multipliedBy2) + .results(); + QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(numberList3, QList() << 2 << 4 << 6); + + QList numberList4 = QtConcurrent::mapped(QLinkedList(numberLinkedList), + &Number::multipliedBy2) + .results(); + QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(numberList4, QList() << 2 << 4 << 6); + } + + // change the value_type, same container + + // functor + { + QList list2 = QtConcurrent::mapped(linkedList, IntToDouble()).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 1.0 << 2.0 << 3.0); + + QList list3 = QtConcurrent::mapped(linkedList.constBegin(), + linkedList.constEnd(), + IntToDouble()) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 1.0 << 2.0 << 3.0); + + QList list4 = QtConcurrent::mapped(QLinkedList(linkedList), + IntToDouble()) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); + } + + // function + { + QList list2 = QtConcurrent::mapped(linkedList, intToDouble).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 1.0 << 2.0 << 3.0); + + QList list3 = QtConcurrent::mapped(linkedList.constBegin(), + linkedList.constEnd(), + intToDouble) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 1.0 << 2.0 << 3.0); + + QList list4 = QtConcurrent::mapped(QLinkedList(linkedList), intToDouble) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); + } + + // bound function + { + QList list2 = QtConcurrent::mapped(linkedList, intToDouble).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 1.0 << 2.0 << 3.0); + + QList list3 = QtConcurrent::mapped(linkedList.constBegin(), + linkedList.constEnd(), + intToDouble) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 1.0 << 2.0 << 3.0); + + + QList list4 = QtConcurrent::mapped(QLinkedList(linkedList), + intToDouble) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); + } + + // const member function + { + QList list2 = QtConcurrent::mapped(numberLinkedList, &Number::toString).results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << "1" << "2" << "3"); + + QList list3 = QtConcurrent::mapped(numberLinkedList.constBegin(), + numberLinkedList.constEnd(), + &Number::toString) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << "1" << "2" << "3"); + + QList list4 = QtConcurrent::mapped(QLinkedList(numberLinkedList), + &Number::toString) + .results(); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << "1" << "2" << "3"); + } +QT_WARNING_POP +#endif } void tst_QtConcurrentMap::blocking_mapped() { QList list; list << 1 << 2 << 3; - QLinkedList linkedList; - linkedList << 1 << 2 << 3; QList numberList; numberList << 1 << 2 << 3; - QLinkedList numberLinkedList; - numberLinkedList << 1 << 2 << 3; // functor { @@ -809,21 +840,6 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 2 << 4 << 6); } - { - QLinkedList linkedList2 = QtConcurrent::blockingMapped(linkedList, MultiplyBy2()); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList() << 2 << 4 << 6); - - QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), - linkedList.constEnd(), - MultiplyBy2()); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList() << 2 << 4 << 6); - - QLinkedList linkedList4 = QtConcurrent::blockingMapped(QLinkedList(linkedList), MultiplyBy2()); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList() << 2 << 4 << 6); - } // function { @@ -841,21 +857,6 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 2 << 4 << 6); } - { - QLinkedList linkedList2 = QtConcurrent::blockingMapped(linkedList, multiplyBy2); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList() << 2 << 4 << 6); - - QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), - linkedList.constEnd(), - multiplyBy2); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList() << 2 << 4 << 6); - - QLinkedList linkedList4 = QtConcurrent::blockingMapped(QLinkedList(linkedList), multiplyBy2); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList() << 2 << 4 << 6); - } // bound function { @@ -873,21 +874,6 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 2 << 4 << 6); } - { - QLinkedList linkedList2 = QtConcurrent::blockingMapped(linkedList, multiplyBy2); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList() << 2 << 4 << 6); - - QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), - linkedList.constEnd(), - multiplyBy2); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList() << 2 << 4 << 6); - - QLinkedList linkedList4 = QtConcurrent::blockingMapped(QLinkedList(linkedList), multiplyBy2); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList() << 2 << 4 << 6); - } // const member function { @@ -906,22 +892,6 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(numberList, QList() << 1 << 2 << 3); QCOMPARE(numberList4, QList() << 2 << 4 << 6); } - { - QLinkedList numberLinkedList2 = QtConcurrent::blockingMapped(numberLinkedList, &Number::multipliedBy2); - QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(numberLinkedList2, QLinkedList() << 2 << 4 << 6); - - QLinkedList numberLinkedList3 = QtConcurrent::blockingMapped >(numberLinkedList.constBegin(), - numberLinkedList.constEnd(), - &Number::multipliedBy2); - QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(numberLinkedList3, QLinkedList() << 2 << 4 << 6); - - QLinkedList numberLinkedList4 = QtConcurrent::blockingMapped(QLinkedList(numberLinkedList), - &Number::multipliedBy2); - QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(numberLinkedList4, QLinkedList() << 2 << 4 << 6); - } // change the value_type, same container @@ -942,22 +912,6 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); } - { - QLinkedList linkedList2 = QtConcurrent::blockingMapped >(linkedList, IntToDouble()); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList() << 1.0 << 2.0 << 3.0); - - QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), - linkedList.constEnd(), - IntToDouble()); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList() << 1.0 << 2.0 << 3.0); - - QLinkedList linkedList4 = QtConcurrent::blockingMapped >(QLinkedList(linkedList), - IntToDouble()); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList() << 1.0 << 2.0 << 3.0); - } // function { @@ -975,21 +929,6 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); } - { - QLinkedList linkedList2 = QtConcurrent::blockingMapped >(linkedList, intToDouble); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList() << 1.0 << 2.0 << 3.0); - - QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), - linkedList.constEnd(), - intToDouble); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList() << 1.0 << 2.0 << 3.0); - - QLinkedList linkedList4 = QtConcurrent::blockingMapped >(QLinkedList(linkedList), intToDouble); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList() << 1.0 << 2.0 << 3.0); - } // bound function { @@ -1009,23 +948,6 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << 1.0 << 2.0 << 3.0); } - { - QLinkedList linkedList2 = QtConcurrent::blockingMapped >(linkedList, intToDouble); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList() << 1.0 << 2.0 << 3.0); - - QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), - linkedList.constEnd(), - intToDouble); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList() << 1.0 << 2.0 << 3.0); - - - QLinkedList linkedList4 = QtConcurrent::blockingMapped >(QLinkedList(linkedList), - intToDouble); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList() << 1.0 << 2.0 << 3.0); - } // const member function { @@ -1045,23 +967,6 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(list, QList() << 1 << 2 << 3); QCOMPARE(list4, QList() << "1" << "2" << "3"); } - { - QLinkedList linkedList2 = - QtConcurrent::blockingMapped >(numberLinkedList, &Number::toString); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList2, QLinkedList() << "1" << "2" << "3"); - - QLinkedList linkedList3 = QtConcurrent::blockingMapped >(numberLinkedList.constBegin(), - numberLinkedList.constEnd() - , &Number::toString); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList3, QLinkedList() << "1" << "2" << "3"); - - QLinkedList linkedList4 = - QtConcurrent::blockingMapped >(QLinkedList(numberLinkedList), &Number::toString); - QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); - QCOMPARE(linkedList4, QLinkedList() << "1" << "2" << "3"); - } // change the value_type { @@ -1218,6 +1123,162 @@ void tst_QtConcurrentMap::blocking_mapped() QCOMPARE(list5, QVector() << 1 << 2 << 3); #endif } + +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + + QLinkedList linkedList; + linkedList << 1 << 2 << 3; + QLinkedList numberLinkedList; + numberLinkedList << 1 << 2 << 3; + + // functor + { + QLinkedList linkedList2 = QtConcurrent::blockingMapped(linkedList, MultiplyBy2()); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList2, QLinkedList() << 2 << 4 << 6); + + QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), + linkedList.constEnd(), + MultiplyBy2()); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList3, QLinkedList() << 2 << 4 << 6); + + QLinkedList linkedList4 = QtConcurrent::blockingMapped(QLinkedList(linkedList), MultiplyBy2()); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList4, QLinkedList() << 2 << 4 << 6); + } + + // function + { + QLinkedList linkedList2 = QtConcurrent::blockingMapped(linkedList, multiplyBy2); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList2, QLinkedList() << 2 << 4 << 6); + + QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), + linkedList.constEnd(), + multiplyBy2); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList3, QLinkedList() << 2 << 4 << 6); + + QLinkedList linkedList4 = QtConcurrent::blockingMapped(QLinkedList(linkedList), multiplyBy2); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList4, QLinkedList() << 2 << 4 << 6); + } + + // bound function + { + QLinkedList linkedList2 = QtConcurrent::blockingMapped(linkedList, multiplyBy2); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList2, QLinkedList() << 2 << 4 << 6); + + QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), + linkedList.constEnd(), + multiplyBy2); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList3, QLinkedList() << 2 << 4 << 6); + + QLinkedList linkedList4 = QtConcurrent::blockingMapped(QLinkedList(linkedList), multiplyBy2); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList4, QLinkedList() << 2 << 4 << 6); + } + + // const member function + { + QLinkedList numberLinkedList2 = QtConcurrent::blockingMapped(numberLinkedList, &Number::multipliedBy2); + QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(numberLinkedList2, QLinkedList() << 2 << 4 << 6); + + QLinkedList numberLinkedList3 = QtConcurrent::blockingMapped >(numberLinkedList.constBegin(), + numberLinkedList.constEnd(), + &Number::multipliedBy2); + QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(numberLinkedList3, QLinkedList() << 2 << 4 << 6); + + QLinkedList numberLinkedList4 = QtConcurrent::blockingMapped(QLinkedList(numberLinkedList), + &Number::multipliedBy2); + QCOMPARE(numberLinkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(numberLinkedList4, QLinkedList() << 2 << 4 << 6); + } + + // change the value_type, same container + + // functor + { + QLinkedList linkedList2 = QtConcurrent::blockingMapped >(linkedList, IntToDouble()); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList2, QLinkedList() << 1.0 << 2.0 << 3.0); + + QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), + linkedList.constEnd(), + IntToDouble()); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList3, QLinkedList() << 1.0 << 2.0 << 3.0); + + QLinkedList linkedList4 = QtConcurrent::blockingMapped >(QLinkedList(linkedList), + IntToDouble()); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList4, QLinkedList() << 1.0 << 2.0 << 3.0); + } + + // function + { + QLinkedList linkedList2 = QtConcurrent::blockingMapped >(linkedList, intToDouble); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList2, QLinkedList() << 1.0 << 2.0 << 3.0); + + QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), + linkedList.constEnd(), + intToDouble); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList3, QLinkedList() << 1.0 << 2.0 << 3.0); + + QLinkedList linkedList4 = QtConcurrent::blockingMapped >(QLinkedList(linkedList), intToDouble); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList4, QLinkedList() << 1.0 << 2.0 << 3.0); + } + + // bound function + { + QLinkedList linkedList2 = QtConcurrent::blockingMapped >(linkedList, intToDouble); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList2, QLinkedList() << 1.0 << 2.0 << 3.0); + + QLinkedList linkedList3 = QtConcurrent::blockingMapped >(linkedList.constBegin(), + linkedList.constEnd(), + intToDouble); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList3, QLinkedList() << 1.0 << 2.0 << 3.0); + + + QLinkedList linkedList4 = QtConcurrent::blockingMapped >(QLinkedList(linkedList), + intToDouble); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList4, QLinkedList() << 1.0 << 2.0 << 3.0); + } + + // const member function + { + QLinkedList linkedList2 = + QtConcurrent::blockingMapped >(numberLinkedList, &Number::toString); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList2, QLinkedList() << "1" << "2" << "3"); + + QLinkedList linkedList3 = QtConcurrent::blockingMapped >(numberLinkedList.constBegin(), + numberLinkedList.constEnd() + , &Number::toString); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList3, QLinkedList() << "1" << "2" << "3"); + + QLinkedList linkedList4 = + QtConcurrent::blockingMapped >(QLinkedList(numberLinkedList), &Number::toString); + QCOMPARE(linkedList, QLinkedList() << 1 << 2 << 3); + QCOMPARE(linkedList4, QLinkedList() << "1" << "2" << "3"); + } + +QT_WARNING_POP +#endif } int intSquare(int x) @@ -1240,12 +1301,8 @@ void tst_QtConcurrentMap::mappedReduced() { QList list; list << 1 << 2 << 3; - QLinkedList linkedList; - linkedList << 1 << 2 << 3; QList numberList; numberList << 1 << 2 << 3; - QLinkedList numberLinkedList; - numberLinkedList << 1 << 2 << 3; // test Q_DECLARE_OPERATORS_FOR_FLAGS QtConcurrent::ReduceOptions opt = (QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce); @@ -1277,6 +1334,164 @@ void tst_QtConcurrentMap::mappedReduced() intSumReduce); QCOMPARE(sum6, 14); } + + // function-functor + { + int sum = QtConcurrent::mappedReduced(list, intSquare, IntSumReduce()); + QCOMPARE(sum, 14); + int sum2 = QtConcurrent::mappedReduced(list.constBegin(), + list.constEnd(), + intSquare, + IntSumReduce()); + QCOMPARE(sum2, 14); + + int sum3 = QtConcurrent::mappedReduced(QList(list), intSquare, IntSumReduce()); + QCOMPARE(sum3, 14); + } + + // functor-function + { + int sum = QtConcurrent::mappedReduced(list, IntSquare(), intSumReduce); + QCOMPARE(sum, 14); + int sum2 = QtConcurrent::mappedReduced(list.constBegin(), + list.constEnd(), + IntSquare(), + intSumReduce); + QCOMPARE(sum2, 14); + + int sum3 = QtConcurrent::mappedReduced(QList(list), IntSquare(), intSumReduce); + QCOMPARE(sum3, 14); + } + + // function-function + { + int sum = QtConcurrent::mappedReduced(list, intSquare, intSumReduce); + QCOMPARE(sum, 14); + int sum2 = QtConcurrent::mappedReduced(list.constBegin(), + list.constEnd(), + intSquare, + intSumReduce); + QCOMPARE(sum2, 14); + + int sum3 = QtConcurrent::mappedReduced(QList(list), intSquare, intSumReduce); + QCOMPARE(sum3, 14); + } + + // functor-member + { + QList list2 = QtConcurrent::mappedReduced(list, + IntSquare(), + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 1 << 4 << 9); + + QList list3 = QtConcurrent::mappedReduced(list.constBegin(), + list.constEnd(), + IntSquare(), + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 1 << 4 << 9); + + QList list4 = QtConcurrent::mappedReduced(QList(list), + IntSquare(), + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 1 << 4 << 9); + } + + // member-functor + { + int sum = QtConcurrent::mappedReduced(numberList, &Number::toInt, IntSumReduce()); + QCOMPARE(sum, 6); + int sum2 = QtConcurrent::mappedReduced(numberList.constBegin(), + numberList.constEnd(), + &Number::toInt, + IntSumReduce()); + QCOMPARE(sum2, 6); + + int sum3 = QtConcurrent::mappedReduced(QList(numberList), + &Number::toInt, + IntSumReduce()); + QCOMPARE(sum3, 6); + } + + // member-member + { + QList list2 = QtConcurrent::mappedReduced(numberList, + &Number::toInt, + &QList::push_back, + OrderedReduce); + QCOMPARE(list2, QList() << 1 << 2 << 3); + + QList list3 = QtConcurrent::mappedReduced(numberList.constBegin(), + numberList.constEnd(), + &Number::toInt, + &QList::push_back, + OrderedReduce); + QCOMPARE(list3, QList() << 1 << 2 << 3); + + QList list4 = QtConcurrent::mappedReduced(QList(numberList), + &Number::toInt, + &QList::push_back, OrderedReduce); + QCOMPARE(list4, QList() << 1 << 2 << 3); + } + + // function-member + { + QList list2 = QtConcurrent::mappedReduced(list, + intSquare, + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 1 << 4 << 9); + + QList list3 = QtConcurrent::mappedReduced(list.constBegin(), + list.constEnd(), + intSquare, + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 1 << 4 << 9); + + QList list4 = QtConcurrent::mappedReduced(QList(list), + intSquare, + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 1 << 4 << 9); + } + + // member-function + { + int sum = QtConcurrent::mappedReduced(numberList, + &Number::toInt, + intSumReduce); + QCOMPARE(sum, 6); + int sum2 = QtConcurrent::mappedReduced(numberList.constBegin(), + numberList.constEnd(), + &Number::toInt, + intSumReduce); + QCOMPARE(sum2, 6); + + int sum3 = QtConcurrent::mappedReduced(QList(numberList), + &Number::toInt, + intSumReduce); + QCOMPARE(sum3, 6); + } + +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + + QLinkedList linkedList; + linkedList << 1 << 2 << 3; + QLinkedList numberLinkedList; + numberLinkedList << 1 << 2 << 3; + + // functor-functor { int sum = QtConcurrent::mappedReduced(linkedList, IntSquare(), IntSumReduce()); QCOMPARE(sum, 14); @@ -1304,18 +1519,6 @@ void tst_QtConcurrentMap::mappedReduced() } // function-functor - { - int sum = QtConcurrent::mappedReduced(list, intSquare, IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced(QList(list), intSquare, IntSumReduce()); - QCOMPARE(sum3, 14); - } { int sum = QtConcurrent::mappedReduced(linkedList, intSquare, IntSumReduce()); QCOMPARE(sum, 14); @@ -1330,18 +1533,6 @@ void tst_QtConcurrentMap::mappedReduced() } // functor-function - { - int sum = QtConcurrent::mappedReduced(list, IntSquare(), intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - IntSquare(), - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced(QList(list), IntSquare(), intSumReduce); - QCOMPARE(sum3, 14); - } { int sum = QtConcurrent::mappedReduced(linkedList, IntSquare(), intSumReduce); QCOMPARE(sum, 14); @@ -1356,18 +1547,6 @@ void tst_QtConcurrentMap::mappedReduced() } // function-function - { - int sum = QtConcurrent::mappedReduced(list, intSquare, intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::mappedReduced(QList(list), intSquare, intSumReduce); - QCOMPARE(sum3, 14); - } { int sum = QtConcurrent::mappedReduced(linkedList, intSquare, intSumReduce); QCOMPARE(sum, 14); @@ -1382,29 +1561,6 @@ void tst_QtConcurrentMap::mappedReduced() } // functor-member - { - QList list2 = QtConcurrent::mappedReduced(list, - IntSquare(), - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 1 << 4 << 9); - - QList list3 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - IntSquare(), - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 1 << 4 << 9); - - QList list4 = QtConcurrent::mappedReduced(QList(list), - IntSquare(), - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 1 << 4 << 9); - } { QLinkedList linkedList2 = QtConcurrent::mappedReduced(linkedList, IntSquare(), @@ -1430,20 +1586,6 @@ void tst_QtConcurrentMap::mappedReduced() } // member-functor - { - int sum = QtConcurrent::mappedReduced(numberList, &Number::toInt, IntSumReduce()); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::mappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::mappedReduced(QList(numberList), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum3, 6); - } { int sum = QtConcurrent::mappedReduced(numberLinkedList, &Number::toInt, IntSumReduce()); QCOMPARE(sum, 6); @@ -1460,25 +1602,6 @@ void tst_QtConcurrentMap::mappedReduced() } // member-member - { - QList list2 = QtConcurrent::mappedReduced(numberList, - &Number::toInt, - &QList::push_back, - OrderedReduce); - QCOMPARE(list2, QList() << 1 << 2 << 3); - - QList list3 = QtConcurrent::mappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - &QList::push_back, - OrderedReduce); - QCOMPARE(list3, QList() << 1 << 2 << 3); - - QList list4 = QtConcurrent::mappedReduced(QList(numberList), - &Number::toInt, - &QList::push_back, OrderedReduce); - QCOMPARE(list4, QList() << 1 << 2 << 3); - } { QLinkedList linkedList2 = QtConcurrent::mappedReduced(numberLinkedList, &Number::toInt, @@ -1500,29 +1623,6 @@ void tst_QtConcurrentMap::mappedReduced() } // function-member - { - QList list2 = QtConcurrent::mappedReduced(list, - intSquare, - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 1 << 4 << 9); - - QList list3 = QtConcurrent::mappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 1 << 4 << 9); - - QList list4 = QtConcurrent::mappedReduced(QList(list), - intSquare, - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 1 << 4 << 9); - } { QLinkedList linkedList2 = QtConcurrent::mappedReduced(linkedList, intSquare, @@ -1548,22 +1648,6 @@ void tst_QtConcurrentMap::mappedReduced() } // member-function - { - int sum = QtConcurrent::mappedReduced(numberList, - &Number::toInt, - intSumReduce); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::mappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - intSumReduce); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::mappedReduced(QList(numberList), - &Number::toInt, - intSumReduce); - QCOMPARE(sum3, 6); - } { int sum = QtConcurrent::mappedReduced(numberLinkedList, &Number::toInt, @@ -1615,6 +1699,9 @@ void tst_QtConcurrentMap::mappedReduced() QCOMPARE(sum6, 14); } +QT_WARNING_POP +#endif + // ### the same as above, with an initial result value } @@ -1622,12 +1709,8 @@ void tst_QtConcurrentMap::blocking_mappedReduced() { QList list; list << 1 << 2 << 3; - QLinkedList linkedList; - linkedList << 1 << 2 << 3; QList numberList; numberList << 1 << 2 << 3; - QLinkedList numberLinkedList; - numberLinkedList << 1 << 2 << 3; // functor-functor { @@ -1655,6 +1738,165 @@ void tst_QtConcurrentMap::blocking_mappedReduced() intSumReduce); QCOMPARE(sum6, 14); } + + // function-functor + { + int sum = QtConcurrent::blockingMappedReduced(list, intSquare, IntSumReduce()); + QCOMPARE(sum, 14); + int sum2 = QtConcurrent::blockingMappedReduced(list.constBegin(), + list.constEnd(), + intSquare, + IntSumReduce()); + QCOMPARE(sum2, 14); + + int sum3 = QtConcurrent::blockingMappedReduced(QList(list), intSquare, IntSumReduce()); + QCOMPARE(sum3, 14); + } + + // functor-function + { + int sum = QtConcurrent::blockingMappedReduced(list, IntSquare(), intSumReduce); + QCOMPARE(sum, 14); + int sum2 = QtConcurrent::blockingMappedReduced(list.constBegin(), + list.constEnd(), + IntSquare(), + intSumReduce); + QCOMPARE(sum2, 14); + + int sum3 = QtConcurrent::blockingMappedReduced(QList(list), IntSquare(), intSumReduce); + QCOMPARE(sum3, 14); + } + + // function-function + { + int sum = QtConcurrent::blockingMappedReduced(list, intSquare, intSumReduce); + QCOMPARE(sum, 14); + int sum2 = QtConcurrent::blockingMappedReduced(list.constBegin(), + list.constEnd(), + intSquare, + intSumReduce); + QCOMPARE(sum2, 14); + + int sum3 = QtConcurrent::blockingMappedReduced(QList(list), intSquare, intSumReduce); + QCOMPARE(sum3, 14); + } + + // functor-member + { + QList list2 = QtConcurrent::blockingMappedReduced(list, + IntSquare(), + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 1 << 4 << 9); + + QList list3 = QtConcurrent::blockingMappedReduced(list.constBegin(), + list.constEnd(), + IntSquare(), + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 1 << 4 << 9); + + QList list4 = QtConcurrent::blockingMappedReduced(QList(list), + IntSquare(), + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 1 << 4 << 9); + } + + // member-functor + { + int sum = QtConcurrent::blockingMappedReduced(numberList, &Number::toInt, + IntSumReduce()); + QCOMPARE(sum, 6); + int sum2 = QtConcurrent::blockingMappedReduced(numberList.constBegin(), + numberList.constEnd(), + &Number::toInt, + IntSumReduce()); + QCOMPARE(sum2, 6); + + int sum3 = QtConcurrent::blockingMappedReduced(QList(numberList), + &Number::toInt, + IntSumReduce()); + QCOMPARE(sum3, 6); + } + + // member-member + { + QList list2 = QtConcurrent::blockingMappedReduced(numberList, + &Number::toInt, + &QList::push_back, + OrderedReduce); + QCOMPARE(list2, QList() << 1 << 2 << 3); + + QList list3 = QtConcurrent::blockingMappedReduced(numberList.constBegin(), + numberList.constEnd(), + &Number::toInt, + &QList::push_back, + OrderedReduce); + QCOMPARE(list3, QList() << 1 << 2 << 3); + + QList list4 = QtConcurrent::blockingMappedReduced(QList(numberList), + &Number::toInt, + &QList::push_back, OrderedReduce); + QCOMPARE(list4, QList() << 1 << 2 << 3); + } + + // function-member + { + QList list2 = QtConcurrent::blockingMappedReduced(list, + intSquare, + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list2, QList() << 1 << 4 << 9); + + QList list3 = QtConcurrent::blockingMappedReduced(list.constBegin(), + list.constEnd(), + intSquare, + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list3, QList() << 1 << 4 << 9); + + QList list4 = QtConcurrent::blockingMappedReduced(QList(list), + intSquare, + &QList::push_back, + OrderedReduce); + QCOMPARE(list, QList() << 1 << 2 << 3); + QCOMPARE(list4, QList() << 1 << 4 << 9); + } + + // member-function + { + int sum = QtConcurrent::blockingMappedReduced(numberList, + &Number::toInt, + intSumReduce); + QCOMPARE(sum, 6); + int sum2 = QtConcurrent::blockingMappedReduced(numberList.constBegin(), + numberList.constEnd(), + &Number::toInt, + intSumReduce); + QCOMPARE(sum2, 6); + + int sum3 = QtConcurrent::blockingMappedReduced(QList(numberList), + &Number::toInt, + intSumReduce); + QCOMPARE(sum3, 6); + } + +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + + QLinkedList linkedList; + linkedList << 1 << 2 << 3; + QLinkedList numberLinkedList; + numberLinkedList << 1 << 2 << 3; + + // functor-functor { int sum = QtConcurrent::blockingMappedReduced(linkedList, IntSquare(), IntSumReduce()); QCOMPARE(sum, 14); @@ -1682,18 +1924,6 @@ void tst_QtConcurrentMap::blocking_mappedReduced() } // function-functor - { - int sum = QtConcurrent::blockingMappedReduced(list, intSquare, IntSumReduce()); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - IntSumReduce()); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced(QList(list), intSquare, IntSumReduce()); - QCOMPARE(sum3, 14); - } { int sum = QtConcurrent::blockingMappedReduced(linkedList, intSquare, IntSumReduce()); QCOMPARE(sum, 14); @@ -1708,18 +1938,6 @@ void tst_QtConcurrentMap::blocking_mappedReduced() } // functor-function - { - int sum = QtConcurrent::blockingMappedReduced(list, IntSquare(), intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - IntSquare(), - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced(QList(list), IntSquare(), intSumReduce); - QCOMPARE(sum3, 14); - } { int sum = QtConcurrent::blockingMappedReduced(linkedList, IntSquare(), intSumReduce); QCOMPARE(sum, 14); @@ -1734,18 +1952,6 @@ void tst_QtConcurrentMap::blocking_mappedReduced() } // function-function - { - int sum = QtConcurrent::blockingMappedReduced(list, intSquare, intSumReduce); - QCOMPARE(sum, 14); - int sum2 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - intSumReduce); - QCOMPARE(sum2, 14); - - int sum3 = QtConcurrent::blockingMappedReduced(QList(list), intSquare, intSumReduce); - QCOMPARE(sum3, 14); - } { int sum = QtConcurrent::blockingMappedReduced(linkedList, intSquare, intSumReduce); QCOMPARE(sum, 14); @@ -1760,29 +1966,6 @@ void tst_QtConcurrentMap::blocking_mappedReduced() } // functor-member - { - QList list2 = QtConcurrent::blockingMappedReduced(list, - IntSquare(), - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 1 << 4 << 9); - - QList list3 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - IntSquare(), - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 1 << 4 << 9); - - QList list4 = QtConcurrent::blockingMappedReduced(QList(list), - IntSquare(), - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 1 << 4 << 9); - } { QLinkedList linkedList2 = QtConcurrent::blockingMappedReduced(linkedList, IntSquare(), @@ -1808,21 +1991,6 @@ void tst_QtConcurrentMap::blocking_mappedReduced() } // member-functor - { - int sum = QtConcurrent::blockingMappedReduced(numberList, &Number::toInt, - IntSumReduce()); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::blockingMappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::blockingMappedReduced(QList(numberList), - &Number::toInt, - IntSumReduce()); - QCOMPARE(sum3, 6); - } { int sum = QtConcurrent::blockingMappedReduced(numberLinkedList, &Number::toInt, IntSumReduce()); QCOMPARE(sum, 6); @@ -1839,25 +2007,6 @@ void tst_QtConcurrentMap::blocking_mappedReduced() } // member-member - { - QList list2 = QtConcurrent::blockingMappedReduced(numberList, - &Number::toInt, - &QList::push_back, - OrderedReduce); - QCOMPARE(list2, QList() << 1 << 2 << 3); - - QList list3 = QtConcurrent::blockingMappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - &QList::push_back, - OrderedReduce); - QCOMPARE(list3, QList() << 1 << 2 << 3); - - QList list4 = QtConcurrent::blockingMappedReduced(QList(numberList), - &Number::toInt, - &QList::push_back, OrderedReduce); - QCOMPARE(list4, QList() << 1 << 2 << 3); - } { QLinkedList linkedList2 = QtConcurrent::blockingMappedReduced(numberLinkedList, &Number::toInt, @@ -1879,29 +2028,6 @@ void tst_QtConcurrentMap::blocking_mappedReduced() } // function-member - { - QList list2 = QtConcurrent::blockingMappedReduced(list, - intSquare, - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list2, QList() << 1 << 4 << 9); - - QList list3 = QtConcurrent::blockingMappedReduced(list.constBegin(), - list.constEnd(), - intSquare, - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list3, QList() << 1 << 4 << 9); - - QList list4 = QtConcurrent::blockingMappedReduced(QList(list), - intSquare, - &QList::push_back, - OrderedReduce); - QCOMPARE(list, QList() << 1 << 2 << 3); - QCOMPARE(list4, QList() << 1 << 4 << 9); - } { QLinkedList linkedList2 = QtConcurrent::blockingMappedReduced(linkedList, intSquare, @@ -1927,22 +2053,6 @@ void tst_QtConcurrentMap::blocking_mappedReduced() } // member-function - { - int sum = QtConcurrent::blockingMappedReduced(numberList, - &Number::toInt, - intSumReduce); - QCOMPARE(sum, 6); - int sum2 = QtConcurrent::blockingMappedReduced(numberList.constBegin(), - numberList.constEnd(), - &Number::toInt, - intSumReduce); - QCOMPARE(sum2, 6); - - int sum3 = QtConcurrent::blockingMappedReduced(QList(numberList), - &Number::toInt, - intSumReduce); - QCOMPARE(sum3, 6); - } { int sum = QtConcurrent::blockingMappedReduced(numberLinkedList, &Number::toInt, @@ -1994,6 +2104,9 @@ void tst_QtConcurrentMap::blocking_mappedReduced() QCOMPARE(sum6, 14); } +QT_WARNING_POP +#endif + // ### the same as above, with an initial result value } diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 5af1353a0fd..70bda1a0efd 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -3885,12 +3885,17 @@ void tst_QVariant::moreCustomTypes() PLAY_WITH_VARIANT(data, false, QString(), 0, false); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED { QList > data; PLAY_WITH_VARIANT(data, false, QString(), 0, false); data << (QLinkedList() << 42); PLAY_WITH_VARIANT(data, false, QString(), 0, false); } +QT_WARNING_POP +#endif } void tst_QVariant::movabilityTest() diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index aed84cb14e3..ff2e98e7302 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -3063,24 +3063,6 @@ void tst_QDataStream::status_QHash_QMap() QVERIFY(list.isEmpty()); \ } \ } \ - { \ - LinkedList expectedLinkedList; \ - for (int i = 0; i < expectedList.count(); ++i) \ - expectedLinkedList << expectedList.at(i); \ - QByteArray ba = byteArray; \ - QDataStream stream(&ba, QIODevice::ReadOnly); \ - if (inTransaction) \ - stream.startTransaction(); \ - stream.setStatus(initialStatus); \ - stream >> linkedList; \ - QCOMPARE((int)stream.status(), (int)expectedStatus); \ - if (!inTransaction || stream.commitTransaction()) { \ - QCOMPARE(linkedList.size(), expectedLinkedList.size()); \ - QCOMPARE(linkedList, expectedLinkedList); \ - } else { \ - QVERIFY(linkedList.isEmpty()); \ - } \ - } \ { \ Vector expectedVector; \ for (int i = 0; i < expectedList.count(); ++i) \ @@ -3103,12 +3085,34 @@ void tst_QDataStream::status_QHash_QMap() break; \ } +#define LINKED_LIST_TEST(byteArray, initialStatus, expectedStatus, expectedList) \ + for (bool inTransaction = false;; inTransaction = true) { \ + { \ + LinkedList expectedLinkedList; \ + for (int i = 0; i < expectedList.count(); ++i) \ + expectedLinkedList << expectedList.at(i); \ + QByteArray ba = byteArray; \ + QDataStream stream(&ba, QIODevice::ReadOnly); \ + if (inTransaction) \ + stream.startTransaction(); \ + stream.setStatus(initialStatus); \ + stream >> linkedList; \ + QCOMPARE((int)stream.status(), (int)expectedStatus); \ + if (!inTransaction || stream.commitTransaction()) { \ + QCOMPARE(linkedList.size(), expectedLinkedList.size()); \ + QCOMPARE(linkedList, expectedLinkedList); \ + } else { \ + QVERIFY(linkedList.isEmpty()); \ + } \ + } \ + if (inTransaction) \ + break; \ + } + void tst_QDataStream::status_QLinkedList_QList_QVector() { - typedef QLinkedList LinkedList; typedef QList List; typedef QVector Vector; - LinkedList linkedList; List list; Vector vector; @@ -3155,6 +3159,61 @@ void tst_QDataStream::status_QLinkedList_QList_QVector() LIST_TEST(QByteArray("\x00\x00\x00\x01", 4), QDataStream::ReadCorruptData, QDataStream::ReadCorruptData, List()); LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, List()); } + +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + // The same as above with QLinkedList + + typedef QLinkedList LinkedList; + LinkedList linkedList; + + // ok + { + List listWithEmptyString; + listWithEmptyString.append(""); + + List someList; + someList.append("J"); + someList.append("MN"); + + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::Ok, QDataStream::Ok, listWithEmptyString); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J" + "\x00\x00\x00\x04\x00M\x00N", 18), QDataStream::Ok, QDataStream::Ok, someList); + } + + // past end + { + LINKED_LIST_TEST(QByteArray(), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + LINKED_LIST_TEST(QByteArray("\x00", 1), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00", 2), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00", 3), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01", 4), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + for (int i = 4; i < 12; ++i) { + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", i), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + } + } + + // corrupt data + { + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::Ok, QDataStream::ReadCorruptData, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x01\x00J" + "\x00\x00\x00\x02\x00M\x00N", 18), QDataStream::Ok, QDataStream::ReadCorruptData, List()); + } + + // test the previously latched error status is not affected by reading + { + List listWithEmptyString; + listWithEmptyString.append(""); + + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, listWithEmptyString); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01", 4), QDataStream::ReadCorruptData, QDataStream::ReadCorruptData, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, List()); + } + +QT_WARNING_POP +#endif } void tst_QDataStream::streamToAndFromQByteArray() diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index e79a4dba299..ec519ad3626 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -96,7 +96,9 @@ private slots: void typeinfo(); void qstring(); void list(); +#if QT_DEPRECATED_SINCE(5, 15) void linkedList(); +#endif void vector(); void byteArray(); void stack(); @@ -109,7 +111,9 @@ private slots: #endif void pair(); void sharableQList(); +#if QT_DEPRECATED_SINCE(5, 15) void sharableQLinkedList(); +#endif void sharableQVector(); void sharableQMap(); void sharableQHash(); @@ -121,8 +125,10 @@ private slots: void vector_stl(); void list_stl_data(); void list_stl(); +#if QT_DEPRECATED_SINCE(5, 15) void linkedlist_stl_data(); void linkedlist_stl(); +#endif void q_init(); void pointersize(); void containerInstantiation(); @@ -736,8 +742,11 @@ void tst_Collections::list() } } +#if QT_DEPRECATED_SINCE(5, 15) void tst_Collections::linkedList() { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED { QLinkedList list; QVERIFY(list.isEmpty()); @@ -955,7 +964,9 @@ void tst_Collections::linkedList() QCOMPARE(a.endsWith(1), false); QCOMPARE(a.endsWith(2), true); } +QT_WARNING_POP }; +#endif void tst_Collections::vector() @@ -2330,11 +2341,16 @@ void populate(QList &container) container << 1 << 2 << 4 << 8; } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED template <> void populate(QLinkedList &container) { container << 1 << 2 << 4 << 8; } +QT_WARNING_POP +#endif template <> void populate(QVector &container) @@ -2431,10 +2447,15 @@ void tst_Collections::sharableQList() TEST_SEQUENTIAL_CONTAINER(List); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void tst_Collections::sharableQLinkedList() { TEST_SEQUENTIAL_CONTAINER(LinkedList); } +QT_WARNING_POP +#endif void tst_Collections::sharableQVector() { @@ -2755,7 +2776,12 @@ void tst_Collections::constAndNonConstStlIterators() { testListLikeStlIterators >(); testListLikeStlIterators(); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED testLinkedListLikeStlIterators >(); +QT_WARNING_POP +#endif testListLikeStlIterators >(); testMapLikeStlIterators >(); testMapLikeStlIterators >(); @@ -2798,6 +2824,7 @@ void tst_Collections::vector_stl() QCOMPARE(QVector(stdVector.begin(), stdVector.end()), vector); } +#if QT_DEPRECATED_SINCE(5, 15) void tst_Collections::linkedlist_stl_data() { list_stl_data(); @@ -2805,6 +2832,8 @@ void tst_Collections::linkedlist_stl_data() void tst_Collections::linkedlist_stl() { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QFETCH(QStringList, elements); QLinkedList list; @@ -2821,7 +2850,9 @@ void tst_Collections::linkedlist_stl() QCOMPARE(*it, *it2); QCOMPARE(QLinkedList::fromStdList(stdList), list); +QT_WARNING_POP } +#endif void tst_Collections::list_stl_data() { @@ -3070,6 +3101,10 @@ void tst_Collections::containerInstantiation() typedef QSet Set; instantiateAssociative(); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + //Instantiate QLinkedList member functions. typedef QLinkedList LinkedList; instantiateSequence (); @@ -3078,6 +3113,8 @@ void tst_Collections::containerInstantiation() LinkedList list; list.removeAll(value); } +QT_WARNING_POP +#endif //Instantiate QList member functions. typedef QList List; @@ -3185,7 +3222,12 @@ void tst_Collections::containerTypedefs() testContainerTypedefs(QVector()); testContainerTypedefs(QStack()); testContainerTypedefs(QList()); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED testContainerTypedefs(QLinkedList()); +QT_WARNING_POP +#endif testContainerTypedefs(QQueue()); testPairAssociativeContainerTypedefs(QMap()); @@ -3207,7 +3249,12 @@ void tst_Collections::forwardDeclared() { typedef QMultiMap C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } { typedef QPair C; C *x = 0; Q_UNUSED(x) } { typedef QList C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED { typedef QLinkedList C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } +QT_WARNING_POP +#endif { typedef QVector C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) Q_UNUSED(i) Q_UNUSED(j) } { typedef QStack C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) Q_UNUSED(i) Q_UNUSED(j) } { typedef QQueue C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } @@ -3441,7 +3488,12 @@ void tst_Collections::QTBUG13079_collectionInsideCollection() QTBUG13079_collectionInsideCollectionImpl(); QTBUG13079_collectionInsideCollectionImpl(); QTBUG13079_collectionInsideCollectionImpl(); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QTBUG13079_collectionInsideCollectionImpl(); +QT_WARNING_POP +#endif QTBUG13079_collectionInsideCollectionImpl(); { diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp index 88c0c5055cd..2c7c8f65145 100644 --- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp +++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp @@ -324,11 +324,12 @@ private Q_SLOTS: #endif } - void ranged_ctor_QLinkedList_int() { ranged_ctor_non_associative_impl>(); } - void ranged_ctor_QLinkedList_Movable() { ranged_ctor_non_associative_impl>(); } - void ranged_ctor_QLinkedList_Complex() { ranged_ctor_non_associative_impl>(); } - void ranged_ctor_QLinkedList_duplicates_strategy() { non_associative_container_duplicates_strategy(); } - +#if QT_DEPRECATED_SINCE(5, 15) + void ranged_ctor_QLinkedList_int(); + void ranged_ctor_QLinkedList_Movable(); + void ranged_ctor_QLinkedList_Complex(); + void ranged_ctor_QLinkedList_duplicates_strategy(); +#endif void ranged_ctor_std_set_int() { ranged_ctor_non_associative_impl>(); } void ranged_ctor_std_set_Movable() { ranged_ctor_non_associative_impl>(); } void ranged_ctor_std_set_Complex() { ranged_ctor_non_associative_impl>(); } @@ -482,7 +483,9 @@ private Q_SLOTS: void front_back_std_vector() { front_back_impl>(); } void front_back_QVector() { front_back_impl>(); } void front_back_QList() { front_back_impl>(); } - void front_back_QLinkedList() { front_back_impl>(); } +#if QT_DEPRECATED_SINCE(5, 15) + void front_back_QLinkedList(); +#endif void front_back_QVarLengthArray() { front_back_impl>(); } void front_back_QString() { front_back_impl(); } void front_back_QStringRef() { front_back_impl(); } @@ -590,8 +593,13 @@ template struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; #endif +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED template struct ContainerDuplicatedValuesStrategy> : ContainerAcceptsDuplicateValues {}; +QT_WARNING_POP +#endif // assuming https://cplusplus.github.io/LWG/lwg-active.html#2844 resolution template @@ -819,5 +827,35 @@ void tst_ContainerApiSymmetry::front_back_impl() const QCOMPARE(clean(qAsConst(c2).back()), V(2)); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED +void tst_ContainerApiSymmetry::ranged_ctor_QLinkedList_int() +{ + ranged_ctor_non_associative_impl>(); +} + +void tst_ContainerApiSymmetry::ranged_ctor_QLinkedList_Movable() +{ + ranged_ctor_non_associative_impl>(); +} + +void tst_ContainerApiSymmetry::ranged_ctor_QLinkedList_Complex() +{ + ranged_ctor_non_associative_impl>(); +} + +void tst_ContainerApiSymmetry::ranged_ctor_QLinkedList_duplicates_strategy() +{ + non_associative_container_duplicates_strategy(); +} + +void tst_ContainerApiSymmetry::front_back_QLinkedList() +{ + front_back_impl>(); +} +QT_WARNING_POP +#endif + QTEST_APPLESS_MAIN(tst_ContainerApiSymmetry) #include "tst_containerapisymmetry.moc" diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index df42b5dea9d..b681676d095 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -29,6 +29,10 @@ #include #include +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + struct Movable { Movable(char input = 'j') : i(input), state(Constructed) @@ -1129,5 +1133,16 @@ void tst_QLinkedList::setSharableInt() const #endif } +QT_WARNING_POP +#else +class tst_QLinkedList : public QObject +{ + Q_OBJECT +private slots: + void initTestCase() { QSKIP("Deprecated APIs are disabled, skipping this test."); } +}; + +#endif // QT_DEPRECATED_SINCE(5, 15) + QTEST_APPLESS_MAIN(tst_QLinkedList) #include "tst_qlinkedlist.moc" From 2de3bfced35ae060acffc06e66e18279de6f5099 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Mar 2020 09:44:05 +0100 Subject: [PATCH 19/38] Fix UB in QProcess deprecation warning fixes The commits e1e08629 and 66e905b1 introduced undefined behavior. Fix this by assigning the result of takeFirst to a temporary. Change-Id: I9e29412cf632d4836b95d47e12d8c07ab0645fbb Reviewed-by: Volker Hilsheimer --- src/corelib/io/qprocess.cpp | 3 ++- .../services/genericunix/qgenericunixservices.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 9400662b97c..4500467ac27 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -2522,7 +2522,8 @@ int QProcess::execute(const QString &command) QStringList args = splitCommand(command); if (args.isEmpty()) return -2; - return execute(args.takeFirst(), args); + QString program = args.takeFirst(); + return execute(program, args); } /*! diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 8e9923e208a..b583d636c0f 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -167,7 +167,11 @@ static inline bool launch(const QString &launcher, const QUrl &url) const bool ok = ::system(qPrintable(command + QLatin1String(" &"))); #else QStringList args = QProcess::splitCommand(command); - const bool ok = !args.isEmpty() && QProcess::startDetached(args.takeFirst(), args); + bool ok = false; + if (!args.isEmpty()) { + QString program = args.takeFirst(); + ok = QProcess::startDetached(program, args); + } #endif if (!ok) qWarning("Launch failed (%s)", qPrintable(command)); From 94fc977b2bcb46d7ddc206a83009dcaa7d7532d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 2 Mar 2020 12:51:15 +0100 Subject: [PATCH 20/38] macOS: Disable system provided tabbing by default macOS 10.12 introduced automatic window tabbing, where the OS provides tab handling on behalf of the application. The feature defaulted to being on, and the release notes asked applications that had their own tab handling to disable the automatic tab handling explicitly. Qt has its own tab handling, and should therefore disable the automatic handling. We do this on a per NSWindow basis, using the tabbingMode property of the window, instead of the global allowsAutomaticWindowTabbing property on NSWindow, so that individual windows can still opt in to the automatic tab handling. Doing it via the tabbingMode property also ensures that we're not affecting the host application's behavior in a plug-in setting. Ideally Qt's tab handling should read the userTabbingPreference property of NSWindow to pick up the system preference choice of whether to open new windows as standalone windows or tabs, but this is left for a later change. An alternative would also be to use the automatic window tabbing instead of our own implementation. Fixes: QTBUG-61707 Change-Id: Icf2078b63ec16202ff7fd83ea264a48dc61978e1 Reviewed-by: Volker Hilsheimer Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 9cb4470e02c..5edc7223b19 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1635,6 +1635,7 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel) nsWindow.restorable = NO; nsWindow.level = windowLevel(flags); + nsWindow.tabbingMode = NSWindowTabbingModeDisallowed; if (shouldBePanel) { // Qt::Tool windows hide on app deactivation, unless Qt::WA_MacAlwaysShowToolWindow is set From ccee938b5193ff90a6fecc1f4635b856a24718bd Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 5 Mar 2020 17:35:03 +0100 Subject: [PATCH 21/38] rhi: vulkan: Silence useless desc.set validation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is deemed more appropriate than having some time consuming tracking of descriptor types in pools, just to avoid the rare case of attempting a failing vkAllocateDescriptorSets(), which is then always followed by another, successful attempt. Change-Id: I7a3a1d80afe400dc96605a3d6c834e8b2c71143a Reviewed-by: Christian Strømme --- src/gui/rhi/qrhivulkan.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index ca913475a51..26c153afff5 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -345,6 +345,15 @@ static bool qvk_debug_filter(VkDebugReportFlagsEXT flags, VkDebugReportObjectTyp return true; } + // In certain cases allocateDescriptorSet() will attempt to allocate from a + // pool that does not have enough descriptors of a certain type. This makes + // the validation layer shout. However, this is not an error since we will + // then move on to another pool. If there is a real error, a qWarning + // message is shown by allocateDescriptorSet(), so the validation warning + // does not have any value and is just noise. + if (strstr(pMessage, "VUID-VkDescriptorSetAllocateInfo-descriptorPool-00307")) + return true; + return false; } From 50d2acdc93b4de2ba56eb67787e2bdcb21dd4bea Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 5 Mar 2020 09:36:49 +0100 Subject: [PATCH 22/38] Add default arguments to QPainterPath methods using transform Fixes: QTBUG-82602 Change-Id: Id82f145ffb33e6d4ef9b81282ad14657b1c8fbd0 Reviewed-by: Qt CI Bot Reviewed-by: Lars Knoll --- examples/opengl/paintedwindow/paintedwindow.cpp | 1 + examples/opengl/qopenglwindow/main.cpp | 1 + examples/qpa/qrasterwindow/main.cpp | 1 + .../widgets/painting/basicdrawing/renderarea.cpp | 1 + .../widgets/widgets/styles/norwegianwoodstyle.cpp | 1 + src/gui/painting/qpainterpath.h | 15 +++++++++------ src/gui/painting/qrasterizer.cpp | 2 ++ src/gui/painting/qtextureglyphcache.cpp | 2 ++ src/gui/painting/qtransform.h | 5 +---- src/gui/text/qrawfont.cpp | 1 + .../fontdatabases/freetype/qfontengine_ft.cpp | 1 + .../fontdatabases/mac/qfontengine_coretext.mm | 1 + .../windows/qwindowsfontenginedirectwrite.cpp | 1 + src/plugins/styles/mac/qmacstyle_mac.mm | 1 + src/widgets/graphicsview/qgraphicsscene.cpp | 1 + src/widgets/graphicsview/qgraphicssceneindex.cpp | 1 + src/widgets/graphicsview/qgraphicsview.cpp | 1 + src/widgets/graphicsview/qgraphicswidget.cpp | 1 + src/widgets/styles/qfusionstyle.cpp | 1 + src/widgets/styles/qstylesheetstyle.cpp | 1 + src/widgets/styles/qwindowsstyle.cpp | 1 + .../serialization/qdatastream/tst_qdatastream.cpp | 9 +++++---- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 1 + tests/auto/gui/painting/qregion/tst_qregion.cpp | 1 + .../gui/painting/qtransform/tst_qtransform.cpp | 4 ++-- tests/auto/gui/qopengl/tst_qopengl.cpp | 1 + tests/auto/opengl/qgl/tst_qgl.cpp | 1 + tests/auto/other/lancelot/paintcommands.cpp | 1 + .../qgraphicsitem/tst_qgraphicsitem.cpp | 1 + .../tst_qgraphicspixmapitem.cpp | 1 + .../tst_qgraphicspolygonitem.cpp | 1 + .../qgraphicsscene/tst_qgraphicsscene.cpp | 1 + .../tst_qgraphicssceneindex.cpp | 1 + .../qgraphicsview/tst_qgraphicsview_2.cpp | 1 + tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 1 + .../gui/painting/qpainter/tst_qpainter.cpp | 1 + .../gui/painting/qtbench/benchmarktests.h | 1 + .../gui/painting/qtransform/tst_qtransform.cpp | 1 + 38 files changed, 53 insertions(+), 16 deletions(-) diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp index 799431a765e..94aa2152881 100644 --- a/examples/opengl/paintedwindow/paintedwindow.cpp +++ b/examples/opengl/paintedwindow/paintedwindow.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include diff --git a/examples/opengl/qopenglwindow/main.cpp b/examples/opengl/qopenglwindow/main.cpp index 8932269ddfa..7ce4dd0977f 100644 --- a/examples/opengl/qopenglwindow/main.cpp +++ b/examples/opengl/qopenglwindow/main.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/examples/qpa/qrasterwindow/main.cpp b/examples/qpa/qrasterwindow/main.cpp index 958da2205af..699c950c27b 100644 --- a/examples/qpa/qrasterwindow/main.cpp +++ b/examples/qpa/qrasterwindow/main.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include #include diff --git a/examples/widgets/painting/basicdrawing/renderarea.cpp b/examples/widgets/painting/basicdrawing/renderarea.cpp index a1437dea8f8..09d610ee95a 100644 --- a/examples/widgets/painting/basicdrawing/renderarea.cpp +++ b/examples/widgets/painting/basicdrawing/renderarea.cpp @@ -51,6 +51,7 @@ #include "renderarea.h" #include +#include //! [0] RenderArea::RenderArea(QWidget *parent) diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp index 31150cd994e..34a63e0eea1 100644 --- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp +++ b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 26b92dc6fae..8d4bdf2e199 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -178,15 +179,15 @@ public: #if QT_DEPRECATED_SINCE(5, 15) QT_DEPRECATED_X("Use toSubpathPolygons(const QTransform &)") - QList toSubpathPolygons(const QMatrix &matrix = QMatrix()) const; + QList toSubpathPolygons(const QMatrix &matrix) const; QT_DEPRECATED_X("Use toFillPolygons(const QTransform &") - QList toFillPolygons(const QMatrix &matrix = QMatrix()) const; + QList toFillPolygons(const QMatrix &matrix) const; QT_DEPRECATED_X("Use toFillPolygon(const QTransform &)") - QPolygonF toFillPolygon(const QMatrix &matrix = QMatrix()) const; + QPolygonF toFillPolygon(const QMatrix &matrix) const; #endif // QT_DEPRECATED_SINCE(5, 15) - QList toSubpathPolygons(const QTransform &matrix) const; - QList toFillPolygons(const QTransform &matrix) const; - QPolygonF toFillPolygon(const QTransform &matrix) const; + QList toSubpathPolygons(const QTransform &matrix = QTransform()) const; + QList toFillPolygons(const QTransform &matrix = QTransform()) const; + QPolygonF toFillPolygon(const QTransform &matrix = QTransform()) const; int elementCount() const; QPainterPath::Element elementAt(int i) const; @@ -362,6 +363,8 @@ inline void QPainterPath::translate(const QPointF &offset) inline QPainterPath QPainterPath::translated(const QPointF &offset) const { return translated(offset.x(), offset.y()); } +inline QPainterPath operator *(const QPainterPath &p, const QTransform &m) +{ return m.map(p); } #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug, const QPainterPath &); diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index cd31d75f833..f3c193d7995 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -46,6 +46,8 @@ #include #include +#include + #include QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 91214f27ca3..141b195a42c 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -43,6 +43,8 @@ #include "private/qfontengine_p.h" #include "private/qnumeric_p.h" +#include + QT_BEGIN_NAMESPACE // #define CACHE_DEBUG diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 485caa51403..41cbfc35f23 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -41,7 +41,6 @@ #include #include -#include #include #include #include @@ -51,8 +50,8 @@ QT_BEGIN_NAMESPACE - class QVariant; +class QPainterPath; class Q_GUI_EXPORT QTransform { @@ -408,8 +407,6 @@ inline QPolygonF operator *(const QPolygonF &a, const QTransform &m) { return m.map(a); } inline QRegion operator *(const QRegion &r, const QTransform &m) { return m.map(r); } -inline QPainterPath operator *(const QPainterPath &p, const QTransform &m) -{ return m.map(p); } inline QTransform operator *(const QTransform &a, qreal n) { QTransform t(a); t *= n; return t; } diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 884525bd76d..b4b60cbaaf9 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -51,6 +51,7 @@ #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index e65f67d4f1c..7e83bcad077 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #ifndef QT_NO_FREETYPE diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index ce793dfafa4..115b13d60d4 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -45,6 +45,7 @@ #include #endif #include +#include #include #include diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index e8f9cfb2a8f..ecf60495047 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #if defined(QT_USE_DIRECTWRITE2) # include diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index d5ad1a8ca07..8e4aaa19c7b 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -56,6 +56,7 @@ #include +#include #include #include #include diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index bbcceb1ce6c..b669b0fe610 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -233,6 +233,7 @@ #include #include #include +#include #include #include #include diff --git a/src/widgets/graphicsview/qgraphicssceneindex.cpp b/src/widgets/graphicsview/qgraphicssceneindex.cpp index c2e9cb47299..aab9068374d 100644 --- a/src/widgets/graphicsview/qgraphicssceneindex.cpp +++ b/src/widgets/graphicsview/qgraphicssceneindex.cpp @@ -60,6 +60,7 @@ #include "qgraphicswidget.h" #include "qgraphicssceneindex_p.h" #include "qgraphicsscenebsptreeindex_p.h" +#include QT_BEGIN_NAMESPACE diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index a75f1ab24be..17c13e47d61 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -294,6 +294,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < #include #include #include +#include #include #include diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 6242314e1da..472d61d437c 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index ce5f084618f..751ce36bb34 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -52,6 +52,7 @@ #include #endif #include +#include #include #include #include diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 1e032b237a9..b07abe4f511 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -118,6 +118,7 @@ #include #endif +#include #include QT_BEGIN_NAMESPACE diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 4965d146b03..e275e3a7142 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -78,6 +78,7 @@ #endif #include #include +#include #include #include #include diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index ff2e98e7302..7ada913778a 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -28,12 +28,13 @@ #include #include -#include -#include -#include -#include #include +#include +#include #include +#include +#include +#include class tst_QDataStream : public QObject { diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 9eb62ceab22..45798cc527a 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -46,6 +46,7 @@ #include #include +#include #include #include diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp index d1ea7706b97..aa9a84ba8e6 100644 --- a/tests/auto/gui/painting/qregion/tst_qregion.cpp +++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp @@ -32,6 +32,7 @@ #include #include +#include #include class tst_QRegion : public QObject diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp index 78638a75187..f31e2bf41b2 100644 --- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp +++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp @@ -28,11 +28,11 @@ #include -#include "qtransform.h" +#include #include +#include #include - class tst_QTransform : public QObject { Q_OBJECT diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index ede1e58a53c..8e516e428ab 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 3cc9592fb18..d860caaa37d 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index c1ff7e7a873..e98df3781e7 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 45026170e37..5f2a9aad70a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -59,6 +59,7 @@ #include #include #include +#include using AbstractGraphicsShapeItemPtr = QSharedPointer; using GraphicsItems = QVector; diff --git a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp index 28222791900..e7bba010d93 100644 --- a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp @@ -30,6 +30,7 @@ #include #include #include +#include class tst_QGraphicsPixmapItem : public QObject { diff --git a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp index fbdd38804da..5380dd0dafd 100644 --- a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/tst_qgraphicspolygonitem.cpp @@ -29,6 +29,7 @@ #include #include +#include #include diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index cfbe1f96eeb..7e5d94da22e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index baccf7bff81..ff01810938f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp @@ -28,6 +28,7 @@ #include +#include #include #include #include diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp index 95506558684..aedb96f19a1 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 1f2060942b0..2483d7b5bb5 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp index 485306a8ac7..82804a09774 100644 --- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include diff --git a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h index b31b6823aa4..6d388fcaad8 100644 --- a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h +++ b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h @@ -37,6 +37,7 @@ #include #include #include +#include #include class Benchmark diff --git a/tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp b/tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp index 12e85d48423..d28f9502d74 100644 --- a/tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp +++ b/tests/benchmarks/gui/painting/qtransform/tst_qtransform.cpp @@ -28,6 +28,7 @@ #include #include +#include class tst_QTransform : public QObject { From 114394702b2975b5d890833a5f14510b5e1a2e2b Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 26 Feb 2020 19:35:06 +0100 Subject: [PATCH 23/38] QtSql/ODBC: allow table names with unicode chars The ODBC driver did not properly decode table names with unicode chars. Fix it by explicitly passing the unicode flag to qGetStringData(). Fixes: QTBUG-82401 Change-Id: Id6eb44cc85ce196ea97d0d6aef1cd573fa033970 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/odbc/qsql_odbc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index 8e996d0deda..88f1c740284 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -2379,7 +2379,7 @@ QStringList QODBCDriver::tables(QSql::TableType type) const } while (r == SQL_SUCCESS) { - QString fieldVal = qGetStringData(hStmt, 2, -1, false); + QString fieldVal = qGetStringData(hStmt, 2, -1, d->unicode); tl.append(fieldVal); if (d->hasSQLFetchScroll) From 4bc9e3b8470ed2026604dc06dc027c80e6f7c445 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 28 Feb 2020 20:00:24 +0100 Subject: [PATCH 24/38] QDataStream: fix compilation with QT_DISABLE_DEPRECATED_BEFORE=0x0050F00 Fixes: QTBUG-81023 Change-Id: I0d56785d1fed2c4c8e0e87ccefb0b72b0ed3644a Reviewed-by: Giuseppe D'Angelo --- src/corelib/serialization/qdatastream.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index 4d827772c8a..6f6593f9bfd 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -285,6 +285,13 @@ QDataStream &readListBasedContainer(QDataStream &s, Container &c) return s; } +template +struct MultiContainer { using type = T; }; +template +struct MultiContainer> { using type = QMultiMap; }; +template +struct MultiContainer> { using type = QMultiHash; }; + template QDataStream &readAssociativeContainer(QDataStream &s, Container &c) { @@ -301,10 +308,7 @@ QDataStream &readAssociativeContainer(QDataStream &s, Container &c) c.clear(); break; } -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - c.insertMulti(k, t); -QT_WARNING_POP + static_cast::type &>(c).insert(k, t); } return s; From 37a66236d2fd0d671c8ee37c5f9512d30f18c179 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 3 Mar 2020 13:57:30 +0100 Subject: [PATCH 25/38] qmake: Document qmltypes and metatypes Task-number: QTBUG-81615 Fixes: QTBUG-82305 Change-Id: I0a411ff2ebc2dbf5462fa110b1eb70a1876b6ae5 Reviewed-by: Joerg Bornemann Reviewed-by: Leena Miettinen --- qmake/doc/src/qmake-manual.qdoc | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 1e1e23495c0..351009bd1c6 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -1111,6 +1111,15 @@ \row \li designer \li The target is a plugin for \QD. \row \li no_lflags_merge \li Ensures that the list of libraries stored in the \c LIBS variable is not reduced to a list of unique values before it is used. + \row \li metatypes \li Create a \c {_metatypes.json} file for the + current project. \c {} is the all lowercase base name of + \l TARGET. + \row \li qmltypes \li Automatically register QML types defined in C++. + For more information, see \l {Defining QML Types from C++}. + Also, create a \c {