From b0493998c391688022df7502892bd9b42cfdab7b Mon Sep 17 00:00:00 2001 From: wangChuan Date: Tue, 21 May 2019 16:08:25 +0800 Subject: [PATCH 001/172] QTextBoundaryFinder: don't break after uppercase followed by comma [ChangeLog][QtCore][QTextBoundaryFinder] Sentence breaking now no longer breaks between uppercase letters and comma. This is a deviation from the Unicode specification, but produces less surprising behavior. Fixes: QTBUG-75857 Change-Id: If1e78b3be3f20250d01100353ea7da6110985f82 Reviewed-by: Edward Welbourne Reviewed-by: Konstantin Ritt --- src/corelib/tools/qunicodetools.cpp | 2 +- .../tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qunicodetools.cpp b/src/corelib/tools/qunicodetools.cpp index c9d0868fef9..0a2bea28e21 100644 --- a/src/corelib/tools/qunicodetools.cpp +++ b/src/corelib/tools/qunicodetools.cpp @@ -327,7 +327,7 @@ static const uchar breakTable[BAfter + 1][QUnicodeTables::NumSentenceBreakClasse // Any CR LF Sep Extend Sp Lower Upper OLetter Numeric ATerm SContinue STerm Close { Initial, BAfterC, BAfter , BAfter , Initial, Initial, Lower , Upper , Initial, Initial, ATerm , Initial, STerm , Initial }, // Initial { Initial, BAfterC, BAfter , BAfter , Lower , Initial, Initial, Initial, Initial, Initial, LUATerm, Initial, STerm , Initial }, // Lower - { Initial, BAfterC, BAfter , BAfter , Upper , Initial, Initial, Upper , Initial, Initial, LUATerm, STerm , STerm , Initial }, // Upper + { Initial, BAfterC, BAfter , BAfter , Upper , Initial, Initial, Upper , Initial, Initial, LUATerm, Initial, STerm , Initial }, // Upper { Lookup , BAfterC, BAfter , BAfter , LUATerm, ACS , Initial, Upper , Break , Initial, ATerm , STerm , STerm , ATermC }, // LUATerm { Lookup , BAfterC, BAfter , BAfter , ATerm , ACS , Initial, Break , Break , Initial, ATerm , STerm , STerm , ATermC }, // ATerm diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 5467d438a3e..5701335b4ac 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -539,6 +539,13 @@ void tst_QTextBoundaryFinder::sentenceBoundaries_manual_data() QTest::newRow("data3") << testString << expectedBreakPositions; } + { + QString testString(QString::fromUtf8("Doing TEST, doing another test.")); + QList expectedBreakPositions; + expectedBreakPositions << 0 << 31; + + QTest::newRow("data4") << testString << expectedBreakPositions; + } } void tst_QTextBoundaryFinder::sentenceBoundaries_manual() From 90aefe0843a50aede26b8d411f46f3828dae25f1 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Sun, 26 May 2019 22:14:45 +0200 Subject: [PATCH 002/172] Add quoting to deal with empty ${CMAKE_CXX_STANDARD_LIBRARIES} Done to fix broken CMake WebAssembly support, where CMAKE_CXX_STANDARD_LIBRARIES appear to be empty. The regression was introduced by ba4fdd99fff80790f764ab1ac8addd699e3101e7. This fixes the following CMake error on find_package(Qt ...): string sub-command REGEX, mode REPLACE needs at least 6 arguments total to command. Fixes: QTBUG-73475 Fixes: QTBUG-76244 Change-Id: Ieebe8cd1d49bb302dc37d8f118cc0b9376d6cdd7 Reviewed-by: Kai Koehne --- mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index 1c4994c30ff..705e0a3c933 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -59,7 +59,7 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura file(STRINGS \"${prl_file_location}\" _prl_strings REGEX \"QMAKE_PRL_LIBS[ \\t]*=\") string(REGEX REPLACE \"QMAKE_PRL_LIBS[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends ${_prl_strings}) string(REGEX REPLACE \"[ \\t]+\" \";\" _static_depends ${_static_depends}) - string(REGEX REPLACE \"[ \\t]+\" \";\" _standard_libraries ${CMAKE_CXX_STANDARD_LIBRARIES}) + string(REGEX REPLACE \"[ \\t]+\" \";\" _standard_libraries \"${CMAKE_CXX_STANDARD_LIBRARIES}\") set(_search_paths) string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\") foreach(_flag ${_static_depends}) From 2e7b7e4c90882cef50b293fe8048205a9ca7e5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 13 Dec 2018 15:39:26 +0100 Subject: [PATCH 003/172] QSslSocket: add and set the TLSv1.3-specific PSK callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If this callback is not set then OpenSSL will call the callback used for <= TLS 1.2 unconditionally when connecting. If using PSK it will call it again later once the preshared key is needed. We don't currently handle the TLSv1.3 PSK, but we definitely should. But for now we can work around it - when psk_use_session_callback is called we simply change the PSK callback to a dummy function whose only purpose is to restore the old callback. This is mostly done to keep behavior the same as it is now for users (and to keep our tests running). Later we can add a new signal and handle this new feature properly. Reviewed-by: Simo Fält (cherry picked from commit d8efc8d718e3b3a0464f321e740541f5b221a5d6) Task-number: QTBUG-67463 Change-Id: I4aca4ae73ec4be7c4f82a85e8864de103f35a834 Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslsocket_openssl.cpp | 56 +++++++++++++++++++ .../ssl/qsslsocket_openssl11_symbols_p.h | 6 ++ .../ssl/qsslsocket_openssl_symbols.cpp | 2 + .../network/ssl/qsslsocket/tst_qsslsocket.cpp | 12 +--- 4 files changed, 65 insertions(+), 11 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index c48cd423601..977d8a6742d 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -137,6 +137,55 @@ static unsigned int q_ssl_psk_server_callback(SSL *ssl, Q_ASSERT(d); return d->tlsPskServerCallback(identity, psk, max_psk_len); } + +#ifdef TLS1_3_VERSION +#ifndef OPENSSL_NO_PSK +static unsigned int q_ssl_psk_restore_client(SSL *ssl, + const char *hint, + char *identity, unsigned int max_identity_len, + unsigned char *psk, unsigned int max_psk_len) +{ + Q_UNUSED(hint); + Q_UNUSED(identity); + Q_UNUSED(max_identity_len); + Q_UNUSED(psk); + Q_UNUSED(max_psk_len); + +#ifdef QT_DEBUG + QSslSocketBackendPrivate *d = reinterpret_cast(q_SSL_get_ex_data(ssl, QSslSocketBackendPrivate::s_indexForSSLExtraData)); + Q_ASSERT(d); + Q_ASSERT(d->mode == QSslSocket::SslClientMode); +#endif + q_SSL_set_psk_client_callback(ssl, &q_ssl_psk_client_callback); + + return 0; +} +#endif // !OPENSSL_NO_PSK + +static int q_ssl_psk_use_session_callback(SSL *ssl, const EVP_MD *md, const unsigned char **id, + size_t *idlen, SSL_SESSION **sess) +{ + Q_UNUSED(ssl); + Q_UNUSED(md); + Q_UNUSED(id); + Q_UNUSED(idlen); + Q_UNUSED(sess); + +#ifndef OPENSSL_NO_PSK +#ifdef QT_DEBUG + QSslSocketBackendPrivate *d = reinterpret_cast(q_SSL_get_ex_data(ssl, QSslSocketBackendPrivate::s_indexForSSLExtraData)); + Q_ASSERT(d); + Q_ASSERT(d->mode == QSslSocket::SslClientMode); +#endif + + // Temporarily rebind the psk because it will be called next. The function will restore it. + q_SSL_set_psk_client_callback(ssl, &q_ssl_psk_restore_client); +#endif + + return 1; // need to return 1 or else "the connection setup fails." +} +#endif // TLS1_3_VERSION + #endif #if QT_CONFIG(ocsp) @@ -555,6 +604,13 @@ bool QSslSocketBackendPrivate::initSslContext() q_SSL_set_psk_server_callback(ssl, &q_ssl_psk_server_callback); } #endif +#if OPENSSL_VERSION_NUMBER >= 0x10101006L + // Set the client callback for TLSv1.3 PSK + if (mode == QSslSocket::SslClientMode + && QSslSocket::sslLibraryBuildVersionNumber() >= 0x10101006L) { + q_SSL_set_psk_use_session_callback(ssl, &q_ssl_psk_use_session_callback); + } +#endif // openssl version >= 0x10101006L #if QT_CONFIG(ocsp) if (configuration.ocspStaplingEnabled) { diff --git a/src/network/ssl/qsslsocket_openssl11_symbols_p.h b/src/network/ssl/qsslsocket_openssl11_symbols_p.h index a44d00a8303..d523a957503 100644 --- a/src/network/ssl/qsslsocket_openssl11_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl11_symbols_p.h @@ -183,4 +183,10 @@ const OCSP_CERTID *q_OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x); #define q_SSL_CTX_set_max_proto_version(ctx, version) \ q_SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, nullptr) +extern "C" { +typedef int (*q_SSL_psk_use_session_cb_func_t)(SSL *, const EVP_MD *, const unsigned char **, size_t *, + SSL_SESSION **); +} +void q_SSL_set_psk_use_session_callback(SSL *s, q_SSL_psk_use_session_cb_func_t); + #endif diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index aa1dc681e07..93b54aaa67c 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -163,6 +163,7 @@ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return) DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return) #ifdef TLS1_3_VERSION DEFINEFUNC2(int, SSL_CTX_set_ciphersuites, SSL_CTX *ctx, ctx, const char *str, str, return 0, return) +DEFINEFUNC2(void, SSL_set_psk_use_session_callback, SSL *ssl, ssl, q_SSL_psk_use_session_cb_func_t callback, callback, return, DUMMYARG) #endif DEFINEFUNC3(size_t, SSL_get_client_random, SSL *a, a, unsigned char *out, out, size_t outlen, outlen, return 0, return) DEFINEFUNC3(size_t, SSL_SESSION_get_master_key, const SSL_SESSION *ses, ses, unsigned char *out, out, size_t outlen, outlen, return 0, return) @@ -967,6 +968,7 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(SSL_CTX_set_options) #ifdef TLS1_3_VERSION RESOLVEFUNC(SSL_CTX_set_ciphersuites) + RESOLVEFUNC(SSL_set_psk_use_session_callback) #endif // TLS 1.3 or OpenSSL > 1.1.1 RESOLVEFUNC(SSL_get_client_random) RESOLVEFUNC(SSL_SESSION_get_master_key) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 1c279018447..b4dc9bed33b 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -3546,12 +3546,7 @@ protected: socket = new QSslSocket(this); socket->setSslConfiguration(config); socket->setPeerVerifyMode(peerVerifyMode); - if (QSslSocket::sslLibraryVersionNumber() > 0x10101000L) { - // FIXME. With OpenSSL 1.1.1 and TLS 1.3 PSK auto-test is broken. - socket->setProtocol(QSsl::TlsV1_2); - } else { - socket->setProtocol(protocol); - } + socket->setProtocol(protocol); if (ignoreSslErrors) connect(socket, SIGNAL(sslErrors(QList)), this, SLOT(ignoreErrorSlot())); @@ -3895,11 +3890,6 @@ void tst_QSslSocket::pskServer() return; QSslSocket socket; -#ifdef TLS1_3_VERSION - // FIXME: with OpenSSL 1.1.1 (thus TLS 1.3) test is known to fail - // due to the different PSK mechanism (?) - to be investigated ASAP. - socket.setProtocol(QSsl::TlsV1_2); -#endif this->socket = &socket; QSignalSpy connectedSpy(&socket, SIGNAL(connected())); From 2c5d21be436ad5f2549cb1a6f40b185e159812a4 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 12 Jun 2019 15:29:09 +0200 Subject: [PATCH 004/172] H2 auto-test, degrage flowControlServerSide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit our powerful VMs die/time out on 30 requests, use 10 only. Change-Id: Ibf3ceedeac1839f9a88f88def844c7d61786b94f Reviewed-by: Mårten Nordheim (cherry picked from commit 515c6e7639a7df647cfcc8b639e258864aaaa4af) Reviewed-by: Timur Pocheptsov --- tests/auto/network/access/http2/tst_http2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index 53d0e7a6946..e24370fc87e 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -340,7 +340,7 @@ void tst_Http2::flowControlServerSide() clearHTTP2State(); serverPort = 0; - nRequests = 30; + nRequests = 10; const Http2::RawSettings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 7}}; From fc9ae22c88dd085c7c31599037132fc756feeb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 11 Mar 2019 15:56:51 +0100 Subject: [PATCH 005/172] tst_qsslsocket: fix racy test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this threaded setup the server can sometimes have the data before it calls "waitForReadyRead", what happens then is that we fail the wait and as a result the test fails overall. Let's check if we actually got some data after all and then continue if we did. Since both the client and the server currently wait the same amount of time (2s) the max timeout for the client was increased by 0.5s so it has some time to notice that the server got the message. Change-Id: Ib5915958853413047aa5a7574712585bcae28f79 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov (cherry picked from commit e79b1dcdf542be3a20d5c21ea163ff857ed875bf) Reviewed-by: Simo Fält (cherry picked from commit d53b8b77bc8de236e148ef2652806015a9a87e2b) Change-Id: I2f6ffb8e0a9b4d591edb6925e48baffcefc14511 Reviewed-by: Timur Pocheptsov --- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index b4dc9bed33b..66475e55ad6 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -2096,7 +2096,7 @@ protected: // delayed reading data QTest::qSleep(100); - if (!socket->waitForReadyRead(2000)) + if (!socket->waitForReadyRead(2000) && socket->bytesAvailable() == 0) return; // error socket->readAll(); dataReadSemaphore.release(); @@ -2167,7 +2167,7 @@ void tst_QSslSocket::waitForMinusOne() socket.write("How are you doing?"); QVERIFY(socket.bytesToWrite() != 0); QVERIFY(socket.waitForBytesWritten(-1)); - QVERIFY(server.dataReadSemaphore.tryAcquire(1, 2000)); + QVERIFY(server.dataReadSemaphore.tryAcquire(1, 2500)); // third verification: it should wait for 100 ms: QVERIFY(socket.waitForReadyRead(-1)); From 5aaade8c935caa1add92f61187c0065e34cf7e0e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 15 May 2019 12:35:08 +0200 Subject: [PATCH 006/172] Fix editing of QDateTimeEdit in 12-hour locales that don't use AM/PM The code made two incorrect assumptions: that the strings used are "AM" or "PM", or would be translated. Instead, the locale provides the correct strings, and there is no need to translate. However, in order not to break existing translations, we give those preference. And that the AM/PM string is not longer than 4 characters, while in e.g Spanish/Columbia locale the strings are "A. M." and "P. M.", ie 5 characters long. Also, the use of qMin in a function that is asked to provide the maximum section length is wrong. [ChangeLog][QWidgets][QDateTimeEdit] Use the information provided by the locale to determine the AM/PM strings, unless they are already translated. Change-Id: I6d1b05376e5ac62fc58da2cdea2e6cb732ec6747 Fixes: QTBUG-72833 Reviewed-by: Andy Shaw Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetimeparser.cpp | 27 ++++++++++--------- src/widgets/widgets/qdatetimeedit.cpp | 22 +++++++++++++-- .../corelib/tools/qdatetime/tst_qdatetime.cpp | 7 +++-- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index e8470f6cde9..adc5451deca 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -622,11 +622,11 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const case LastSection: return 0; case AmPmSection: { - const int lowerMax = qMin(getAmPmText(AmText, LowerCase).size(), + const int lowerMax = qMax(getAmPmText(AmText, LowerCase).size(), getAmPmText(PmText, LowerCase).size()); - const int upperMax = qMin(getAmPmText(AmText, UpperCase).size(), + const int upperMax = qMax(getAmPmText(AmText, UpperCase).size(), getAmPmText(PmText, UpperCase).size()); - return qMin(4, qMin(lowerMax, upperMax)); + return qMax(lowerMax, upperMax); } case Hour24Section: @@ -1665,13 +1665,16 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, /*! \internal - Returns - AM if str == tr("AM") - PM if str == tr("PM") - PossibleAM if str can become tr("AM") - PossiblePM if str can become tr("PM") - PossibleBoth if str can become tr("PM") and can become tr("AM") - Neither if str can't become anything sensible + Compares str to the am/pm texts returned by getAmPmText(). + Returns AM or PM if str is one of those texts. Failing that, it looks to see + whether, ignoring spaces and case, each character of str appears in one of + the am/pm texts. + If neither text can be the result of the user typing more into str, returns + Neither. If both texts are possible results of further typing, returns + PossibleBoth. Otherwise, only one of them is a possible completion, so this + returns PossibleAM or PossiblePM to indicate which. + + \sa getAmPmText() */ QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionIndex, int *used) const { @@ -1700,10 +1703,10 @@ QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionI QDTPDEBUG << "findAmPm" << str << ampm[0] << ampm[1]; - if (str.indexOf(ampm[amindex], 0, Qt::CaseInsensitive) == 0) { + if (str.startsWith(ampm[amindex], Qt::CaseInsensitive)) { str = ampm[amindex]; return AM; - } else if (str.indexOf(ampm[pmindex], 0, Qt::CaseInsensitive) == 0) { + } else if (str.startsWith(ampm[pmindex], Qt::CaseInsensitive)) { str = ampm[pmindex]; return PM; } else if (context == FromString || (str.count(space) == 0 && str.size() >= size)) { diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 3cebea77d6d..3e6afdb5869 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2307,13 +2307,31 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event) style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this); } +/* + Returns the string for AM and PM markers. + + If a translation for "AM" and "PM" is installed, then use that. + Otherwise, use the default implementation, which uses the locale. +*/ QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const { + QString original; + QString translated; if (ap == AmText) { - return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am")); + original = QLatin1String(cs == UpperCase ? "AM" : "am"); + translated = (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am")); } else { - return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm")); + original = QLatin1String(cs == UpperCase ? "PM" : "pm"); + translated = (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm")); } + + // This logic fails if a translation exists but doesn't change the string, + // which we can accept as a corner-case for which a locale-derived answer + // will be acceptable. + if (original != translated) + return translated; + + return QDateTimeParser::getAmPmText(ap, cs); } int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) const diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 38b72ab91fe..ce7cacf9668 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2490,17 +2490,20 @@ void tst_QDateTime::fromString_LOCALE_ILDATE() void tst_QDateTime::fromStringToStringLocale_data() { + QTest::addColumn("locale"); QTest::addColumn("dateTime"); - QTest::newRow("data0") << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); + QTest::newRow("frFR") << QLocale(QLocale::French, QLocale::France) << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); + QTest::newRow("spCO") << QLocale(QLocale::Spanish, QLocale::Colombia) << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); } void tst_QDateTime::fromStringToStringLocale() { + QFETCH(QLocale, locale); QFETCH(QDateTime, dateTime); QLocale def; - QLocale::setDefault(QLocale(QLocale::French, QLocale::France)); + QLocale::setDefault(locale); #define ROUNDTRIP(format) \ QCOMPARE(QDateTime::fromString(dateTime.toString(format), format), dateTime) From eed85dc3e72c56caaa65dd4ec27ef6892ca1ffae Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 17 Jun 2019 17:02:15 +0200 Subject: [PATCH 007/172] Turn on C++11 and 14 correctly Without this, a local build of this test on macOS fails. Change-Id: Ie03fa47ff0a54db752af47f223fbe5724cd9c976 Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qglobal/qglobal.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/global/qglobal/qglobal.pro b/tests/auto/corelib/global/qglobal/qglobal.pro index b1057694307..e4453affa54 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.pro +++ b/tests/auto/corelib/global/qglobal/qglobal.pro @@ -2,4 +2,6 @@ CONFIG += testcase TARGET = tst_qglobal QT = core testlib SOURCES = tst_qglobal.cpp qglobal.c -contains(QT_CONFIG, c++1z): CONFIG += c++1z +qtConfig(c++11): CONFIG += c++11 +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z From e6f7cc96fa09b50c17bc5f4645b06c30145a3f55 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 17 Jun 2019 17:07:45 +0200 Subject: [PATCH 008/172] Use C++11 alignof as reference for Q_ALIGNOF, and fix test on Android Not removing QT_EMULATED_ALIGNOF logic from qglobal.h at this point, as it might be used elsewhere. Change-Id: Ie78922bb604a54aed03ab5b88e31a7f29a3a4de0 Fixes: QTBUG-73561 Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 56da047147d..7800a101ecb 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -468,7 +468,7 @@ typedef int (Empty::*memFun) (); QCOMPARE(Q_ALIGNOF(type), size_t(alignment)); \ /* Compare to native operator for compilers that support it, otherwise... erm... check consistency! :-) */ \ - QCOMPARE(QT_EMULATED_ALIGNOF(type), Q_ALIGNOF(type)); \ + QCOMPARE(alignof(type), Q_ALIGNOF(type)); \ } while (false) /**/ @@ -521,7 +521,7 @@ void tst_QGlobal::qAlignOf() TEST_AlignOf_impl(AlignmentInStruct, Q_ALIGNOF(AlignmentInStruct)); // 32-bit x86 ABI, Clang disagrees with gcc -#if !defined(Q_PROCESSOR_X86_32) || !defined(Q_CC_CLANG) +#if !defined(Q_PROCESSOR_X86_32) || !defined(Q_CC_CLANG) || defined(Q_OS_ANDROID) TEST_AlignOf_impl(qint64 [5], Q_ALIGNOF(qint64)); #else TEST_AlignOf_impl(qint64 [5], Q_ALIGNOF(AlignmentInStruct)); From 4ad915425d804df798e12031c9b2fc13534dcb97 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 3 May 2019 14:17:19 +0200 Subject: [PATCH 009/172] Doc: Replace example file lists with links to code.qt.io Instead of generating .html page for each file in an example project, generate links to code.qt.io, under the correct path and branch, where the user can browse the example source. Store all URLs under QT_INSTALL_DOCS/config where other qt5 submodules can access them. The repository name appears in the URL, so we cannot define a single URL for all modules. Task-number: QTBUG-74391 Change-Id: I63d4d6d2c352877797b1ee8e057d48c0cd789bff Reviewed-by: Paul Wicking --- doc/config/exampleurl-qt3d.qdocconf | 1 + doc/config/exampleurl-qtactiveqt.qdocconf | 1 + doc/config/exampleurl-qtandroidextras.qdocconf | 1 + doc/config/exampleurl-qtbase.qdocconf | 1 + doc/config/exampleurl-qtcharts.qdocconf | 1 + doc/config/exampleurl-qtconnectivity.qdocconf | 1 + doc/config/exampleurl-qtdatavis3d.qdocconf | 1 + doc/config/exampleurl-qtdeclarative.qdocconf | 1 + doc/config/exampleurl-qtdoc.qdocconf | 1 + doc/config/exampleurl-qtgamepad.qdocconf | 1 + doc/config/exampleurl-qtgraphicaleffects.qdocconf | 1 + doc/config/exampleurl-qtimageformats.qdocconf | 1 + doc/config/exampleurl-qtlocation.qdocconf | 1 + doc/config/exampleurl-qtlottie.qdocconf | 1 + doc/config/exampleurl-qtmacextras.qdocconf | 1 + doc/config/exampleurl-qtmultimedia.qdocconf | 1 + doc/config/exampleurl-qtnetworkauth.qdocconf | 1 + doc/config/exampleurl-qtpurchasing.qdocconf | 1 + doc/config/exampleurl-qtquickcontrols.qdocconf | 1 + doc/config/exampleurl-qtquickcontrols2.qdocconf | 1 + doc/config/exampleurl-qtremoteobjects.qdocconf | 1 + doc/config/exampleurl-qtscript.qdocconf | 1 + doc/config/exampleurl-qtscxml.qdocconf | 1 + doc/config/exampleurl-qtsensors.qdocconf | 1 + doc/config/exampleurl-qtserialbus.qdocconf | 1 + doc/config/exampleurl-qtserialport.qdocconf | 1 + doc/config/exampleurl-qtspeech.qdocconf | 1 + doc/config/exampleurl-qtsvg.qdocconf | 1 + doc/config/exampleurl-qttools.qdocconf | 1 + doc/config/exampleurl-qtvirtualkeyboard.qdocconf | 1 + doc/config/exampleurl-qtwayland.qdocconf | 1 + doc/config/exampleurl-qtwebchannel.qdocconf | 1 + doc/config/exampleurl-qtwebengine.qdocconf | 1 + doc/config/exampleurl-qtwebsockets.qdocconf | 1 + doc/config/exampleurl-qtwebview.qdocconf | 1 + doc/config/exampleurl-qtwinextras.qdocconf | 1 + doc/config/exampleurl-qtx11extras.qdocconf | 1 + doc/config/exampleurl-qtxmlpatterns.qdocconf | 1 + src/concurrent/doc/qtconcurrent.qdocconf | 1 + src/corelib/doc/qtcore.qdocconf | 1 + src/dbus/doc/qtdbus.qdocconf | 1 + src/gui/doc/qtgui.qdocconf | 1 + src/network/doc/qtnetwork.qdocconf | 1 + src/opengl/doc/qtopengl.qdocconf | 1 + src/platformheaders/doc/qtplatformheaders.qdocconf | 1 + src/printsupport/doc/qtprintsupport.qdocconf | 1 + src/sql/doc/qtsql.qdocconf | 1 + src/testlib/doc/qttestlib.qdocconf | 1 + src/widgets/doc/qtwidgets.qdocconf | 1 + src/xml/doc/qtxml.qdocconf | 1 + 50 files changed, 50 insertions(+) create mode 100644 doc/config/exampleurl-qt3d.qdocconf create mode 100644 doc/config/exampleurl-qtactiveqt.qdocconf create mode 100644 doc/config/exampleurl-qtandroidextras.qdocconf create mode 100644 doc/config/exampleurl-qtbase.qdocconf create mode 100644 doc/config/exampleurl-qtcharts.qdocconf create mode 100644 doc/config/exampleurl-qtconnectivity.qdocconf create mode 100644 doc/config/exampleurl-qtdatavis3d.qdocconf create mode 100644 doc/config/exampleurl-qtdeclarative.qdocconf create mode 100644 doc/config/exampleurl-qtdoc.qdocconf create mode 100644 doc/config/exampleurl-qtgamepad.qdocconf create mode 100644 doc/config/exampleurl-qtgraphicaleffects.qdocconf create mode 100644 doc/config/exampleurl-qtimageformats.qdocconf create mode 100644 doc/config/exampleurl-qtlocation.qdocconf create mode 100644 doc/config/exampleurl-qtlottie.qdocconf create mode 100644 doc/config/exampleurl-qtmacextras.qdocconf create mode 100644 doc/config/exampleurl-qtmultimedia.qdocconf create mode 100644 doc/config/exampleurl-qtnetworkauth.qdocconf create mode 100644 doc/config/exampleurl-qtpurchasing.qdocconf create mode 100644 doc/config/exampleurl-qtquickcontrols.qdocconf create mode 100644 doc/config/exampleurl-qtquickcontrols2.qdocconf create mode 100644 doc/config/exampleurl-qtremoteobjects.qdocconf create mode 100644 doc/config/exampleurl-qtscript.qdocconf create mode 100644 doc/config/exampleurl-qtscxml.qdocconf create mode 100644 doc/config/exampleurl-qtsensors.qdocconf create mode 100644 doc/config/exampleurl-qtserialbus.qdocconf create mode 100644 doc/config/exampleurl-qtserialport.qdocconf create mode 100644 doc/config/exampleurl-qtspeech.qdocconf create mode 100644 doc/config/exampleurl-qtsvg.qdocconf create mode 100644 doc/config/exampleurl-qttools.qdocconf create mode 100644 doc/config/exampleurl-qtvirtualkeyboard.qdocconf create mode 100644 doc/config/exampleurl-qtwayland.qdocconf create mode 100644 doc/config/exampleurl-qtwebchannel.qdocconf create mode 100644 doc/config/exampleurl-qtwebengine.qdocconf create mode 100644 doc/config/exampleurl-qtwebsockets.qdocconf create mode 100644 doc/config/exampleurl-qtwebview.qdocconf create mode 100644 doc/config/exampleurl-qtwinextras.qdocconf create mode 100644 doc/config/exampleurl-qtx11extras.qdocconf create mode 100644 doc/config/exampleurl-qtxmlpatterns.qdocconf diff --git a/doc/config/exampleurl-qt3d.qdocconf b/doc/config/exampleurl-qt3d.qdocconf new file mode 100644 index 00000000000..1a141514162 --- /dev/null +++ b/doc/config/exampleurl-qt3d.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qt3d.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtactiveqt.qdocconf b/doc/config/exampleurl-qtactiveqt.qdocconf new file mode 100644 index 00000000000..f1abbd165e1 --- /dev/null +++ b/doc/config/exampleurl-qtactiveqt.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtactiveqt.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtandroidextras.qdocconf b/doc/config/exampleurl-qtandroidextras.qdocconf new file mode 100644 index 00000000000..44984a56934 --- /dev/null +++ b/doc/config/exampleurl-qtandroidextras.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtandroidextras.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtbase.qdocconf b/doc/config/exampleurl-qtbase.qdocconf new file mode 100644 index 00000000000..b29df464ba4 --- /dev/null +++ b/doc/config/exampleurl-qtbase.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtbase.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtcharts.qdocconf b/doc/config/exampleurl-qtcharts.qdocconf new file mode 100644 index 00000000000..2e49a7d1d86 --- /dev/null +++ b/doc/config/exampleurl-qtcharts.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtcharts.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtconnectivity.qdocconf b/doc/config/exampleurl-qtconnectivity.qdocconf new file mode 100644 index 00000000000..42923eb6732 --- /dev/null +++ b/doc/config/exampleurl-qtconnectivity.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtconnectivity.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtdatavis3d.qdocconf b/doc/config/exampleurl-qtdatavis3d.qdocconf new file mode 100644 index 00000000000..66f129a7731 --- /dev/null +++ b/doc/config/exampleurl-qtdatavis3d.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtdatavis3d.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtdeclarative.qdocconf b/doc/config/exampleurl-qtdeclarative.qdocconf new file mode 100644 index 00000000000..4b1d751b609 --- /dev/null +++ b/doc/config/exampleurl-qtdeclarative.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtdoc.qdocconf b/doc/config/exampleurl-qtdoc.qdocconf new file mode 100644 index 00000000000..947a5757728 --- /dev/null +++ b/doc/config/exampleurl-qtdoc.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtdoc.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtgamepad.qdocconf b/doc/config/exampleurl-qtgamepad.qdocconf new file mode 100644 index 00000000000..d55de4e3d93 --- /dev/null +++ b/doc/config/exampleurl-qtgamepad.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtgamepad.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtgraphicaleffects.qdocconf b/doc/config/exampleurl-qtgraphicaleffects.qdocconf new file mode 100644 index 00000000000..4d25ef4c944 --- /dev/null +++ b/doc/config/exampleurl-qtgraphicaleffects.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtgraphicaleffects.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtimageformats.qdocconf b/doc/config/exampleurl-qtimageformats.qdocconf new file mode 100644 index 00000000000..1070beaf128 --- /dev/null +++ b/doc/config/exampleurl-qtimageformats.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtimageformats.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtlocation.qdocconf b/doc/config/exampleurl-qtlocation.qdocconf new file mode 100644 index 00000000000..93d47fca135 --- /dev/null +++ b/doc/config/exampleurl-qtlocation.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtlocation.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtlottie.qdocconf b/doc/config/exampleurl-qtlottie.qdocconf new file mode 100644 index 00000000000..f60714027ab --- /dev/null +++ b/doc/config/exampleurl-qtlottie.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtlottie.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtmacextras.qdocconf b/doc/config/exampleurl-qtmacextras.qdocconf new file mode 100644 index 00000000000..1e2d515e05b --- /dev/null +++ b/doc/config/exampleurl-qtmacextras.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtmacextras.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtmultimedia.qdocconf b/doc/config/exampleurl-qtmultimedia.qdocconf new file mode 100644 index 00000000000..b710693d315 --- /dev/null +++ b/doc/config/exampleurl-qtmultimedia.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtnetworkauth.qdocconf b/doc/config/exampleurl-qtnetworkauth.qdocconf new file mode 100644 index 00000000000..e71da43bb18 --- /dev/null +++ b/doc/config/exampleurl-qtnetworkauth.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtnetworkauth.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtpurchasing.qdocconf b/doc/config/exampleurl-qtpurchasing.qdocconf new file mode 100644 index 00000000000..fe232c02fe2 --- /dev/null +++ b/doc/config/exampleurl-qtpurchasing.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtpurchasing.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtquickcontrols.qdocconf b/doc/config/exampleurl-qtquickcontrols.qdocconf new file mode 100644 index 00000000000..e9cd8c49f34 --- /dev/null +++ b/doc/config/exampleurl-qtquickcontrols.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtquickcontrols.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtquickcontrols2.qdocconf b/doc/config/exampleurl-qtquickcontrols2.qdocconf new file mode 100644 index 00000000000..3e2749ec657 --- /dev/null +++ b/doc/config/exampleurl-qtquickcontrols2.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtremoteobjects.qdocconf b/doc/config/exampleurl-qtremoteobjects.qdocconf new file mode 100644 index 00000000000..40c4c68bff2 --- /dev/null +++ b/doc/config/exampleurl-qtremoteobjects.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtremoteobjects.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtscript.qdocconf b/doc/config/exampleurl-qtscript.qdocconf new file mode 100644 index 00000000000..b7b5324481a --- /dev/null +++ b/doc/config/exampleurl-qtscript.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtscript.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtscxml.qdocconf b/doc/config/exampleurl-qtscxml.qdocconf new file mode 100644 index 00000000000..2383f823ea8 --- /dev/null +++ b/doc/config/exampleurl-qtscxml.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtscxml.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtsensors.qdocconf b/doc/config/exampleurl-qtsensors.qdocconf new file mode 100644 index 00000000000..291a0e80858 --- /dev/null +++ b/doc/config/exampleurl-qtsensors.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtsensors.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtserialbus.qdocconf b/doc/config/exampleurl-qtserialbus.qdocconf new file mode 100644 index 00000000000..b263b510389 --- /dev/null +++ b/doc/config/exampleurl-qtserialbus.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtserialbus.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtserialport.qdocconf b/doc/config/exampleurl-qtserialport.qdocconf new file mode 100644 index 00000000000..6b1e66b1d3c --- /dev/null +++ b/doc/config/exampleurl-qtserialport.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtserialport.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtspeech.qdocconf b/doc/config/exampleurl-qtspeech.qdocconf new file mode 100644 index 00000000000..0cb3b209bd8 --- /dev/null +++ b/doc/config/exampleurl-qtspeech.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtspeech.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtsvg.qdocconf b/doc/config/exampleurl-qtsvg.qdocconf new file mode 100644 index 00000000000..2514710f119 --- /dev/null +++ b/doc/config/exampleurl-qtsvg.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtsvg.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qttools.qdocconf b/doc/config/exampleurl-qttools.qdocconf new file mode 100644 index 00000000000..12a79f303db --- /dev/null +++ b/doc/config/exampleurl-qttools.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qttools.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtvirtualkeyboard.qdocconf b/doc/config/exampleurl-qtvirtualkeyboard.qdocconf new file mode 100644 index 00000000000..f9080346b31 --- /dev/null +++ b/doc/config/exampleurl-qtvirtualkeyboard.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtvirtualkeyboard.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtwayland.qdocconf b/doc/config/exampleurl-qtwayland.qdocconf new file mode 100644 index 00000000000..65417434cee --- /dev/null +++ b/doc/config/exampleurl-qtwayland.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtwayland.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtwebchannel.qdocconf b/doc/config/exampleurl-qtwebchannel.qdocconf new file mode 100644 index 00000000000..e9926b29e6e --- /dev/null +++ b/doc/config/exampleurl-qtwebchannel.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtwebchannel.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtwebengine.qdocconf b/doc/config/exampleurl-qtwebengine.qdocconf new file mode 100644 index 00000000000..27b28536ac6 --- /dev/null +++ b/doc/config/exampleurl-qtwebengine.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtwebengine.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtwebsockets.qdocconf b/doc/config/exampleurl-qtwebsockets.qdocconf new file mode 100644 index 00000000000..814f97b3e1b --- /dev/null +++ b/doc/config/exampleurl-qtwebsockets.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtwebsockets.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtwebview.qdocconf b/doc/config/exampleurl-qtwebview.qdocconf new file mode 100644 index 00000000000..38a57352858 --- /dev/null +++ b/doc/config/exampleurl-qtwebview.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtwebview.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtwinextras.qdocconf b/doc/config/exampleurl-qtwinextras.qdocconf new file mode 100644 index 00000000000..daf3a71fee9 --- /dev/null +++ b/doc/config/exampleurl-qtwinextras.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtwinextras.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtx11extras.qdocconf b/doc/config/exampleurl-qtx11extras.qdocconf new file mode 100644 index 00000000000..046691d3344 --- /dev/null +++ b/doc/config/exampleurl-qtx11extras.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtx11extras.git/tree/examples/\1?h=$QT_VER" diff --git a/doc/config/exampleurl-qtxmlpatterns.qdocconf b/doc/config/exampleurl-qtxmlpatterns.qdocconf new file mode 100644 index 00000000000..b28a32767ac --- /dev/null +++ b/doc/config/exampleurl-qtxmlpatterns.qdocconf @@ -0,0 +1 @@ +url.examples = "https://code.qt.io/cgit/qt/qtxmlpatterns.git/tree/examples/\1?h=$QT_VER" diff --git a/src/concurrent/doc/qtconcurrent.qdocconf b/src/concurrent/doc/qtconcurrent.qdocconf index 356d602a7c4..610dca2a7e1 100644 --- a/src/concurrent/doc/qtconcurrent.qdocconf +++ b/src/concurrent/doc/qtconcurrent.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtConcurrent description = Qt Concurrent Reference Documentation diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 85dcde4607d..15b1925e51b 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtCore description = Qt Core Reference Documentation diff --git a/src/dbus/doc/qtdbus.qdocconf b/src/dbus/doc/qtdbus.qdocconf index 4ff7242b25b..e08bbfd94e5 100644 --- a/src/dbus/doc/qtdbus.qdocconf +++ b/src/dbus/doc/qtdbus.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) # Name of the project which must match the outputdir. Determines the .index file project = QtDBus diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf index b8b8a00cd66..049b9ef1797 100644 --- a/src/gui/doc/qtgui.qdocconf +++ b/src/gui/doc/qtgui.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtGui description = Qt GUI Reference Documentation diff --git a/src/network/doc/qtnetwork.qdocconf b/src/network/doc/qtnetwork.qdocconf index 4f667eed9d7..5465b1c0af1 100644 --- a/src/network/doc/qtnetwork.qdocconf +++ b/src/network/doc/qtnetwork.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtNetwork description = Qt Network Reference Documentation diff --git a/src/opengl/doc/qtopengl.qdocconf b/src/opengl/doc/qtopengl.qdocconf index 2d38a5d2af1..22194bda596 100644 --- a/src/opengl/doc/qtopengl.qdocconf +++ b/src/opengl/doc/qtopengl.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) # Name of the project which must match the outputdir. Determines the .index file project = QtOpenGL diff --git a/src/platformheaders/doc/qtplatformheaders.qdocconf b/src/platformheaders/doc/qtplatformheaders.qdocconf index 9a034e7671e..c8868d678b9 100644 --- a/src/platformheaders/doc/qtplatformheaders.qdocconf +++ b/src/platformheaders/doc/qtplatformheaders.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtPlatformHeaders description = Qt Platform Headers Reference Documentation diff --git a/src/printsupport/doc/qtprintsupport.qdocconf b/src/printsupport/doc/qtprintsupport.qdocconf index fbb6f8d1a98..b46d9f37d90 100644 --- a/src/printsupport/doc/qtprintsupport.qdocconf +++ b/src/printsupport/doc/qtprintsupport.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtPrintSupport description = Qt Print Support Reference Documentation diff --git a/src/sql/doc/qtsql.qdocconf b/src/sql/doc/qtsql.qdocconf index 5a224adeb96..f353a11e8b0 100644 --- a/src/sql/doc/qtsql.qdocconf +++ b/src/sql/doc/qtsql.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtSql description = Qt SQL Reference Documentation diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf index 5fdf6d9415a..73310221cf3 100644 --- a/src/testlib/doc/qttestlib.qdocconf +++ b/src/testlib/doc/qttestlib.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtTestLib moduleheader = QtTest diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf index 5d7262fca16..6e04372a8b6 100644 --- a/src/widgets/doc/qtwidgets.qdocconf +++ b/src/widgets/doc/qtwidgets.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtWidgets description = Qt Widgets Reference Documentation diff --git a/src/xml/doc/qtxml.qdocconf b/src/xml/doc/qtxml.qdocconf index a23915487f0..25a463fecd2 100644 --- a/src/xml/doc/qtxml.qdocconf +++ b/src/xml/doc/qtxml.qdocconf @@ -1,4 +1,5 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtbase.qdocconf) project = QtXml description = Qt XML Reference Documentation From cdfe8c76af1518ccdd497c20ecc189365c733879 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 17 Jun 2019 14:25:09 +0200 Subject: [PATCH 010/172] checkOcspResponse - remove unneeded locking and also plain wrong comments: since we don't set verification callback on a store - we don't have to lock (our q_X509Callback never gets called). This change should simplify the merge with change I have in 5.12 (where I completely got rid of locking). Since I don't care about exact errors found (relying on the fact it's the same chain of certs we check in SSL_connect/SSL_accept), for now we don't try to extract them from OCSP_basic_verify. In fufure, if these chains are different, we can create a temporary store (see how it's done in 'verify', for example) and set a VF callback on this store. Change-Id: I4a36e19836d19c2ea95c869dcfe85f49fe723ff0 Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslsocket_openssl.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 977d8a6742d..7c04feb5f88 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1575,27 +1575,15 @@ bool QSslSocketBackendPrivate::checkOcspStatus() // 3) It checks CertID in response. // 4) Ensures the responder is authorized to sign the status respond. // - // Here it's important to notice that it calls X509_cert_verify and - // as a result, possibly, our verification callback. Given this callback - // at the moment uses a global variable, we have to lock. This will change - // as soon as we fix our verification procedure. - // Also note, OpenSSL prior to 1.0.2b would only use bs->certs to + // Note, OpenSSL prior to 1.0.2b would only use bs->certs to // verify the responder's chain (see their commit 4ba9a4265bd). // Working this around - is too much fuss for ancient versions we // are dropping quite soon anyway. { const unsigned long verificationFlags = 0; - const QMutexLocker locker(&_q_sslErrorList()->mutex); - // Before unlocking the mutex, startHandshake() stores errors (found in SSL_connect() - // or SSL_accept()) into the local variable, so it's safe to clear it here - as soon - // as we managed to lock, whoever had the lock before, already stored their own copy - // of errors. - _q_sslErrorList()->errors.clear(); const int success = q_OCSP_basic_verify(basicResponse, peerChain, store, verificationFlags); - if (success <= 0 || _q_sslErrorList()->errors.size()) { - _q_sslErrorList()->errors.clear(); + if (success <= 0) ocspErrors.push_back(QSslError::OcspResponseCannotBeTrusted); - } } if (q_OCSP_resp_count(basicResponse) != 1) { From 6275e037bfe532d12ecd76913d5d36a91c1d5034 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 18 Jun 2019 23:03:01 +0200 Subject: [PATCH 011/172] Android: Make sure that the root file system is in the list of volumes On Android (at least in the emulator), the root file system is reported to be of type rootfs, which we usually ignore on Linux as legacy. Also, it's a read-only file system with bytesTotal reported as zero. We usually ignore such volumes, but as the root file system is expected to be in the list, we should never ignore it. This fixes the failing QStorageInfo test. Change-Id: I778ee9e76e385649e58d5e5ac7e0ae2d8e0ba92b Fixes: QTBUG-73563 Reviewed-by: Thiago Macieira Reviewed-by: BogDan Vatra --- src/corelib/io/qstorageinfo_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index b7621b5d2f1..6b821b0fe9a 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -220,7 +220,7 @@ static bool shouldIncludeFs(const QStorageIterator &it) return false; } -#ifdef Q_OS_LINUX +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) if (it.fileSystemType() == "rootfs") return false; #endif @@ -846,7 +846,7 @@ QList QStorageInfoPrivate::mountedVolumes() const QString mountDir = it.rootPath(); QStorageInfo info(mountDir); - if (info.bytesTotal() == 0) + if (info.bytesTotal() == 0 && info != root()) continue; volumes.append(info); } From b877285694501d16b2bb0dc8d1a92e185b079b87 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 19 Jun 2019 00:01:14 +0200 Subject: [PATCH 012/172] Android: don't run test function for fd leakage, make test pass It is sufficient to run this test on systems where we don't need to set up dependencies and satisfy other assumptions the test makes. It is safe to assume that if this test passes on regular Unix, then QTemporaryFile will behave as expected on Android as well. Change-Id: Iaf9a67d7c12b3acfd0992bab591c3f906b073d9e Fixes: QTBUG-73564 Reviewed-by: Thiago Macieira --- .../auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index cf4ab4902dc..b8f67c7d379 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -569,13 +569,7 @@ void tst_QTemporaryFile::rename() void tst_QTemporaryFile::renameFdLeak() { -#ifdef Q_OS_UNIX - -# if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) - ChdirOnReturn cor(QDir::currentPath()); - QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); -# endif - +#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA(__FILE__)); QVERIFY(!sourceFile.isEmpty()); // Test this on Unix only From 2ce4a9f48705095669cb74c8de9d8a72f9d49b0e Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 19 Jun 2019 16:35:28 +0200 Subject: [PATCH 013/172] Fix crash in QPainterPath::reserve() Function did not handle default-constructed (null d_ptr) path correctly. Fixes: QTBUG-76516 Change-Id: I2925d4306f7fce34ece6739b18a8e275e7970837 Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qpainterpath.cpp | 3 ++- tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index cbe34c2857a..d20faf89a2f 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -675,8 +675,9 @@ void QPainterPath::reserve(int size) { Q_D(QPainterPath); if ((!d && size > 0) || (d && d->elements.capacity() < size)) { + ensureData(); detach(); - d->elements.reserve(size); + d_func()->elements.reserve(size); } } diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index 69c961c1a13..c90348e91a6 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -189,6 +189,10 @@ void tst_QPainterPath::reserveAndCapacity() p.reserve(0); QVERIFY(p.capacity() >= 1000); + + QPainterPath p2; + p2.reserve(10); + QVERIFY(p.capacity() >= 10); } Q_DECLARE_METATYPE(QPainterPath) From cbdc9a7786278c31fdb6eb465f32d0374349c1ef Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 20 Jun 2019 09:36:46 -0700 Subject: [PATCH 014/172] RCC: Change the default compression to Zlib Codebases using QResource::isCompressed() and assuming it is Zlib break if zstd is enabled. So change the default back to Zlib until Qt 6.0. [ChangeLog][Important Behavior Changes] RCC's default compression algorithm was changed back to Zlib, as it was in all previous releases until 5.13.0. The default will remain Zlib for all Qt 5.x releases but will change in Qt 6.0. To activate Zstd compression for your resources, either pass the --compress-algo=zstd option to the rcc tool or add the XML attribute compression-algorithm="zstd" to the tags in the .qrc file. Task-number: QTBUG-76521 Change-Id: Ief874765cd7b43798de3fffd15a9f56fd9ad1ad4 Reviewed-by: Simon Hausmann --- src/tools/rcc/rcc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 862e574f2db..011a7db8100 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -58,7 +58,7 @@ enum { CONSTANT_COMPRESSTHRESHOLD_DEFAULT = 70 }; -#if QT_CONFIG(zstd) +#if QT_CONFIG(zstd) && QT_VERSION >= QT_VERSION_CHECK(6,0,0) # define CONSTANT_COMPRESSALGO_DEFAULT RCCResourceLibrary::CompressionAlgorithm::Zstd #elif !defined(QT_NO_COMPRESS) # define CONSTANT_COMPRESSALGO_DEFAULT RCCResourceLibrary::CompressionAlgorithm::Zlib From 859eb2467dbc15728ea2ee15931073a4147f8d59 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 Sep 2018 13:20:42 -0700 Subject: [PATCH 015/172] Add qmake config for controlling LTCG behavior for static libs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Static libraries may get installed and used by other builds, which may be done with a different version or build of the compiler. So this commit introduces two new flags: - no-static-ltcg: disables LTCG completely for static libraries - fat-static-lto: forces static libraries to produce fat LTO objects fat-static-lto is useful for Linux distributions, since installed static libraries should not carry LTO information, but that information is useful during Qt's own build. This feature should be used alongside some compiler-specific method of removing the LTO information from the static libraries prior to installation, so only the regular part remains. For current GCC versions, this command suffices: strip -R '.gnu.lto*' -R '.gnu.debuglto*' libname.a Otherwise, distributions can use "no-static-ltcg" to disable it completely. Change-Id: I495bc19409f348069f5bfffd155237ade9f4b42f Reviewed-by: Jörg Bornemann --- mkspecs/features/ltcg.prf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/ltcg.prf b/mkspecs/features/ltcg.prf index f2dbc6fa9e0..a94f6d0eebf 100644 --- a/mkspecs/features/ltcg.prf +++ b/mkspecs/features/ltcg.prf @@ -1,4 +1,6 @@ -CONFIG(release, debug|release) { +static:no-static-ltcg { + # Static library but no-static-ltcg enabled: skip LTCG +} else: CONFIG(release, debug|release) { # We need fat object files when creating static libraries on some platforms # so the linker will know to load a particular object from the library # in the first place. On others, we have special ar and nm to create the symbol @@ -22,7 +24,7 @@ CONFIG(release, debug|release) { } } - fat-lto { + fat-lto|if(static:fat-static-lto) { QMAKE_CFLAGS_LTCG += $$QMAKE_CFLAGS_LTCG_FATOBJECTS QMAKE_CXXFLAGS_LTCG += $$QMAKE_CXXFLAGS_LTCG_FATOBJECTS } From 0f3f143f6deee3b31a7dfaba07dfd517f0aee442 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sun, 23 Jun 2019 23:26:28 +0200 Subject: [PATCH 016/172] Fix window shortcuts when a completer popup has focus The completer popup has focus, making QShortcut direct to it's window rather than to the window the completer belongs to. As QShortcut handles the case for Tool windows that have a parent, but doens't do the same for popups. And they shouldn't be treated the same way, as a context menu popup for a e.g. text edit should in fact block the text edit's shortcuts while open. However, the completer popup is special, in that it explicitly makes the widget completes for its focusProxy, which is what we can use to fix this issue. Change-Id: Ie7177d39668b3af14a1d9e0ee5d93eca9c67c8af Fixes: QTBUG-4485 Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qshortcut.cpp | 13 +++++++--- .../kernel/qshortcut/tst_qshortcut.cpp | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index a680ff79130..b7857e2b74c 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -189,10 +189,15 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge } #endif - /* if a floating tool window is active, keep shortcuts on the - * parent working */ - if (active_window != tlw && active_window && active_window->windowType() == Qt::Tool && active_window->parentWidget()) { - active_window = active_window->parentWidget()->window(); + if (active_window && active_window != tlw) { + /* if a floating tool window is active, keep shortcuts on the parent working. + * and if a popup window is active (f.ex a completer), keep shortcuts on the + * focus proxy working */ + if (active_window->windowType() == Qt::Tool && active_window->parentWidget()) { + active_window = active_window->parentWidget()->window(); + } else if (active_window->windowType() == Qt::Popup && active_window->focusProxy()) { + active_window = active_window->focusProxy()->window(); + } } if (active_window != tlw) { diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index b78287f84bc..2c9295d995c 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include #include @@ -120,6 +122,7 @@ private slots: void unicodeCompare(); void context(); void duplicatedShortcutOverride(); + void shortcutToFocusProxy(); protected: static Qt::KeyboardModifiers toButtons( int key ); @@ -1279,5 +1282,28 @@ void tst_QShortcut::testElement() } } +void tst_QShortcut::shortcutToFocusProxy() +{ + QLineEdit le; + QCompleter completer; + QStringListModel *slm = new QStringListModel(QStringList() << "a0" << "a1" << "a2", &completer); + completer.setModel(slm); + completer.setCompletionMode(QCompleter::PopupCompletion); + le.setCompleter(&completer); + QShortcut *shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_S), &le); + QObject::connect(shortcut, &QShortcut::activated, &le, &QLineEdit::clear); + le.setFocus(); + le.show(); + + QVERIFY(QTest::qWaitForWindowActive(&le)); + QCOMPARE(QApplication::focusWidget(), &le); + QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_A); + + QCOMPARE(le.text(), QString::fromLocal8Bit("a")); + QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Alt); + QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_S, Qt::AltModifier); + QCOMPARE(le.text(), QString()); +} + QTEST_MAIN(tst_QShortcut) #include "tst_qshortcut.moc" From 9be66cb282dee1ce4380602a2f3caf5abfd144cf Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 24 Apr 2019 15:40:29 +0200 Subject: [PATCH 017/172] Android: Use Android button layout for the DialogButtonBoxLayout hint Fixes: QTBUG-70045 Change-Id: I9c51e9a769f510a6f14f6e9d78583caf3df15031 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidplatformtheme.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index b891407c445..94405738f35 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -488,6 +488,8 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const Q_FALLTHROUGH(); } + case DialogButtonBoxLayout: + return QVariant(QPlatformDialogHelper::AndroidLayout); default: return QPlatformTheme::themeHint(hint); } From 530c6903a449f44cc9c3fc578d5394c0eed8ddec Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 3 Jun 2019 12:43:26 +0200 Subject: [PATCH 018/172] Brush up Diaglib Fix most clang warnings about override, nullptr, range-based for loops. Change-Id: Id47e57adb63a38e2f397a31511b788a2432c97cf Reviewed-by: Oliver Wolff --- tests/manual/diaglib/debugproxystyle.h | 26 +++++++++++++------------- tests/manual/diaglib/eventfilter.cpp | 2 +- tests/manual/diaglib/eventfilter.h | 6 +++--- tests/manual/diaglib/logwidget.cpp | 4 ++-- tests/manual/diaglib/logwidget.h | 2 +- tests/manual/diaglib/qwidgetdump.cpp | 4 ++-- tests/manual/diaglib/qwidgetdump.h | 2 +- tests/manual/diaglib/qwindowdump.cpp | 4 ++-- tests/manual/diaglib/qwindowdump.h | 6 +++--- tests/manual/diaglib/textdump.cpp | 21 +++++++++------------ 10 files changed, 37 insertions(+), 40 deletions(-) diff --git a/tests/manual/diaglib/debugproxystyle.h b/tests/manual/diaglib/debugproxystyle.h index 01e1e6b6d12..51bf79374ee 100644 --- a/tests/manual/diaglib/debugproxystyle.h +++ b/tests/manual/diaglib/debugproxystyle.h @@ -39,19 +39,19 @@ class DebugProxyStyle : public QProxyStyle { public: explicit DebugProxyStyle(QStyle *style); - void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const; - void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const; - void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const; - void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const; - QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const; - QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const; - QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const; - QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const; - QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const; - int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const; - int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const; - QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const; - QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const; + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override; + void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override; + void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const override; + void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override; + QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override; + QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override; + QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override; + QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override; + QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override; + int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override; + int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; + QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = nullptr) const override; + QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override; }; } // namespace QtDiag diff --git a/tests/manual/diaglib/eventfilter.cpp b/tests/manual/diaglib/eventfilter.cpp index 39898f07811..b99d4099e35 100644 --- a/tests/manual/diaglib/eventfilter.cpp +++ b/tests/manual/diaglib/eventfilter.cpp @@ -197,7 +197,7 @@ static void formatApplicationState(QDebug debug) static void formatMouseState(QObject *o, QDebug debug) { if (o->isWidgetType()) { - const QWidget *w = static_cast(o); + auto w = static_cast(o); if (QWidget::mouseGrabber() == w) debug << " [grabbed]"; if (w->hasMouseTracking()) diff --git a/tests/manual/diaglib/eventfilter.h b/tests/manual/diaglib/eventfilter.h index 1f57fbeb8be..a8740bb4e9c 100644 --- a/tests/manual/diaglib/eventfilter.h +++ b/tests/manual/diaglib/eventfilter.h @@ -68,10 +68,10 @@ public: }; Q_DECLARE_FLAGS(ObjectTypes, ObjectType) - explicit EventFilter(EventCategories eventCategories, QObject *p = 0); - explicit EventFilter(QObject *p = 0); + explicit EventFilter(EventCategories eventCategories, QObject *p = nullptr); + explicit EventFilter(QObject *p = nullptr); - bool eventFilter(QObject *, QEvent *); + bool eventFilter(QObject *, QEvent *) override; ObjectTypes objectTypes() const { return m_objectTypes; } void setObjectTypes(ObjectTypes objectTypes) { m_objectTypes = objectTypes; } diff --git a/tests/manual/diaglib/logwidget.cpp b/tests/manual/diaglib/logwidget.cpp index 35fabd6e2ea..18a82d819e0 100644 --- a/tests/manual/diaglib/logwidget.cpp +++ b/tests/manual/diaglib/logwidget.cpp @@ -40,7 +40,7 @@ #include -LogWidget *LogWidget::m_instance = 0; +LogWidget *LogWidget::m_instance = nullptr; bool LogWidget::m_lineNumberingEnabled = true; bool LogWidget::m_showMessageType = true; int LogWidget::m_indent = 0; @@ -54,7 +54,7 @@ LogWidget::LogWidget(QWidget *parent) LogWidget::~LogWidget() { - LogWidget::m_instance = 0; + LogWidget::m_instance = nullptr; } QString LogWidget::startupMessage() diff --git a/tests/manual/diaglib/logwidget.h b/tests/manual/diaglib/logwidget.h index 55324e31001..b1ce43f2316 100644 --- a/tests/manual/diaglib/logwidget.h +++ b/tests/manual/diaglib/logwidget.h @@ -46,7 +46,7 @@ class LogWidget : public QPlainTextEdit { Q_OBJECT public: - explicit LogWidget(QWidget *parent = 0); + explicit LogWidget(QWidget *parent = nullptr); ~LogWidget(); static LogWidget *instance() { return m_instance; } diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp index 6c1e7d8f79d..5a2966021b9 100644 --- a/tests/manual/diaglib/qwidgetdump.cpp +++ b/tests/manual/diaglib/qwidgetdump.cpp @@ -59,8 +59,8 @@ static const char *qtWidgetClasses[] = { static bool isQtWidget(const char *className) { - for (size_t i = 0, count = sizeof(qtWidgetClasses) / sizeof(qtWidgetClasses[0]); i < count; ++i) { - if (!qstrcmp(className, qtWidgetClasses[i])) + for (auto qtWidgetClass : qtWidgetClasses) { + if (qstrcmp(className, qtWidgetClass) == 0) return true; } return false; diff --git a/tests/manual/diaglib/qwidgetdump.h b/tests/manual/diaglib/qwidgetdump.h index f3eb1fda8df..c9b2db72dde 100644 --- a/tests/manual/diaglib/qwidgetdump.h +++ b/tests/manual/diaglib/qwidgetdump.h @@ -35,7 +35,7 @@ QT_FORWARD_DECLARE_CLASS(QWidget) namespace QtDiag { -void dumpAllWidgets(FormatWindowOptions options = 0, const QWidget *root = 0); +void dumpAllWidgets(FormatWindowOptions options = {}, const QWidget *root = nullptr); } // namespace QtDiag diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp index 0e613753efd..381b6833595 100644 --- a/tests/manual/diaglib/qwindowdump.cpp +++ b/tests/manual/diaglib/qwindowdump.cpp @@ -73,7 +73,7 @@ if ((type & typeConstant) == typeConstant) \ if (flags & flagConstant) \ s << ' ' << #flagConstant; -void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags) +void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags) { str << showbase << hex << unsigned(flags) << dec << noshowbase; const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask; @@ -158,7 +158,7 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option } static void dumpWindowRecursion(QTextStream &str, const QWindow *w, - FormatWindowOptions options = 0, int depth = 0) + FormatWindowOptions options = {}, int depth = 0) { indentStream(str, 2 * depth); formatWindow(str, w, options); diff --git a/tests/manual/diaglib/qwindowdump.h b/tests/manual/diaglib/qwindowdump.h index 74f976567af..9d7491eab22 100644 --- a/tests/manual/diaglib/qwindowdump.h +++ b/tests/manual/diaglib/qwindowdump.h @@ -49,10 +49,10 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(FormatWindowOptions) void indentStream(QTextStream &s, int indent); void formatObject(QTextStream &str, const QObject *o); void formatRect(QTextStream &str, const QRect &geom); -void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags); +void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags); -void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = 0); -void dumpAllWindows(FormatWindowOptions options = 0); +void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = {}); +void dumpAllWindows(FormatWindowOptions options = {}); } // namespace QtDiag diff --git a/tests/manual/diaglib/textdump.cpp b/tests/manual/diaglib/textdump.cpp index e070a920e7d..8bb899783b4 100644 --- a/tests/manual/diaglib/textdump.cpp +++ b/tests/manual/diaglib/textdump.cpp @@ -381,7 +381,7 @@ static const EnumLookup *enumLookup(int v, const EnumLookup *array, size_t size) if (p->value == v) return p; } - return 0; + return nullptr; } static const char *enumName(int v, const EnumLookup *array, size_t size) @@ -394,15 +394,12 @@ static const char *enumName(int v, const EnumLookup *array, size_t size) // that change will be output. struct FormattingContext { - FormattingContext() : category(-1), direction(-1), joiningType(-1) - , decompositionTag(-1), script(-1), unicodeVersion(-1) {} - - int category; - int direction; - int joiningType; - int decompositionTag; - int script; - int unicodeVersion; + int category = -1; + int direction = -1; + int joiningType = -1; + int decompositionTag = -1; + int script = -1; + int unicodeVersion = -1; }; static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context) @@ -478,8 +475,8 @@ QString dumpTextAsCode(const QString &text) QString result; QTextStream str(&result); str << " QString result;\n" << hex << showbase; - for (int i = 0; i < text.size(); ++i) - str << " result += QChar(" << text.at(i).unicode() << ");\n"; + for (QChar c : text) + str << " result += QChar(" << c.unicode() << ");\n"; str << '\n'; return result; } From 244ff3311983112709643e789f42d1603ddbd401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 20 Jun 2019 14:47:12 +0200 Subject: [PATCH 019/172] styles example: Use QImage instead of QPixmap in NorwegianWoodStyle Using QImage allows creating the style before the application has been created, and is the more modern API. No changes to the documentation needed. Change-Id: Ifa0e5fa1113802fca18fbd45bb3c0a5ba1dbfeab Reviewed-by: Andreas Aardal Hanssen --- .../widgets/widgets/styles/norwegianwoodstyle.cpp | 13 +++++++------ .../widgets/widgets/styles/norwegianwoodstyle.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp index 8aca91a6861..a6d5d4a7e7d 100644 --- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp +++ b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp @@ -64,9 +64,9 @@ void NorwegianWoodStyle::polish(QPalette &palette) QColor beige(236, 182, 120); QColor slightlyOpaqueBlack(0, 0, 0, 63); - QPixmap backgroundImage(":/images/woodbackground.png"); - QPixmap buttonImage(":/images/woodbutton.png"); - QPixmap midImage = buttonImage; + QImage backgroundImage(":/images/woodbackground.png"); + QImage buttonImage(":/images/woodbutton.png"); + QImage midImage = buttonImage.convertToFormat(QImage::Format_RGB32); QPainter painter; painter.begin(&midImage); @@ -311,11 +311,12 @@ void NorwegianWoodStyle::drawControl(ControlElement element, //! [37] void NorwegianWoodStyle::setTexture(QPalette &palette, QPalette::ColorRole role, //! [37] //! [38] - const QPixmap &pixmap) + const QImage &image) { for (int i = 0; i < QPalette::NColorGroups; ++i) { - QColor color = palette.brush(QPalette::ColorGroup(i), role).color(); - palette.setBrush(QPalette::ColorGroup(i), role, QBrush(color, pixmap)); + QBrush brush(image); + brush.setColor(palette.brush(QPalette::ColorGroup(i), role).color()); + palette.setBrush(QPalette::ColorGroup(i), role, brush); } } //! [38] diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.h b/examples/widgets/widgets/styles/norwegianwoodstyle.h index c41d81d23a8..5a1783eb4d1 100644 --- a/examples/widgets/widgets/styles/norwegianwoodstyle.h +++ b/examples/widgets/widgets/styles/norwegianwoodstyle.h @@ -80,7 +80,7 @@ public: private: static void setTexture(QPalette &palette, QPalette::ColorRole role, - const QPixmap &pixmap); + const QImage &image); static QPainterPath roundRectPath(const QRect &rect); }; //! [0] From b6ded193ee64ffe67df6d22e7a23aa1ea9e02ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 5 Mar 2019 11:14:21 +0100 Subject: [PATCH 020/172] QHighDpi::fromNativePixels: use correct screen Calls like QHighDpi::fromNativePixels(point, window) would return device independent coordinates outside any screen in cases where the window is spanning multiple screens and the native point was not on the main screen. Correct this by looking up the correct screen and use its scale factor and origin when scaling coordinates. Task-number: QTBUG-73231 Change-Id: I01a3a42f42121b8d9f4ced2bb0fb023d6ae6bfe7 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qhighdpiscaling.cpp | 52 +++++++++--------------------- src/gui/kernel/qhighdpiscaling_p.h | 37 +++++++++++++++------ 2 files changed, 43 insertions(+), 46 deletions(-) diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 93fcb1a2160..0fea4164041 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -452,52 +452,30 @@ QDpi QHighDpiScaling::logicalDpi() return m_logicalDpi; } -qreal QHighDpiScaling::factor(const QScreen *screen) -{ - // Fast path for when scaling in Qt is not used at all. - if (!m_active) - return qreal(1.0); - - // The effective factor for a given screen is the product of the - // screen and global sub-factors - qreal factor = m_factor; - if (screen) - factor *= screenSubfactor(screen->handle()); - return factor; -} - -qreal QHighDpiScaling::factor(const QPlatformScreen *platformScreen) +QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QPlatformScreen *platformScreen, QPoint *nativePosition) { if (!m_active) - return qreal(1.0); - - return m_factor * screenSubfactor(platformScreen); + return { qreal(1), QPoint() }; + const QPlatformScreen *actualScreen = nativePosition ? + platformScreen->screenForPosition(*nativePosition) : platformScreen; + return { m_factor * screenSubfactor(actualScreen), actualScreen->geometry().topLeft() }; } -qreal QHighDpiScaling::factor(const QWindow *window) +QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QScreen *screen, QPoint *nativePosition) { if (!m_active) - return qreal(1.0); - - return factor(window ? window->screen() : QGuiApplication::primaryScreen()); + return { qreal(1), QPoint() }; + if (!screen) + return { m_factor, QPoint() }; // the global factor + return scaleAndOrigin(screen->handle(), nativePosition); } -QPoint QHighDpiScaling::origin(const QScreen *screen) +QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QWindow *window, QPoint *nativePosition) { - return screen->geometry().topLeft(); -} - -QPoint QHighDpiScaling::origin(const QPlatformScreen *platformScreen) -{ - return platformScreen->geometry().topLeft(); -} - -QPoint QHighDpiScaling::origin(const QWindow *window) -{ - if (window && window->isTopLevel() && window->screen()) - return window->screen()->geometry().topLeft(); - - return QPoint(0, 0); + if (!m_active) + return { qreal(1), QPoint() }; + QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen(); + return scaleAndOrigin(screen, nativePosition); } #endif //QT_NO_HIGHDPISCALING diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 525e3fe78e6..3410c1d345a 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -78,14 +78,23 @@ public: static void setScreenFactor(QScreen *window, qreal factor); static bool isActive() { return m_active; } - static qreal factor(const QWindow *window); - static qreal factor(const QScreen *screen); - static qreal factor(const QPlatformScreen *platformScreen); - static QPoint origin(const QScreen *screen); - static QPoint origin(const QPlatformScreen *platformScreen); - static QPoint origin(const QWindow *window); - static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen); + + struct ScaleAndOrigin + { + qreal factor; + QPoint origin; + }; + static ScaleAndOrigin scaleAndOrigin(const QPlatformScreen *platformScreen, QPoint *nativePosition = nullptr); + static ScaleAndOrigin scaleAndOrigin(const QScreen *screen, QPoint *nativePosition = nullptr); + static ScaleAndOrigin scaleAndOrigin(const QWindow *platformScreen, QPoint *nativePosition = nullptr); + + template + static qreal factor(C *context, QPoint *nativePosition = nullptr) { + return scaleAndOrigin(context, nativePosition).factor; + } + static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen); + static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen); static QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); static QPoint mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window); static QDpi logicalDpi(); @@ -166,16 +175,26 @@ inline QRegion scale(const QRegion ®ion, qreal scaleFactor, QPoint origin = Q return scaled; } +template +inline QPoint position(T) { return QPoint(); } +inline QPoint position(QPoint point) { return point; } +inline QPoint position(QPointF point) { return point.toPoint(); } +inline QPoint position(QRect rect) { return rect.center(); } +inline QPoint position(QRectF rect) { return rect.center().toPoint(); } + template T fromNativePixels(const T &value, const C *context) { - return scale(value, qreal(1) / QHighDpiScaling::factor(context), QHighDpiScaling::origin(context)); + QPoint nativePosition = position(value); + QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context, &nativePosition); + return scale(value, qreal(1) / so.factor, so.origin); } template T toNativePixels(const T &value, const C *context) { - return scale(value, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context)); + QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context); + return scale(value, so.factor, so.origin); } template From e3b3dbbe93dbbac196543f62b444b2c044d14907 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Wed, 22 May 2019 16:41:15 +0200 Subject: [PATCH 021/172] Example: Move the SQL statements Used const variables for the SQL statements, so that the code looks similar to its couterpart in Qt for Python. Change-Id: If2a505a404deff77d3d37c5ffad913c8c538d0b3 Reviewed-by: Christian Tismer Reviewed-by: Paul Wicking --- examples/sql/books/initdb.h | 38 +++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/examples/sql/books/initdb.h b/examples/sql/books/initdb.h index 44f74f0c375..773e3fb74cb 100644 --- a/examples/sql/books/initdb.h +++ b/examples/sql/books/initdb.h @@ -79,6 +79,32 @@ QVariant addAuthor(QSqlQuery &q, const QString &name, const QDate &birthdate) return q.lastInsertId(); } +const auto BOOKS_SQL = QLatin1String(R"( + create table books(id integer primary key, title varchar, author integer, + genre integer, year integer, rating integer) + )"); + +const auto AUTHORS_SQL = QLatin1String(R"( + create table authors(id integer primary key, name varchar, birthdate date) + )"); + +const auto GENRES_SQL = QLatin1String(R"( + create table genres(id integer primary key, name varchar) + )"); + +const auto INSERT_AUTHOR_SQL = QLatin1String(R"( + insert into authors(name, birthdate) values(?, ?) + )"); + +const auto INSERT_BOOK_SQL = QLatin1String(R"( + insert into books(title, year, author, genre, rating) + values(?, ?, ?, ?, ?) + )"); + +const auto INSERT_GENRE_SQL = QLatin1String(R"( + insert into genres(name) values(?) + )"); + QSqlError initDb() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); @@ -93,26 +119,26 @@ QSqlError initDb() return QSqlError(); QSqlQuery q; - if (!q.exec(QLatin1String("create table books(id integer primary key, title varchar, author integer, genre integer, year integer, rating integer)"))) + if (!q.exec(BOOKS_SQL)) return q.lastError(); - if (!q.exec(QLatin1String("create table authors(id integer primary key, name varchar, birthdate date)"))) + if (!q.exec(AUTHORS_SQL)) return q.lastError(); - if (!q.exec(QLatin1String("create table genres(id integer primary key, name varchar)"))) + if (!q.exec(GENRES_SQL)) return q.lastError(); - if (!q.prepare(QLatin1String("insert into authors(name, birthdate) values(?, ?)"))) + if (!q.prepare(INSERT_AUTHOR_SQL)) return q.lastError(); QVariant asimovId = addAuthor(q, QLatin1String("Isaac Asimov"), QDate(1920, 2, 1)); QVariant greeneId = addAuthor(q, QLatin1String("Graham Greene"), QDate(1904, 10, 2)); QVariant pratchettId = addAuthor(q, QLatin1String("Terry Pratchett"), QDate(1948, 4, 28)); - if (!q.prepare(QLatin1String("insert into genres(name) values(?)"))) + if (!q.prepare(INSERT_GENRE_SQL)) return q.lastError(); QVariant sfiction = addGenre(q, QLatin1String("Science Fiction")); QVariant fiction = addGenre(q, QLatin1String("Fiction")); QVariant fantasy = addGenre(q, QLatin1String("Fantasy")); - if (!q.prepare(QLatin1String("insert into books(title, year, author, genre, rating) values(?, ?, ?, ?, ?)"))) + if (!q.prepare(INSERT_BOOK_SQL)) return q.lastError(); addBook(q, QLatin1String("Foundation"), 1951, asimovId, sfiction, 3); addBook(q, QLatin1String("Foundation and Empire"), 1952, asimovId, sfiction, 4); From 3a806254fe265583f3871ed4629e13b23675ac86 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 24 Jun 2019 17:18:20 +0200 Subject: [PATCH 022/172] Fix 'clean' target for MinGW DLLs 'make clean' removed the import libs for DLLs which makes them quite unusable. Move the import lib removal to the 'distclean' target. Fixes: QTBUG-51977 Change-Id: I727d520435f88a83a7fb14cb0ad81f8fe7c6d61b Reviewed-by: Oliver Wolff --- qmake/generators/win32/mingw_make.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index de7363e51b6..746f3e9008c 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -254,7 +254,7 @@ void MingwMakefileGenerator::init() } if(project->isActiveConfig("dll")) { - project->values("QMAKE_CLEAN").append(project->first("MINGW_IMPORT_LIB")); + project->values("QMAKE_DISTCLEAN").append(project->first("MINGW_IMPORT_LIB")); } } From f6db25962e820d7709c2f235f02893dd3edde4f4 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 24 Jun 2019 17:36:41 +0200 Subject: [PATCH 023/172] Add QDebug streaming operator for ProString This saves us lots of .toQString() and .toQStringList() typing when qDebug()'ing qmake code. Change-Id: I037e5e1816f2dcb6a20dec4c275f3d886f155ad5 Reviewed-by: Oliver Wolff --- qmake/library/proitems.cpp | 5 +++++ qmake/library/proitems.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/qmake/library/proitems.cpp b/qmake/library/proitems.cpp index 8bbde9f8c0a..41bed69f00a 100644 --- a/qmake/library/proitems.cpp +++ b/qmake/library/proitems.cpp @@ -517,4 +517,9 @@ ProKey ProFile::getHashStr(const ushort *&tPtr) return ret; } +QDebug operator<<(QDebug debug, const ProString &str) +{ + return debug << str.toQString(); +} + QT_END_NAMESPACE diff --git a/qmake/library/proitems.h b/qmake/library/proitems.h index 71e5e053671..0e0bebddc7c 100644 --- a/qmake/library/proitems.h +++ b/qmake/library/proitems.h @@ -31,6 +31,7 @@ #include "qmake_global.h" +#include #include #include #include @@ -468,6 +469,8 @@ struct ProFunctionDefs { QHash replaceFunctions; }; +QDebug operator<<(QDebug debug, const ProString &str); + QT_END_NAMESPACE #endif // PROITEMS_H From 64033c35927efed044bac2eebd903304452abaa0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 21 Jun 2019 13:29:50 +0200 Subject: [PATCH 024/172] Output all font families in HTML output Fix our generation of font-family CSS so it contains the full list of families. Change-Id: I37d5efa64faeb4b6aeb7e2c5d6a54ff07febe9cc Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextdocument.cpp | 33 +++++++++++++++++-- src/gui/text/qtextdocument_p.h | 1 + .../text/qtextdocument/tst_qtextdocument.cpp | 12 +++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 4e5ba8e0386..2c677dffe03 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2299,7 +2299,11 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) if (mode == ExportEntireDocument) { html += QLatin1String(" style=\""); - emitFontFamily(defaultCharFormat.fontFamily()); + QStringList fontFamilies = defaultCharFormat.fontFamilies().toStringList(); + if (!fontFamilies.isEmpty()) + emitFontFamily(fontFamilies); + else + emitFontFamily(defaultCharFormat.fontFamily()); if (defaultCharFormat.hasProperty(QTextFormat::FontPointSize)) { html += QLatin1String(" font-size:"); @@ -2361,8 +2365,12 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) bool attributesEmitted = false; { + const QStringList families = format.fontFamilies().toStringList(); const QString family = format.fontFamily(); - if (!family.isEmpty() && family != defaultCharFormat.fontFamily()) { + if (!families.isEmpty() && families != defaultCharFormat.fontFamilies().toStringList()) { + emitFontFamily(families); + attributesEmitted = true; + } else if (!family.isEmpty() && family != defaultCharFormat.fontFamily()) { emitFontFamily(family); attributesEmitted = true; } @@ -2639,6 +2647,27 @@ void QTextHtmlExporter::emitFontFamily(const QString &family) html += QLatin1Char(';'); } +void QTextHtmlExporter::emitFontFamily(const QStringList &families) +{ + html += QLatin1String(" font-family:"); + + bool first = true; + for (const QString &family : families) { + QLatin1String quote("\'"); + if (family.contains(QLatin1Char('\''))) + quote = QLatin1String("""); + + if (!first) + html += QLatin1String(","); + else + first = false; + html += quote; + html += family.toHtmlEscaped(); + html += quote; + } + html += QLatin1Char(';'); +} + void QTextHtmlExporter::emitMargins(const QString &top, const QString &bottom, const QString &left, const QString &right) { html += QLatin1String(" margin-top:"); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index cad9131fbf3..d6680660914 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -396,6 +396,7 @@ private: void emitPageBreakPolicy(QTextFormat::PageBreakFlags policy); void emitFontFamily(const QString &family); + void emitFontFamily(const QStringList &families); void emitBackgroundAttribute(const QTextFormat &format); QString findUrlForImage(const QTextDocument *doc, qint64 cacheKey, bool isPixmap); diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index a07181c1990..e4ee778f64f 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -861,6 +861,18 @@ void tst_QTextDocument::toHtml_data() << QString("

Blah

"); } + { + CREATE_DOC_AND_CURSOR(); + + QTextCharFormat fmt; + fmt.setFontFamily("Times"); + fmt.setFontFamilies(QStringList{ "Times", "serif" }); + cursor.insertText("Blah", fmt); + + QTest::newRow("font-family-with-fallback") << QTextDocumentFragment(&doc) + << QString("

Blah

"); + } + { CREATE_DOC_AND_CURSOR(); From 7f69c13fd9c629acde796b8486e1d32f016678d2 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 19 Jun 2019 16:50:48 +0200 Subject: [PATCH 025/172] Skip tests if the required plugins were not deployed This is usually the case on Android, where running this test would require deployment of files to the emulator. This doesn't give us any further testing that we don't already do by running this test on regular Linux, so skipping the test instead if the preconditions aren't met. Change-Id: I3722796634871213ba51c89ae7f40b19f954f2cb Fixes: QTBUG-73566 Reviewed-by: Daniel Smith Reviewed-by: Volker Hilsheimer --- .../corelib/plugin/qplugin/tst_qplugin.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp index a290c012df6..aa85a7c35ba 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp @@ -41,7 +41,6 @@ class tst_QPlugin : public QObject Q_OBJECT QDir dir; - QString invalidPluginName; public: tst_QPlugin(); @@ -64,15 +63,14 @@ void tst_QPlugin::initTestCase() QVERIFY2(dir.exists(), qPrintable(QString::fromLatin1("Cannot find the 'plugins' directory starting from '%1'"). arg(QDir::toNativeSeparators(QDir::currentPath())))); - - const auto fileNames = dir.entryList({"*invalid*"}, QDir::Files); - if (!fileNames.isEmpty()) - invalidPluginName = dir.absoluteFilePath(fileNames.first()); } void tst_QPlugin::loadDebugPlugin() { const auto fileNames = dir.entryList(QStringList() << "*debug*", QDir::Files); + if (fileNames.isEmpty()) + QSKIP("No debug plugins found - skipping test"); + for (const QString &fileName : fileNames) { if (!QLibrary::isLibrary(fileName)) continue; @@ -100,6 +98,9 @@ void tst_QPlugin::loadDebugPlugin() void tst_QPlugin::loadReleasePlugin() { const auto fileNames = dir.entryList(QStringList() << "*release*", QDir::Files); + if (fileNames.isEmpty()) + QSKIP("No release plugins found - skipping test"); + for (const QString &fileName : fileNames) { if (!QLibrary::isLibrary(fileName)) continue; @@ -227,7 +228,13 @@ static qsizetype locateMetadata(const uchar *data, qsizetype len) void tst_QPlugin::scanInvalidPlugin() { - QVERIFY(!invalidPluginName.isEmpty()); + const auto fileNames = dir.entryList({"*invalid*"}, QDir::Files); + QString invalidPluginName; + if (fileNames.isEmpty()) + QSKIP("No invalid plugin found - skipping test"); + else + invalidPluginName = dir.absoluteFilePath(fileNames.first()); + // copy the file QFileInfo fn(invalidPluginName); From 084e17c4e113f72dc43180bae2cb4e8c68b2a0f6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 19 Jun 2019 13:42:01 +0200 Subject: [PATCH 026/172] Avoid undefined behavior in qjsonwriter.cpp See comment in qnumeric_p.h:convertDoubleTo for details. Change-Id: Ifcd13f7f67995af6a60e50ccabe843a855be04ae Reviewed-by: Thiago Macieira --- src/corelib/serialization/qjsonwriter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/serialization/qjsonwriter.cpp b/src/corelib/serialization/qjsonwriter.cpp index 12ce20ef09a..32feb41183a 100644 --- a/src/corelib/serialization/qjsonwriter.cpp +++ b/src/corelib/serialization/qjsonwriter.cpp @@ -43,6 +43,7 @@ #include "qjsonwriter_p.h" #include "qjson_p.h" #include "private/qutfcodec_p.h" +#include QT_BEGIN_NAMESPACE @@ -131,8 +132,9 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value & case QJsonValue::Double: { const double d = v.toDouble(b); if (qIsFinite(d)) { // +2 to format to ensure the expected precision - const double abs = std::abs(d); - json += QByteArray::number(d, abs == static_cast(abs) ? 'f' : 'g', QLocale::FloatingPointShortest); + quint64 absInt; + json += QByteArray::number(d, convertDoubleTo(std::abs(d), &absInt) ? 'f' : 'g', + QLocale::FloatingPointShortest); } else { json += "null"; // +INF || -INF || NaN (see RFC4627#section2.4) } From 53da86fe8c2a39bebe665231480cad3cc08b6cb3 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 16 Apr 2019 09:58:23 +0200 Subject: [PATCH 027/172] Add a QVkConvenience class with vkFormatFromGlFormat Converts from OpenGL formats to Vulkan formats. There are commented out lines for the formats in QOpenGLTexture::TextureFormat for which it was hard to find an unambiguous mapping to vkFormat. Task-number: QTBUG-75108 Change-Id: I06a7fd8df7d98cef314410ffd79ca9cff6599357 Reviewed-by: Laszlo Agocs (cherry picked from commit b21b07877a96c175ee51e83e1b41425c2e67beb3) Reviewed-by: Lars Knoll Reviewed-by: Johan Helsing --- .../vkconvenience/qvkconvenience.cpp | 215 ++++++++++++++++++ .../vkconvenience/qvkconvenience_p.h | 67 ++++++ .../vkconvenience/vkconvenience.pro | 2 + 3 files changed, 284 insertions(+) create mode 100644 src/platformsupport/vkconvenience/qvkconvenience.cpp create mode 100644 src/platformsupport/vkconvenience/qvkconvenience_p.h diff --git a/src/platformsupport/vkconvenience/qvkconvenience.cpp b/src/platformsupport/vkconvenience/qvkconvenience.cpp new file mode 100644 index 00000000000..462cdc9e0d6 --- /dev/null +++ b/src/platformsupport/vkconvenience/qvkconvenience.cpp @@ -0,0 +1,215 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qvkconvenience_p.h" + +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QVkConvenience + \brief A collection of static helper functions for Vulkan support + \since 5.14 + \internal + \ingroup qpa + */ + +VkFormat QVkConvenience::vkFormatFromGlFormat(uint glFormat) +{ + using GlFormat = QOpenGLTexture::TextureFormat; + switch (glFormat) { + case GlFormat::NoFormat: return VK_FORMAT_UNDEFINED; // GL_NONE + + // Unsigned normalized formats + case GlFormat::R8_UNorm: return VK_FORMAT_R8_UNORM; // GL_R8 + case GlFormat::RG8_UNorm: return VK_FORMAT_R8G8_UNORM; // GL_RG8 + case GlFormat::RGB8_UNorm: return VK_FORMAT_R8G8B8_UNORM; // GL_RGB8 + case GlFormat::RGBA8_UNorm: return VK_FORMAT_R8G8B8A8_UNORM; // GL_RGBA8 + + case GlFormat::R16_UNorm: return VK_FORMAT_R16_UNORM; // GL_R16 + case GlFormat::RG16_UNorm: return VK_FORMAT_R16G16_UNORM; // GL_RG16 + case GlFormat::RGB16_UNorm: return VK_FORMAT_R16G16B16_UNORM; // GL_RGB16 + case GlFormat::RGBA16_UNorm: return VK_FORMAT_R16G16B16A16_UNORM; // GL_RGBA16 + + // Signed normalized formats + case GlFormat::R8_SNorm: return VK_FORMAT_R8_SNORM; // GL_R8_SNORM + case GlFormat::RG8_SNorm: return VK_FORMAT_R8G8_SNORM; // GL_RG8_SNORM + case GlFormat::RGB8_SNorm: return VK_FORMAT_R8G8B8_SNORM; // GL_RGB8_SNORM + case GlFormat::RGBA8_SNorm: return VK_FORMAT_R8G8B8A8_SNORM; // GL_RGBA8_SNORM + + case GlFormat::R16_SNorm: return VK_FORMAT_R16_SNORM; // GL_R16_SNORM + case GlFormat::RG16_SNorm: return VK_FORMAT_R16G16_SNORM; // GL_RG16_SNORM + case GlFormat::RGB16_SNorm: return VK_FORMAT_R16G16B16_SNORM; // GL_RGB16_SNORM + case GlFormat::RGBA16_SNorm: return VK_FORMAT_R16G16B16A16_SNORM; // GL_RGBA16_SNORM + + // Unsigned integer formats + case GlFormat::R8U: return VK_FORMAT_R8_UINT; // GL_R8UI + case GlFormat::RG8U: return VK_FORMAT_R8G8_UINT; // GL_RG8UI + case GlFormat::RGB8U: return VK_FORMAT_R8G8B8_UINT; // GL_RGB8UI + case GlFormat::RGBA8U: return VK_FORMAT_R8G8B8A8_UINT; // GL_RGBA8UI + + case GlFormat::R16U: return VK_FORMAT_R16_UINT; // GL_R16UI + case GlFormat::RG16U: return VK_FORMAT_R16G16_UINT; // GL_RG16UI + case GlFormat::RGB16U: return VK_FORMAT_R16G16B16_UINT; // GL_RGB16UI + case GlFormat::RGBA16U: return VK_FORMAT_R16G16B16A16_UINT; // GL_RGBA16UI + + case GlFormat::R32U: return VK_FORMAT_R32_UINT; // GL_R32UI + case GlFormat::RG32U: return VK_FORMAT_R32G32_UINT; // GL_RG32UI + case GlFormat::RGB32U: return VK_FORMAT_R32G32B32_UINT; // GL_RGB32UI + case GlFormat::RGBA32U: return VK_FORMAT_R32G32B32A32_UINT; // GL_RGBA32UI + + // Signed integer formats + case GlFormat::R8I: return VK_FORMAT_R8_SINT; // GL_R8I + case GlFormat::RG8I: return VK_FORMAT_R8G8_SINT; // GL_RG8I + case GlFormat::RGB8I: return VK_FORMAT_R8G8B8_SINT; // GL_RGB8I + case GlFormat::RGBA8I: return VK_FORMAT_R8G8B8A8_SINT; // GL_RGBA8I + + case GlFormat::R16I: return VK_FORMAT_R16_SINT; // GL_R16I + case GlFormat::RG16I: return VK_FORMAT_R16G16_SINT; // GL_RG16I + case GlFormat::RGB16I: return VK_FORMAT_R16G16B16_SINT; // GL_RGB16I + case GlFormat::RGBA16I: return VK_FORMAT_R16G16B16A16_SINT; // GL_RGBA16I + + case GlFormat::R32I: return VK_FORMAT_R32_SINT; // GL_R32I + case GlFormat::RG32I: return VK_FORMAT_R32G32_SINT; // GL_RG32I + case GlFormat::RGB32I: return VK_FORMAT_R32G32B32_SINT; // GL_RGB32I + case GlFormat::RGBA32I: return VK_FORMAT_R32G32B32A32_SINT; // GL_RGBA32I + + // Floating point formats + case GlFormat::R16F: return VK_FORMAT_R16_SFLOAT; // GL_R16F + case GlFormat::RG16F: return VK_FORMAT_R16G16_SFLOAT; // GL_RG16F + case GlFormat::RGB16F: return VK_FORMAT_R16G16B16_SFLOAT; // GL_RGB16F + case GlFormat::RGBA16F: return VK_FORMAT_R16G16B16A16_SFLOAT; // GL_RGBA16F + + case GlFormat::R32F: return VK_FORMAT_R32_SFLOAT; // GL_R32F + case GlFormat::RG32F: return VK_FORMAT_R32G32_SFLOAT; // GL_RG32F + case GlFormat::RGB32F: return VK_FORMAT_R32G32B32_SFLOAT; // GL_RGB32F + case GlFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; // GL_RGBA32F + + // Packed formats + case GlFormat::RGB9E5: return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; // GL_RGB9_E5 + case GlFormat::RG11B10F: return VK_FORMAT_B10G11R11_UFLOAT_PACK32; // GL_R11F_G11F_B10F +// case GlFormat::RG3B2: return VK_FORMAT_R3_G3_B2; // GL_R3_G3_B2 + case GlFormat::R5G6B5: return VK_FORMAT_R5G6B5_UNORM_PACK16; // GL_RGB565 + case GlFormat::RGB5A1: return VK_FORMAT_R5G5B5A1_UNORM_PACK16; // GL_RGB5_A1 + case GlFormat::RGBA4: return VK_FORMAT_R4G4B4A4_UNORM_PACK16; // GL_RGBA4 + case GlFormat::RGB10A2: return VK_FORMAT_A2R10G10B10_UINT_PACK32; // GL_RGB10_A2UI + + // Depth formats +// case Format::D16: return VK_FORMAT_DEPTH_COMPONENT16; // GL_DEPTH_COMPONENT16 +// case Format::D24: return VK_FORMAT_DEPTH_COMPONENT24; // GL_DEPTH_COMPONENT24 +// case Format::D24S8: return VK_FORMAT_DEPTH24_STENCIL8; // GL_DEPTH24_STENCIL8 +// case Format::D32: return VK_FORMAT_DEPTH_COMPONENT32; // GL_DEPTH_COMPONENT32 +// case Format::D32F: return VK_FORMAT_DEPTH_COMPONENT32F; // GL_DEPTH_COMPONENT32F +// case Format::D32FS8X24: return VK_FORMAT_DEPTH32F_STENCIL8; // GL_DEPTH32F_STENCIL8 +// case Format::S8: return VK_FORMAT_STENCIL_INDEX8; // GL_STENCIL_INDEX8 + + // Compressed formats + case GlFormat::RGB_DXT1: return VK_FORMAT_BC1_RGB_UNORM_BLOCK; // GL_COMPRESSED_RGB_S3TC_DXT1_EXT + case GlFormat::RGBA_DXT1: return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT + case GlFormat::RGBA_DXT3: return VK_FORMAT_BC2_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT + case GlFormat::RGBA_DXT5: return VK_FORMAT_BC3_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT + case GlFormat::R_ATI1N_UNorm: return VK_FORMAT_BC4_UNORM_BLOCK; // GL_COMPRESSED_RED_RGTC1 + case GlFormat::R_ATI1N_SNorm: return VK_FORMAT_BC4_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RED_RGTC1 + case GlFormat::RG_ATI2N_UNorm: return VK_FORMAT_BC5_UNORM_BLOCK; // GL_COMPRESSED_RG_RGTC2 + case GlFormat::RG_ATI2N_SNorm: return VK_FORMAT_BC5_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG_RGTC2 + case GlFormat::RGB_BP_UNSIGNED_FLOAT: return VK_FORMAT_BC6H_UFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB + case GlFormat::RGB_BP_SIGNED_FLOAT: return VK_FORMAT_BC6H_SFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB + case GlFormat::RGB_BP_UNorm: return VK_FORMAT_BC7_UNORM_BLOCK; // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB + case GlFormat::R11_EAC_UNorm: return VK_FORMAT_EAC_R11_UNORM_BLOCK; // GL_COMPRESSED_R11_EAC + case GlFormat::R11_EAC_SNorm: return VK_FORMAT_EAC_R11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_R11_EAC + case GlFormat::RG11_EAC_UNorm: return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; // GL_COMPRESSED_RG11_EAC + case GlFormat::RG11_EAC_SNorm: return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG11_EAC + case GlFormat::RGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // GL_COMPRESSED_RGB8_ETC2 + case GlFormat::SRGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ETC2 + case GlFormat::RGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 + case GlFormat::SRGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 + case GlFormat::RGBA8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; // GL_COMPRESSED_RGBA8_ETC2_EAC + case GlFormat::SRGB8_Alpha8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC +// case GlFormat::RGB8_ETC1: return VK_FORMAT_ETC1_RGB8_OES; // GL_ETC1_RGB8_OES + case GlFormat::RGBA_ASTC_4x4: return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_4x4_KHR + case GlFormat::RGBA_ASTC_5x4: return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x4_KHR + case GlFormat::RGBA_ASTC_5x5: return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x5_KHR + case GlFormat::RGBA_ASTC_6x5: return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x5_KHR + case GlFormat::RGBA_ASTC_6x6: return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x6_KHR + case GlFormat::RGBA_ASTC_8x5: return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x5_KHR + case GlFormat::RGBA_ASTC_8x6: return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x6_KHR + case GlFormat::RGBA_ASTC_8x8: return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x8_KHR + case GlFormat::RGBA_ASTC_10x5: return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x5_KHR + case GlFormat::RGBA_ASTC_10x6: return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x6_KHR + case GlFormat::RGBA_ASTC_10x8: return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x8_KHR + case GlFormat::RGBA_ASTC_10x10: return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x10_KHR + case GlFormat::RGBA_ASTC_12x10: return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x10_KHR + case GlFormat::RGBA_ASTC_12x12: return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x12_KHR + case GlFormat::SRGB8_Alpha8_ASTC_4x4: return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR + case GlFormat::SRGB8_Alpha8_ASTC_5x4: return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR + case GlFormat::SRGB8_Alpha8_ASTC_5x5: return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_6x5: return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_6x6: return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x5: return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x6: return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_8x8: return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x5: return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x6: return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x8: return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR + case GlFormat::SRGB8_Alpha8_ASTC_10x10: return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR + case GlFormat::SRGB8_Alpha8_ASTC_12x10: return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR + case GlFormat::SRGB8_Alpha8_ASTC_12x12: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR + + // sRGB formats + case GlFormat::SRGB8: return VK_FORMAT_R8G8B8_SRGB; // GL_SRGB8 + case GlFormat::SRGB8_Alpha8: return VK_FORMAT_R8G8B8A8_SRGB; // GL_SRGB8_ALPHA8 + case GlFormat::SRGB_DXT1: return VK_FORMAT_BC1_RGB_SRGB_BLOCK; // GL_COMPRESSED_SRGB_S3TC_DXT1_EXT + case GlFormat::SRGB_Alpha_DXT1: return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT + case GlFormat::SRGB_Alpha_DXT3: return VK_FORMAT_BC2_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT + case GlFormat::SRGB_Alpha_DXT5: return VK_FORMAT_BC3_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT + case GlFormat::SRGB_BP_UNorm: return VK_FORMAT_BC7_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB + + // ES 2 formats +// case GlFormat::DepthFormat: return VK_FORMAT_DEPTH_COMPONENT; // GL_DEPTH_COMPONENT +// case GlFormat::AlphaFormat: return VK_FORMAT_ALPHA; // GL_ALPHA +// case GlFormat::RGBFormat: return VK_FORMAT_RGB; // GL_RGB +// case GlFormat::RGBAFormat: return VK_FORMAT_RGBA; // GL_RGBA +// case GlFormat::LuminanceFormat: return VK_FORMAT_LUMINANCE; // GL_LUMINANCE +// case GlFormat::LuminanceAlphaFormat: return VK_FORMAT; + default: return VK_FORMAT_UNDEFINED; + } +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/vkconvenience/qvkconvenience_p.h b/src/platformsupport/vkconvenience/qvkconvenience_p.h new file mode 100644 index 00000000000..1dd1dfc4a73 --- /dev/null +++ b/src/platformsupport/vkconvenience/qvkconvenience_p.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QVKCONVENIENCE_P_H +#define QVKCONVENIENCE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QVkConvenience +{ +public: + static VkFormat vkFormatFromGlFormat(uint glFormat); +}; + +QT_END_NAMESPACE + +#endif // QVKCONVENIENCE_P_H diff --git a/src/platformsupport/vkconvenience/vkconvenience.pro b/src/platformsupport/vkconvenience/vkconvenience.pro index 7a4cdb041dd..ee540024cff 100644 --- a/src/platformsupport/vkconvenience/vkconvenience.pro +++ b/src/platformsupport/vkconvenience/vkconvenience.pro @@ -8,9 +8,11 @@ DEFINES += QT_NO_CAST_FROM_ASCII PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h SOURCES += \ + qvkconvenience.cpp \ qbasicvulkanplatforminstance.cpp HEADERS += \ + qvkconvenience_p.h \ qbasicvulkanplatforminstance_p.h load(qt_module) From c450e8bd208972d36f707269cac42bcd3ee4e105 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 25 Jun 2019 09:17:07 +0200 Subject: [PATCH 028/172] Fix .la/.pc replacements if libdir is in QMAKE_DEFAULT_LIBDIRS We must use the same two-level replacements like for .prl files. This amends commit d5071a40. Change-Id: Iea065d01dee61cf2d1ff78640d045c3c76db9ac8 Fixes: QTBUG-76625 Reviewed-by: Kai Koehne --- mkspecs/features/qt_module.prf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index 18060cd490c..ee7de22059a 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -289,6 +289,12 @@ load(qt_targets) QMAKE_PKGCONFIG_REQUIRES += $$replace(QT.$${i}.name, ^Qt, Qt$$section(QT.$${i}.VERSION, ., 0, 0)) isEmpty(QMAKE_PKGCONFIG_DESCRIPTION): \ QMAKE_PKGCONFIG_DESCRIPTION = $$replace(TARGET, ^Qt, "Qt ") module + !isEmpty(lib_replace0.match) { + pclib_replace0.match = $$lib_replace0.match + pclib_replace0.replace = $$QMAKE_PKGCONFIG_LIBDIR/ + pclib_replace0.CONFIG = path + QMAKE_PKGCONFIG_INSTALL_REPLACE += pclib_replace0 + } pclib_replace.match = $$lib_replace.match !isEmpty(lib_replace.replace): \ pclib_replace.replace = $$QMAKE_PKGCONFIG_LIBDIR @@ -301,6 +307,12 @@ load(qt_targets) QMAKE_LIBTOOL_LIBDIR = $$[QT_HOST_LIBS] else: \ QMAKE_LIBTOOL_LIBDIR = "=$$[QT_INSTALL_LIBS/raw]" + !isEmpty(lib_replace0.match) { + ltlib_replace0.match = $$lib_replace0.match + ltlib_replace0.replace = $$QMAKE_LIBTOOL_LIBDIR/ + ltlib_replace0.CONFIG = path + QMAKE_LIBTOOL_INSTALL_REPLACE += ltlib_replace0 + } ltlib_replace.match = $$lib_replace.match !isEmpty(lib_replace.replace): \ ltlib_replace.replace = $$QMAKE_LIBTOOL_LIBDIR From 18a6c5ebe24afb35aa3193b79c3ab6ba32ea8eab Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 25 Jun 2019 09:40:55 +0200 Subject: [PATCH 029/172] Fix QMAKE_LIBDIR_BCM_HOST for linux-rasp-pi3-g++ The directory must be prepended by = to denote the sysroot. This amends commit 797f686e. Change-Id: Ib85c0abc58fce3504ecccef0e223b2618ac9149a Reviewed-by: Oliver Wolff --- mkspecs/devices/linux-rasp-pi3-g++/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf b/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf index b215833486d..d2e1a3a0ada 100644 --- a/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf +++ b/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf @@ -31,7 +31,7 @@ QMAKE_LIBS_OPENGL_ES2 = $${VC_LINK_LINE} -lGLESv2 # The official opt vc EGL references GLESv2 symbols: need to link it QMAKE_LIBS_EGL = $${VC_LINK_LINE} -lEGL -lGLESv2 -QMAKE_LIBDIR_BCM_HOST = $$VC_LIBRARY_PATH +QMAKE_LIBDIR_BCM_HOST = =$$VC_LIBRARY_PATH QMAKE_INCDIR_BCM_HOST = $$VC_INCLUDE_PATH QMAKE_LIBS_BCM_HOST = -lbcm_host From f6ed6037596783ef1562f586eff69186610ba620 Mon Sep 17 00:00:00 2001 From: Val Doroshchuk Date: Fri, 21 Jun 2019 11:24:06 +0200 Subject: [PATCH 030/172] ANGLE: Invalidate client window area when resizing swap chain Inspired by: https://codereview.appspot.com/6812076/ Resizing a window larger results in the newly exposed region being invalidated but the old region is treated as valid. This can result in the old region no longer updating. Was added to D3D9. Improving a fix from Filippo Cucchetto: https://codereview.qt-project.org/c/qt/qtbase/+/195336 and pushing to D3D11. ifndef protects against compilation error for WinRT. Invalidate() should be used only for desktop apps. Task-number: QTBUG-46074 Change-Id: Ie24b8dffe130b970f2362337ac4f9bee666f82b2 Reviewed-by: Oliver Wolff --- .../renderer/d3d/d3d11/SwapChain11.cpp | 4 ++ ...-client-window-area-when-resizing-sw.patch | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp index dcfd06484d3..e8f13b388fc 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp +++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp @@ -504,6 +504,10 @@ EGLint SwapChain11::resize(const gl::Context *context, ASSERT(SUCCEEDED(result)); if (SUCCEEDED(result)) { +#ifndef ANGLE_ENABLE_WINDOWS_STORE + if (mNativeWindow->getNativeWindow()) + InvalidateRect(mNativeWindow->getNativeWindow(), nullptr, FALSE); +#endif const auto &format = d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps()); mBackBufferTexture.set(backbufferTexture, format); diff --git a/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch b/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch new file mode 100644 index 00000000000..9380437761f --- /dev/null +++ b/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch @@ -0,0 +1,37 @@ +From 7d300c6e7d05f4e31c966f1298d11da3eae9d679 Mon Sep 17 00:00:00 2001 +From: Val Doroshchuk +Date: Fri, 21 Jun 2019 11:24:06 +0200 +Subject: [PATCH] ANGLE: Invalidate client window area when resizing swap chain + +Inspired by: +https://codereview.appspot.com/6812076/ +Resizing a window larger results in the newly exposed region being invalidated +but the old region is treated as valid. +This can result in the old region no longer updating. +Was added to D3D9. + +Improving a fix from Filippo Cucchetto: +https://codereview.qt-project.org/c/qt/qtbase/+/195336 +and pushing to D3D11. + +ifndef protects against compilation error for WinRT. +Invalidate() should be used only for desktop apps. + +diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp +index dcfd06484d..e8f13b388f 100644 +--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp ++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp +@@ -504,6 +504,10 @@ EGLint SwapChain11::resize(const gl::Context *context, + ASSERT(SUCCEEDED(result)); + if (SUCCEEDED(result)) + { ++#ifndef ANGLE_ENABLE_WINDOWS_STORE ++ if (mNativeWindow->getNativeWindow()) ++ InvalidateRect(mNativeWindow->getNativeWindow(), nullptr, FALSE); ++#endif + const auto &format = + d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps()); + mBackBufferTexture.set(backbufferTexture, format); +-- +2.14.2.windows.1 + From 44d9e9b096738a79b6bceffcdad20da42f2e3713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 25 Jun 2019 18:31:58 +0200 Subject: [PATCH 031/172] Fix crash when setting QGuiApplication palette before app is available Change-Id: Ia154f66a27cba970d179f100e66aa2daab01c9fa Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qguiapplication.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a67214bd9ae..5014878bd2b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3233,9 +3233,12 @@ void QGuiApplication::setPalette(const QPalette &pal) QGuiApplicationPrivate::app_pal = new QPalette(pal); else *QGuiApplicationPrivate::app_pal = pal; + applicationResourceFlags |= ApplicationPaletteExplicitlySet; QCoreApplication::setAttribute(Qt::AA_SetPalette); - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + + if (qGuiApp) + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); } void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) From e21169796297f752a62db25c722ff8e2ff66d8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 21 Jun 2019 09:29:22 +0200 Subject: [PATCH 032/172] QHttpNetworkConnectionChannel: don't close if we're already closing In some scenarios with QNAM we call socket->close, leading to a flush, leading to an error, leading to another error emission... To work around this scenario we stop trying to close the socket if the network channel is already closing. Change-Id: Id15504f476484ce61f11ba83a5755ceb5f581f9b Fixes: QTBUG-76567 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index d5f63af745d..074c3896895 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -207,6 +207,9 @@ void QHttpNetworkConnectionChannel::init() void QHttpNetworkConnectionChannel::close() { + if (state == QHttpNetworkConnectionChannel::ClosingState) + return; + if (!socket) state = QHttpNetworkConnectionChannel::IdleState; else if (socket->state() == QAbstractSocket::UnconnectedState) From 0d6b4b519272915c2690ee12d1834823747233ab Mon Sep 17 00:00:00 2001 From: Heikki Halmet Date: Mon, 17 Jun 2019 12:26:54 +0300 Subject: [PATCH 033/172] Add keyword msvc-2019 to testlib blacklisting Change-Id: Ibb1d225909e6c0c8b35f3b41aeb619784012d43b Reviewed-by: Frederik Gladhorn --- src/testlib/qtestblacklist.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp index 886f1f75b97..66426997588 100644 --- a/src/testlib/qtestblacklist.cpp +++ b/src/testlib/qtestblacklist.cpp @@ -150,8 +150,10 @@ static QSet keywords() << "msvc-2013" # elif _MSC_VER <= 1900 << "msvc-2015" -# else +# elif _MSC_VER <= 1916 << "msvc-2017" +# else + << "msvc-2019" # endif #endif From 89655525ae56dd9662f1873efdce72cbff7bb932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 21 Jun 2019 09:20:39 +0200 Subject: [PATCH 034/172] QHttpNetworkConnection: Change assert to early return and handle Http2 When using a http proxy (and presumably other proxies) we might have failed/aborted (aka "finished") the request and _then_ receive a "proxy authentication required" message from the proxy. In this case there is no spdy/http2 reply in the queue, so asserting is wrong. Change-Id: Id9b76b580299f6a6cd6efad62d6aaf63183816fb Fixes: QTBUG-76426 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnection.cpp | 12 +++++++----- src/network/access/qhttpnetworkconnectionchannel.cpp | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index c58fd24a443..10c8541c5f5 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -1528,19 +1528,21 @@ void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpN // dialog is displaying pauseConnection(); QHttpNetworkReply *reply; -#ifndef QT_NO_SSL - if (connectionType == QHttpNetworkConnection::ConnectionTypeSPDY) { + if (connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2 + || connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2Direct +#if QT_CONFIG(ssl) + || connectionType == QHttpNetworkConnection::ConnectionTypeSPDY +#endif + ) { + // we choose the reply to emit the proxyAuth signal from somewhat arbitrarily, // but that does not matter because the signal will ultimately be emitted // by the QNetworkAccessManager. Q_ASSERT(chan->spdyRequestsToSend.count() > 0); reply = chan->spdyRequestsToSend.cbegin().value().second; } else { // HTTP -#endif // QT_NO_SSL reply = chan->reply; -#ifndef QT_NO_SSL } -#endif // QT_NO_SSL Q_ASSERT(reply); emit reply->proxyAuthenticationRequired(proxy, auth); diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 074c3896895..38adca26330 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1115,11 +1115,13 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth) { if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2 + || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct #ifndef QT_NO_SSL || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY #endif ) { - connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth); + if (spdyRequestsToSend.count() > 0) + connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth); } else { // HTTP // Need to dequeue the request before we can emit the error. if (!reply) From ee8dfcaf675958ff7a687b0dc8364716cdb174bf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 26 Jun 2019 11:18:26 +0200 Subject: [PATCH 035/172] tst_QThread: Blacklist sleep() for Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-76707 Change-Id: Iddce10fb3c8259b829d76596ffc9829f8d013bf3 Reviewed-by: Mårten Nordheim --- tests/auto/corelib/thread/qthread/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/corelib/thread/qthread/BLACKLIST b/tests/auto/corelib/thread/qthread/BLACKLIST index d75249454f8..ccf530362cb 100644 --- a/tests/auto/corelib/thread/qthread/BLACKLIST +++ b/tests/auto/corelib/thread/qthread/BLACKLIST @@ -1,2 +1,4 @@ [wait3_slowDestructor] windows +[sleep] +windows ci From 5859f7d0d9440f82086486639a707f3935696cf4 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 26 Jun 2019 10:35:53 +0000 Subject: [PATCH 036/172] Revert "Deprecate QAtomic::load() / store()" This reverts commit 79bdc7cf1daec75df59de9236599a9f24077511a. We haven't ported every usages to loadRelaxed() / storeRelaxed() yet. And warning as error is enabled in dev. We will revert this change when new qt5 baseline got integrated. Task-number: QTBUG-76611 Change-Id: I5b1f608fefbaca481311f376f22718f2c5047106 Reviewed-by: Friedemann Kleint Reviewed-by: Frederik Gladhorn --- src/corelib/thread/qbasicatomic.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 9804e601192..dc976819ef1 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -99,10 +99,8 @@ public: typename Ops::Type _q_value; // Everything below is either implemented in ../arch/qatomic_XXX.h or (as fallback) in qgenericatomic.h -#if QT_DEPRECATED_SINCE(5, 14) - QT_DEPRECATED_VERSION_X_5_14("Use loadRelaxed") T load() const noexcept { return loadRelaxed(); } - QT_DEPRECATED_VERSION_X_5_14("Use storeRelaxed") void store(T newValue) noexcept { storeRelaxed(newValue); } -#endif + T load() const noexcept { return loadRelaxed(); } + void store(T newValue) noexcept { storeRelaxed(newValue); } T loadRelaxed() const noexcept { return Ops::loadRelaxed(_q_value); } void storeRelaxed(T newValue) noexcept { Ops::storeRelaxed(_q_value, newValue); } @@ -240,10 +238,8 @@ public: AtomicType _q_value; -#if QT_DEPRECATED_SINCE(5, 14) - QT_DEPRECATED_VERSION_X_5_14("Use loadRelaxed") Type load() const noexcept { return loadRelaxed(); } - QT_DEPRECATED_VERSION_X_5_14("Use storeRelaxed") void store(Type newValue) noexcept { storeRelaxed(newValue); } -#endif + Type load() const noexcept { return loadRelaxed(); } + void store(Type newValue) noexcept { storeRelaxed(newValue); } Type loadRelaxed() const noexcept { return Ops::loadRelaxed(_q_value); } void storeRelaxed(Type newValue) noexcept { Ops::storeRelaxed(_q_value, newValue); } From cc13b99781b0bbf5f9d09b2c5b081a085762cd0c Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 24 Jun 2019 17:43:16 +0200 Subject: [PATCH 037/172] Do not downscale png when the size is exactly right Don't go through the doScaledRead path (i.e. calling read_image_scaled) when reading an image that the target size is the image of the file we are opening. This makes the loading of the file much faster while keeping the output correct. [ChangeLog][QtGui][QImage] Improve loading time when loading png files that have the same size as the target. Change-Id: I2a33c49fe1ce52ec296c2175ee542b5bcdec2c4b Reviewed-by: Eirik Aavitsland --- src/gui/image/qpnghandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 801b30881dc..e7e998efd1b 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -394,7 +394,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal } QSize outSize(width,height); if (!scaledSize.isEmpty() && quint32(scaledSize.width()) <= width && - quint32(scaledSize.height()) <= height && interlace_method == PNG_INTERLACE_NONE) { + quint32(scaledSize.height()) <= height && scaledSize != outSize && interlace_method == PNG_INTERLACE_NONE) { // Do inline downscaling outSize = scaledSize; if (doScaledRead) From 2a756e294e2efa4bcb2b51afd1c20822df251f29 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 24 Jun 2019 22:42:28 +0200 Subject: [PATCH 038/172] macOS: lower the splash screen when a modal dialog blocks it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the usability issue of a modal dialog showing up behind a splash screen, not visible to the user, but blocking user input and the application startup sequence until discarded. [ChangeLog][QtWidgets][QSlashScreen] On macOS, lower the splash screen when a modal dialog is shown to make sure the user sees the dialog. Change-Id: Ibae768f76909d930cb25dcf5cee31edc5f15c29a Fixes: QTBUG-49576 Reviewed-by: Tor Arne Vestbø --- .../platforms/cocoa/qcocoaintegration.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 232c74b1e98..b5d63f8331a 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -217,6 +217,25 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &QCocoaIntegration::focusWindowChanged); + + static auto splashScreenHider = QMacKeyValueObserver(NSApp, @"modalWindow", []{ + const QWindowList allWindows = QGuiApplication::topLevelWindows(); + for (QWindow *window : allWindows) { + if ((window->flags() & Qt::SplashScreen) == Qt::SplashScreen) { + QCocoaWindow *platformWindow = static_cast(window->handle()); + NSWindow *splashWindow = platformWindow->view().window; + if (!splashWindow) + continue; + if (NSApp.modalWindow) { + NSInteger originalLevel = splashWindow.level; + splashWindow.level = NSNormalWindowLevel; + window->setProperty("_q_levelBeforeModalSession", (qlonglong)originalLevel); + } else if (NSInteger originalLevel = window->property("_q_levelBeforeModalSession").toLongLong()) { + splashWindow.level = originalLevel; + } + } + } + }); } QCocoaIntegration::~QCocoaIntegration() From 72e3d3633e4aca6742a124fb29584d46b63f40ff Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 24 Jun 2019 12:23:41 +0200 Subject: [PATCH 039/172] 3rd-Party/Double conversion: Fix developer build with MSVC Suppress warnings: C4244: 'argument': conversion from 'const uc16' to 'char', possible loss of data caused by various character handling routines. Amends 327bfdb671e0e263c6fb027133a54985a65194c4. Change-Id: I3818c5d0aecb9b6cee174f866b5e7e77aa96d877 Reviewed-by: Allan Sandfeld Jensen --- src/3rdparty/double-conversion/double-conversion.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/3rdparty/double-conversion/double-conversion.cc b/src/3rdparty/double-conversion/double-conversion.cc index ecd1a5ef3f1..881ca0adbc3 100644 --- a/src/3rdparty/double-conversion/double-conversion.cc +++ b/src/3rdparty/double-conversion/double-conversion.cc @@ -38,6 +38,11 @@ #include #include +// Fix warning C4244: 'argument': conversion from 'const uc16' to 'char', possible loss of data +#ifdef _MSC_VER + __pragma(warning(disable: 4244)) +#endif + namespace double_conversion { const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() { From fc940b24dbe8a118e92e335c0d9c7d4194bf3d4f Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 18 Jun 2019 17:19:08 +0300 Subject: [PATCH 040/172] QString: fix comments for qsizetype Change-Id: I445ba61513fbafd24834fa48ade849feae4f1324 Reviewed-by: Thiago Macieira --- src/corelib/tools/qregexp.cpp | 2 +- src/corelib/tools/qstring.cpp | 44 +++++++++++++++++------------------ src/corelib/tools/qstring.h | 20 ++++++++-------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 128df840531..dd38ba03607 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -1420,7 +1420,7 @@ void QRegExpMatchState::match(const QChar *str0, int len0, int pos0, #ifndef QT_NO_REGEXP_OPTIM if (eng->trivial && !oneTest) { - // ### Qt6: qsize + // ### Qt6: qsizetype pos = int(QtPrivate::findString(QStringView(str0, len0), pos0, QStringView(eng->goodStr.unicode(), eng->goodStr.length()), eng->cs)); matchLen = eng->goodStr.length(); matched = (pos != -1); diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index f9a9fcfe910..319f82af530 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -3701,7 +3701,7 @@ bool QString::operator>(QLatin1String other) const noexcept */ int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.length()), cs)); } #endif // QT_STRINGVIEW_LEVEL < 2 @@ -3745,7 +3745,7 @@ int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const int QString::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::findString(QStringView(unicode(), size()), from, str, cs)); } @@ -3758,7 +3758,7 @@ int QString::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const */ int QString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qFindChar(QStringView(unicode(), length()), ch, from, cs)); } @@ -3777,7 +3777,7 @@ int QString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const */ int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.length()), cs)); } @@ -3799,7 +3799,7 @@ int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) co */ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::lastIndexOf(*this, from, str, cs)); } @@ -3826,7 +3826,7 @@ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) c */ int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::lastIndexOf(*this, from, str, cs)); } @@ -3838,7 +3838,7 @@ int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) co */ int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qLastIndexOf(*this, ch, from, cs)); } @@ -3860,7 +3860,7 @@ int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const */ int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::lastIndexOf(*this, from, str, cs)); } #endif // QT_STRINGVIEW_LEVEL < 2 @@ -4192,7 +4192,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) int QString::count(const QString &str, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qt_string_count(QStringView(unicode(), size()), QStringView(str.unicode(), str.size()), cs)); } @@ -4209,7 +4209,7 @@ int QString::count(const QString &str, Qt::CaseSensitivity cs) const int QString::count(QChar ch, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qt_string_count(QStringView(unicode(), size()), ch, cs)); } @@ -4226,7 +4226,7 @@ int QString::count(QChar ch, Qt::CaseSensitivity cs) const */ int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qt_string_count(QStringView(unicode(), size()), QStringView(str.unicode(), str.size()), cs)); } @@ -11172,7 +11172,7 @@ QStringRef QString::midRef(int position, int n) const */ int QStringRef::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.length()), cs)); } #endif // QT_STRINGVIEW_LEVEL < 2 @@ -11207,7 +11207,7 @@ int QStringRef::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) co */ int QStringRef::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qFindChar(QStringView(unicode(), length()), ch, from, cs)); } @@ -11228,7 +11228,7 @@ int QStringRef::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const */ int QStringRef::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::findString(QStringView(unicode(), size()), from, str, cs)); } @@ -11249,7 +11249,7 @@ int QStringRef::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) con */ int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::findString(QStringView(unicode(), size()), from, QStringView(str.unicode(), str.size()), cs)); } #endif // QT_STRINGVIEW_LEVEL < 2 @@ -11270,7 +11270,7 @@ int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) */ int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::lastIndexOf(*this, from, str, cs)); } @@ -11285,7 +11285,7 @@ int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs */ int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qLastIndexOf(*this, ch, from, cs)); } @@ -11306,7 +11306,7 @@ int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const */ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::lastIndexOf(*this, from, str, cs)); } @@ -11327,7 +11327,7 @@ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) */ int QStringRef::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(QtPrivate::lastIndexOf(*this, from, str, cs)); } @@ -11360,7 +11360,7 @@ int QStringRef::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity */ int QStringRef::count(const QString &str, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qt_string_count(QStringView(unicode(), size()), QStringView(str.unicode(), str.size()), cs)); } @@ -11378,7 +11378,7 @@ int QStringRef::count(const QString &str, Qt::CaseSensitivity cs) const */ int QStringRef::count(QChar ch, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qt_string_count(QStringView(unicode(), size()), ch, cs)); } @@ -11396,7 +11396,7 @@ int QStringRef::count(QChar ch, Qt::CaseSensitivity cs) const */ int QStringRef::count(const QStringRef &str, Qt::CaseSensitivity cs) const { - // ### Qt6: qsize + // ### Qt6: qsizetype return int(qt_string_count(QStringView(unicode(), size()), QStringView(str.unicode(), str.size()), cs)); } diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index b56b37edf37..37bc8d91c94 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -135,11 +135,11 @@ public: { return QtPrivate::endsWith(*this, QStringView(&c, 1), cs); } Q_REQUIRED_RESULT int indexOf(QStringView s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsize + { return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsizetype Q_REQUIRED_RESULT int indexOf(QLatin1String s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsize + { return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsizetype Q_REQUIRED_RESULT inline int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::findString(*this, from, QStringView(&c, 1), cs)); } // ### Qt6: qsize + { return int(QtPrivate::findString(*this, from, QStringView(&c, 1), cs)); } // ### Qt6: qsizetype Q_REQUIRED_RESULT bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return indexOf(s, 0, cs) != -1; } @@ -149,11 +149,11 @@ public: { return indexOf(QStringView(&c, 1), 0, cs) != -1; } Q_REQUIRED_RESULT int lastIndexOf(QStringView s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsize + { return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsizetype Q_REQUIRED_RESULT int lastIndexOf(QLatin1String s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsize + { return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsizetype Q_REQUIRED_RESULT inline int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::lastIndexOf(*this, from, QStringView(&c, 1), cs)); } // ### Qt6: qsize + { return int(QtPrivate::lastIndexOf(*this, from, QStringView(&c, 1), cs)); } // ### Qt6: qsizetype using value_type = const char; using reference = value_type&; @@ -367,7 +367,7 @@ public: int indexOf(const QStringRef &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #endif Q_REQUIRED_RESULT int indexOf(QStringView s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsize + { return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsizetype int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int lastIndexOf(QLatin1String s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #if QT_STRINGVIEW_LEVEL < 2 @@ -376,7 +376,7 @@ public: #endif Q_REQUIRED_RESULT int lastIndexOf(QStringView s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsize + { return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsizetype inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #if QT_STRINGVIEW_LEVEL < 2 @@ -1555,7 +1555,7 @@ public: int indexOf(const QStringRef &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #endif Q_REQUIRED_RESULT int indexOf(QStringView s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsize + { return int(QtPrivate::findString(*this, from, s, cs)); } // ### Qt6: qsizetype int indexOf(QChar ch, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #if QT_STRINGVIEW_LEVEL < 2 @@ -1565,7 +1565,7 @@ public: int lastIndexOf(QChar ch, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int lastIndexOf(QLatin1String str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; Q_REQUIRED_RESULT int lastIndexOf(QStringView s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept - { return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsize + { return int(QtPrivate::lastIndexOf(*this, from, s, cs)); } // ### Qt6: qsizetype #if QT_STRINGVIEW_LEVEL < 2 inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; From 6fa34930c23c7494a3f2703777f46794ff091e2b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 07:24:18 +0200 Subject: [PATCH 041/172] QFreeList: fix memory order on block deletion Blocks are likely to have been created in a differnt thread from the one performing their deletion, so we need an acquire fence. The rest of the atomics use in the class looks ok, but nevertheless warrants a deeper analysis. Change-Id: I1571ded3a06695b0d58b5bf1d80d6283ac21f959 Reviewed-by: Thiago Macieira --- src/corelib/tools/qfreelist_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index dcaf5688dcd..5ba23b344b4 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -218,7 +218,7 @@ template inline QFreeList::~QFreeList() { for (int i = 0; i < ConstantsType::BlockCount; ++i) - delete [] _v[i].loadRelaxed(); + delete [] _v[i].loadAcquire(); } template From 8da3eea4fb702c2dc369c1628e91a034569aa9f0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 25 Jun 2019 22:21:44 +0200 Subject: [PATCH 042/172] Optimize some atomic counters Define the static QAtomic at file scope to avoid GCC's pessimisation with function-static QAtomic (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79561), and make sure the initial value is 0, so it ends up in BSS, not TEXT. In QRhi..., don't create a static instance of the wrapper class, use a file- static atomic, too. This turns the class into a glorified namespace. Change-Id: I707f628e2b434330028077223071716d5704ba32 Reviewed-by: Thiago Macieira --- src/gui/rhi/qrhi.cpp | 5 +++-- src/gui/rhi/qrhi_p_p.h | 4 ---- src/gui/text/qfont.cpp | 4 ++-- src/platformsupport/fbconvenience/qfbwindow.cpp | 5 +++-- src/plugins/platforms/android/qandroidplatformwindow.cpp | 5 +++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index dbad63c6d18..927de859dde 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -5192,10 +5192,11 @@ int QRhi::ubufAlignment() const return d->ubufAlignment(); } +static QBasicAtomicInteger counter = Q_BASIC_ATOMIC_INITIALIZER(0); + QRhiGlobalObjectIdGenerator::Type QRhiGlobalObjectIdGenerator::newId() { - static QRhiGlobalObjectIdGenerator inst; - return ++inst.counter; + return counter.fetchAndAddRelaxed(1) + 1; } bool QRhiPassResourceTracker::isEmpty() const diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h index 4fd01d3ef28..83d521f4416 100644 --- a/src/gui/rhi/qrhi_p_p.h +++ b/src/gui/rhi/qrhi_p_p.h @@ -52,7 +52,6 @@ #include "qrhiprofiler_p_p.h" #include #include -#include QT_BEGIN_NAMESPACE @@ -484,9 +483,6 @@ public: using Type = quint32; #endif static Type newId(); - -private: - QAtomicInteger counter; }; class QRhiPassResourceTracker diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 5555422b82f..2a1d207702e 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2799,12 +2799,12 @@ void QFontCache::cleanup() cache->setLocalData(0); } -QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(1); +static QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(0); QFontCache::QFontCache() : QObject(), total_cost(0), max_cost(min_cost), current_timestamp(0), fast(false), timer_id(-1), - m_id(font_cache_id.fetchAndAddRelaxed(1)) + m_id(font_cache_id.fetchAndAddRelaxed(1) + 1) { } diff --git a/src/platformsupport/fbconvenience/qfbwindow.cpp b/src/platformsupport/fbconvenience/qfbwindow.cpp index 36f92b8cea7..9f5f87d9d68 100644 --- a/src/platformsupport/fbconvenience/qfbwindow.cpp +++ b/src/platformsupport/fbconvenience/qfbwindow.cpp @@ -45,11 +45,12 @@ QT_BEGIN_NAMESPACE +static QBasicAtomicInt winIdGenerator = Q_BASIC_ATOMIC_INITIALIZER(0); + QFbWindow::QFbWindow(QWindow *window) : QPlatformWindow(window), mBackingStore(0), mWindowState(Qt::WindowNoState) { - static QAtomicInt winIdGenerator(1); - mWindowId = winIdGenerator.fetchAndAddRelaxed(1); + mWindowId = winIdGenerator.fetchAndAddRelaxed(1) + 1; } QFbWindow::~QFbWindow() diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index c095f51fa35..4f691ce112a 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -49,13 +49,14 @@ QT_BEGIN_NAMESPACE +static QBasicAtomicInt winIdGenerator = Q_BASIC_ATOMIC_INITIALIZER(0); + QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window) : QPlatformWindow(window) { m_windowFlags = Qt::Widget; m_windowState = Qt::WindowNoState; - static QAtomicInt winIdGenerator(1); - m_windowId = winIdGenerator.fetchAndAddRelaxed(1); + m_windowId = winIdGenerator.fetchAndAddRelaxed(1) + 1; setWindowState(window->windowStates()); } From e36e32c21312eee42194815da82203648023a67b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 15 Jun 2019 17:49:21 +0200 Subject: [PATCH 043/172] QBearerEngine: fix const-correctness of a loop with const-propagating QESDP The loop iterates over a collection of QExplicitSharedDataPointer, which traditionally doesn't propagate const. In Qt 6, it will, so prepare the code for this change, by taking the loop variable by non-const reference. Since the loop is followed by container.clear(), make it a consume-loop by looping over qExchange(container, {}). Change-Id: If12ab005544183598fd76a0c486b2df1582710d5 Reviewed-by: Giuseppe D'Angelo --- src/network/bearer/qbearerengine.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp index c06adb202ff..dbcf1e530e2 100644 --- a/src/network/bearer/qbearerengine.cpp +++ b/src/network/bearer/qbearerengine.cpp @@ -46,11 +46,10 @@ QT_BEGIN_NAMESPACE static void cleanUpConfigurations(QHash &configurations) { - for (const auto &ptr : qAsConst(configurations)) { + for (auto &ptr : qExchange(configurations, {})) { ptr->isValid = false; ptr->id.clear(); } - configurations.clear(); } static bool hasUsedConfiguration(const QHash &configurations) From 5220b40edd52ea70ed3a09f9a28fa7fe50ce71e6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 07:56:49 +0200 Subject: [PATCH 044/172] Port from implicit to explicit atomic integer operations The old code used the implicit conversions from QAtomicInteger to T and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixex some users of these APIs before we deprecate them. Change-Id: I4877276581757cd57e042efea8296fe535a493d1 Reviewed-by: Thiago Macieira --- src/3rdparty/forkfd/forkfd.c | 2 +- src/corelib/global/qrandom.cpp | 10 +++++----- src/corelib/global/qrandom_p.h | 4 +++- src/corelib/kernel/qobject.cpp | 2 +- src/corelib/kernel/qobject_p.h | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index bef109e401b..1cbe0da771d 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -267,7 +267,7 @@ static int tryReaping(pid_t pid, struct pipe_payload *payload) static void freeInfo(Header *header, ProcessInfo *entry) { entry->deathPipe = -1; - entry->pid = 0; + ffd_atomic_store(&entry->pid, 0, FFD_ATOMIC_RELEASE); (void)ffd_atomic_add_fetch(&header->busyCount, -1, FFD_ATOMIC_RELEASE); assert(header->busyCount >= 0); diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 84cf960f2db..379e37ac07a 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -359,17 +359,17 @@ Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin, quint32 *buffer = begin; qsizetype count = end - begin; - if (Q_UNLIKELY(uint(qt_randomdevice_control) & SetRandomData)) { - uint value = uint(qt_randomdevice_control) & RandomDataMask; + if (Q_UNLIKELY(uint(qt_randomdevice_control.loadAcquire()) & SetRandomData)) { + uint value = uint(qt_randomdevice_control.loadAcquire()) & RandomDataMask; std::fill_n(buffer, count, value); return; } qsizetype filled = 0; - if (qt_has_hwrng() && (uint(qt_randomdevice_control) & SkipHWRNG) == 0) + if (qt_has_hwrng() && (uint(qt_randomdevice_control.loadAcquire()) & SkipHWRNG) == 0) filled += qt_random_cpu(buffer, count); - if (filled != count && (uint(qt_randomdevice_control) & SkipSystemRNG) == 0) { + if (filled != count && (uint(qt_randomdevice_control.loadAcquire()) & SkipSystemRNG) == 0) { qsizetype bytesFilled = fillBuffer(buffer + filled, (count - filled) * qsizetype(sizeof(*buffer))); filled += bytesFilled / qsizetype(sizeof(*buffer)); @@ -1222,7 +1222,7 @@ void QRandomGenerator::_fillRange(void *buffer, void *bufferEnd) quint32 *begin = static_cast(buffer); quint32 *end = static_cast(bufferEnd); - if (type == SystemRNG || Q_UNLIKELY(uint(qt_randomdevice_control) & (UseSystemRNG|SetRandomData))) + if (type == SystemRNG || Q_UNLIKELY(uint(qt_randomdevice_control.loadAcquire()) & (UseSystemRNG|SetRandomData))) return SystemGenerator::self().generate(begin, end); SystemAndGlobalGenerators::PRNGLocker lock(this); diff --git a/src/corelib/global/qrandom_p.h b/src/corelib/global/qrandom_p.h index 917a91098ed..167f4cc57da 100644 --- a/src/corelib/global/qrandom_p.h +++ b/src/corelib/global/qrandom_p.h @@ -76,7 +76,9 @@ Q_CORE_EXPORT QBasicAtomicInteger qt_randomdevice_control = Q_BASIC_ATOMIC #elif defined(QT_BUILD_INTERNAL) extern Q_CORE_EXPORT QBasicAtomicInteger qt_randomdevice_control; #else -enum { qt_randomdevice_control = 0 }; +static const struct { + uint loadAcquire() const { return 0; } +} qt_randomdevice_control; #endif inline bool qt_has_hwrng() diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8f80be30bd9..e3b25f8bf7a 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -421,7 +421,7 @@ void QObjectPrivate::ConnectionData::cleanOrphanedConnectionsImpl(QObject *sende ConnectionOrSignalVector *c = nullptr; { QBasicMutexLocker l(signalSlotLock(sender)); - if (ref > 1) + if (ref.loadAcquire() > 1) return; // Since ref == 1, no activate() is in process since we locked the mutex. That implies, diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 1953aea21e8..247c7b15010 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -279,7 +279,7 @@ public: void removeConnection(Connection *c); void cleanOrphanedConnections(QObject *sender) { - if (orphaned.loadRelaxed() && ref == 1) + if (orphaned.loadRelaxed() && ref.loadAcquire() == 1) cleanOrphanedConnectionsImpl(sender); } void cleanOrphanedConnectionsImpl(QObject *sender); From 3043c7b95e139426d07889bf8dd46f0552874297 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 26 Jun 2019 14:50:27 +0200 Subject: [PATCH 045/172] Fix qdoc warnings in 5.14 Fix warning: src/corelib/global/qnamespace.qdoc:2371: (qdoc) warning: Cannot find 'Qt::SplitBehavior' specified with '\enum' in any header file and qdoc getting confused by a link spanning lines: src/corelib/time/qdatetime.cpp:3324: (qdoc) warning: Unknown macro 'note' src/corelib/time/qdatetime.cpp:3326: (qdoc) warning: Unknown macro 'section1' src/corelib/time/qdatetime.cpp:3328: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3334: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3344: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3361: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3373: (qdoc) warning: Unknown macro 'e' src/corelib/time/qdatetime.cpp:3378: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3386: (qdoc) warning: Unknown macro 'sa' Change-Id: I314da69078eb07f66e9d389eecdf0195569ea2ce Reviewed-by: Leena Miettinen --- src/corelib/global/qnamespace.qdoc | 2 +- src/corelib/time/qdatetime.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 45d79902c79..0ff6be20498 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2369,7 +2369,7 @@ */ /*! - \enum Qt::SplitBehavior + \enum Qt::SplitBehaviorFlags \since 5.14 This enum specifies how the split() functions should behave with diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index e34ce712127..3c7484dca5c 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -3272,9 +3272,10 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT provides functions for comparing datetimes and for manipulating a datetime by adding a number of seconds, days, months, or years. - QDateTime can describe datetimes with respect to \l{Qt::LocalTime}{local - time}, to \l{Qt::UTC}{UTC}, to a specified \l{Qt::OffsetFromUTC}{offset - from UTC} or to a specified \l{{Qt::TimeZone}{time zone}, in conjunction + QDateTime can describe datetimes with respect to + \l{Qt::LocalTime}{local time}, to \l{Qt::UTC}{UTC}, to a specified + \l{Qt::OffsetFromUTC}{offset from UTC} or to a specified + \l{Qt::TimeZone}{time zone}, in conjunction with the QTimeZone class. For example, a time zone of "Europe/Berlin" will apply the daylight-saving rules as used in Germany since 1970. In contrast, an offset from UTC of +3600 seconds is one hour ahead of UTC (usually From c2b00f8d5737b75996232567790ff93a5a7d258f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 26 Jun 2019 11:28:44 +0200 Subject: [PATCH 046/172] tst_QThread: Add output for all elapsed tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Obtain diagnostics. Task-number: QTBUG-76707 Change-Id: I051fb43802a9736cb9542f4adaaf5880b52a407e Reviewed-by: Mårten Nordheim --- .../corelib/thread/qthread/tst_qthread.cpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index baec4a22a57..7be2f48758b 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -110,6 +110,12 @@ private slots: enum { one_minute = 60 * 1000, five_minutes = 5 * one_minute }; +template +static QString msgElapsed(Int elapsed) +{ + return QString::fromLatin1("elapsed: %1").arg(elapsed); +} + class SignalRecorder : public QObject { Q_OBJECT @@ -591,7 +597,7 @@ void tst_QThread::sleep() thread.interval = 2; thread.start(); QVERIFY(thread.wait(five_minutes)); - QVERIFY(thread.elapsed >= 2000); + QVERIFY2(thread.elapsed >= 2000, qPrintable(msgElapsed(thread.elapsed))); } void tst_QThread::msleep() @@ -602,9 +608,9 @@ void tst_QThread::msleep() thread.start(); QVERIFY(thread.wait(five_minutes)); #if defined (Q_OS_WIN) // May no longer be needed - QVERIFY(thread.elapsed >= 100); + QVERIFY2(thread.elapsed >= 100, qPrintable(msgElapsed(thread.elapsed))); #else - QVERIFY(thread.elapsed >= 120); + QVERIFY2(thread.elapsed >= 120, qPrintable(msgElapsed(thread.elapsed))); #endif } @@ -616,9 +622,9 @@ void tst_QThread::usleep() thread.start(); QVERIFY(thread.wait(five_minutes)); #if defined (Q_OS_WIN) // May no longer be needed - QVERIFY(thread.elapsed >= 100); + QVERIFY2(thread.elapsed >= 100, qPrintable(msgElapsed(thread.elapsed))); #else - QVERIFY(thread.elapsed >= 120); + QVERIFY2(thread.elapsed >= 120, qPrintable(msgElapsed(thread.elapsed))); #endif } @@ -1065,13 +1071,15 @@ void tst_QThread::wait2() timer.start(); QVERIFY(!thread.wait(Waiting_Thread::WaitTime)); qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 9). - QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 10, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed))); + QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 10, + qPrintable(msgElapsed(elapsed))); timer.start(); thread.cond1.wakeOne(); QVERIFY(thread.wait(/*Waiting_Thread::WaitTime * 1.4*/)); elapsed = timer.elapsed(); - QVERIFY2(elapsed - Waiting_Thread::WaitTime >= -1, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed))); + QVERIFY2(elapsed - Waiting_Thread::WaitTime >= -1, + qPrintable(msgElapsed(elapsed))); } From fb244259ae749f33cb4d870552c41c886fbe3f2b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 26 Jun 2019 10:37:57 +0200 Subject: [PATCH 047/172] RHI: Fix compilation with MinGW developer builds Make aligned a template, fixing: rhi\qrhid3d11.cpp: In member function 'void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings*)': rhi\qrhid3d11.cpp:1627:53: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] Q_ASSERT(aligned(b->u.ubuf.offset, 256) == b->u.ubuf.offset); Change-Id: I6b747ebaf78e5accb9b7ed145df71a80d0a15762 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhid3d11.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 7d9c934c187..6b05d68fb53 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -150,7 +150,8 @@ static QString comErrorMessage(HRESULT hr) return result; } -static inline uint aligned(uint v, uint byteAlign) +template +static inline Int aligned(Int v, Int byteAlign) { return (v + byteAlign - 1) & ~(byteAlign - 1); } @@ -595,7 +596,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind for (int i = 0; i < dynamicOffsetCount; ++i) { const QRhiCommandBuffer::DynamicOffset &dynOfs(dynamicOffsets[i]); const uint binding = dynOfs.first; - Q_ASSERT(aligned(dynOfs.second, 256) == dynOfs.second); + Q_ASSERT(aligned(dynOfs.second, quint32(256)) == dynOfs.second); const uint offsetInConstants = dynOfs.second / 16; *p++ = binding; *p++ = offsetInConstants; From 6007120aa4391fa53acd774a451530c6561a1658 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 20 Jun 2019 09:47:38 +0200 Subject: [PATCH 048/172] QtWidgets: Fix static method invocations Apply fixits by Creator and results of manual search focusing on QCore/Gui/Applicaton(Private) methods and variables to prepare for splitting out some classes. Task-number: QTBUG-69478 Task-number: QTBUG-76497 Task-number: QTBUG-76493 Change-Id: Iaf468166793e0cabb514b51c827b30317bf45a2d Reviewed-by: Oliver Wolff --- src/widgets/dialogs/qdialog.cpp | 6 +- src/widgets/dialogs/qerrormessage.cpp | 2 +- src/widgets/dialogs/qfilesystemmodel.cpp | 2 +- src/widgets/dialogs/qfontdialog.cpp | 4 +- src/widgets/dialogs/qmessagebox.cpp | 2 +- src/widgets/dialogs/qprogressdialog.cpp | 4 +- src/widgets/dialogs/qwizard.cpp | 2 +- src/widgets/graphicsview/qgraphicslayout.cpp | 2 +- .../graphicsview/qgraphicslayout_p.cpp | 2 +- .../graphicsview/qgraphicsproxywidget.cpp | 32 ++-- src/widgets/graphicsview/qgraphicsscene.cpp | 24 +-- src/widgets/graphicsview/qgraphicsview.cpp | 56 +++--- src/widgets/graphicsview/qgraphicswidget.cpp | 46 ++--- .../graphicsview/qgraphicswidget_p.cpp | 10 +- src/widgets/itemviews/qabstractitemview.cpp | 18 +- src/widgets/itemviews/qdirmodel.cpp | 4 +- src/widgets/itemviews/qheaderview.cpp | 2 +- src/widgets/itemviews/qlistview.cpp | 6 +- src/widgets/kernel/qaction.cpp | 44 ++--- src/widgets/kernel/qapplication.cpp | 50 +++--- src/widgets/kernel/qboxlayout.cpp | 2 +- src/widgets/kernel/qformlayout.cpp | 2 +- src/widgets/kernel/qgesturemanager.cpp | 4 +- src/widgets/kernel/qlayout.cpp | 4 +- src/widgets/kernel/qopenglwidget.cpp | 4 +- src/widgets/kernel/qshortcut.cpp | 14 +- src/widgets/kernel/qwhatsthis.cpp | 14 +- src/widgets/kernel/qwidget.cpp | 162 +++++++++--------- src/widgets/kernel/qwidgetbackingstore.cpp | 6 +- src/widgets/kernel/qwidgetwindow.cpp | 12 +- src/widgets/kernel/qwindowcontainer.cpp | 2 +- src/widgets/styles/qcommonstyle.cpp | 20 +-- src/widgets/styles/qstyle.cpp | 4 +- src/widgets/styles/qstyleoption.cpp | 2 +- src/widgets/styles/qstylesheetstyle.cpp | 6 +- src/widgets/styles/qwindowsstyle.cpp | 11 +- src/widgets/util/qcompleter.cpp | 2 +- src/widgets/util/qflickgesture.cpp | 8 +- src/widgets/util/qsystemtrayicon_x11.cpp | 4 +- src/widgets/widgets/qabstractscrollarea.cpp | 6 +- src/widgets/widgets/qabstractspinbox.cpp | 6 +- src/widgets/widgets/qcombobox.cpp | 4 +- src/widgets/widgets/qdatetimeedit.cpp | 8 +- src/widgets/widgets/qdockwidget.cpp | 2 +- src/widgets/widgets/qeffects.cpp | 8 +- src/widgets/widgets/qlineedit.cpp | 19 +- src/widgets/widgets/qmdiarea.cpp | 2 +- src/widgets/widgets/qmdisubwindow.cpp | 6 +- src/widgets/widgets/qmenu.cpp | 30 ++-- src/widgets/widgets/qmenubar.cpp | 4 +- src/widgets/widgets/qplaintextedit.cpp | 4 +- src/widgets/widgets/qspinbox.cpp | 8 +- src/widgets/widgets/qsplashscreen.cpp | 6 +- src/widgets/widgets/qtabbar.cpp | 2 +- src/widgets/widgets/qtextedit.cpp | 2 +- src/widgets/widgets/qtoolbar.cpp | 2 +- src/widgets/widgets/qwidgetlinecontrol.cpp | 10 +- src/widgets/widgets/qwidgettextcontrol.cpp | 20 +-- 58 files changed, 376 insertions(+), 374 deletions(-) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 5692a16bcef..3cdd9a5f04e 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -282,7 +282,7 @@ void QDialogPrivate::deletePlatformHelper() progress dialogs, where the user must have the ability to interact with the dialog, e.g. to cancel a long running operation. If you use show() and setModal(true) together to perform a long operation, - you must call QApplication::processEvents() periodically during + you must call QCoreApplication::processEvents() periodically during processing to enable the user to interact with the dialog. (See QProgressDialog.) @@ -691,7 +691,7 @@ void QDialog::contextMenuEvent(QContextMenuEvent *e) if (p.data()->exec(e->globalPos()) == wt) { QHelpEvent e(QEvent::WhatsThis, w->rect().center(), w->mapToGlobal(w->rect().center())); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } delete p.data(); } @@ -826,7 +826,7 @@ QT_WARNING_POP #endif if (fw && !fw->hasFocus()) { QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason); - QApplication::sendEvent(fw, &e); + QCoreApplication::sendEvent(fw, &e); } #ifndef QT_NO_ACCESSIBILITY diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index 51a3e080bf0..f0ec2c0102f 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -295,7 +295,7 @@ QErrorMessage * QErrorMessage::qtHandler() if (!qtMessageHandler) { qtMessageHandler = new QErrorMessage(0); qAddPostRoutine(deleteStaticcQErrorMessage); // clean up - qtMessageHandler->setWindowTitle(QApplication::applicationName()); + qtMessageHandler->setWindowTitle(QCoreApplication::applicationName()); qInstallMessageHandler(jump); } return qtMessageHandler; diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index a778fd3a456..b521f50f407 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1390,7 +1390,7 @@ QModelIndex QFileSystemModel::setRootPath(const QString &newPath) if (d->rootDir.path() == longNewPath) return d->index(rootPath()); - bool showDrives = (longNewPath.isEmpty() || longNewPath == d->myComputer()); + bool showDrives = (longNewPath.isEmpty() || longNewPath == QFileSystemModelPrivate::myComputer()); if (!showDrives && !newPathDir.exists()) return d->index(rootPath()); diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 2b81180ecb9..cd296ca0202 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -432,7 +432,7 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e) k->key() == Qt::Key_PageDown)) { int ci = d->sizeList->currentItem(); - (void)QApplication::sendEvent(d->sizeList, k); + QCoreApplication::sendEvent(d->sizeList, k); if (ci != d->sizeList->currentItem() && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) @@ -680,7 +680,7 @@ void QFontDialogPrivate::updateSampleFont(const QFont &newFont) void QFontDialogPrivate::_q_writingSystemHighlighted(int index) { writingSystem = QFontDatabase::WritingSystem(index); - sampleEdit->setText(fdb.writingSystemSample(writingSystem)); + sampleEdit->setText(QFontDatabase::writingSystemSample(writingSystem)); updateFamilies(); } diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 9bfea06a54c..8dad212692c 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1508,7 +1508,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) if (d->detailsText) textToCopy += d->detailsText->text() + QLatin1Char('\n') + separator; #endif - QApplication::clipboard()->setText(textToCopy); + QGuiApplication::clipboard()->setText(textToCopy); return; } #endif // Q_OS_WIN diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index 078dd6463b5..e1a6bce5b19 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -643,7 +643,7 @@ int QProgressDialog::value() const \warning If the progress dialog is modal (see QProgressDialog::QProgressDialog()), - setValue() calls QApplication::processEvents(), so take care that + setValue() calls QCoreApplication::processEvents(), so take care that this does not cause undesirable re-entrancy in your code. For example, don't use a QProgressDialog inside a paintEvent()! @@ -659,7 +659,7 @@ void QProgressDialog::setValue(int progress) if (d->shown_once) { if (isModal()) - QApplication::processEvents(); + QCoreApplication::processEvents(); } else { if ((!d->setValue_called && progress == 0 /* for compat with Qt < 5.4 */) || progress == minimum()) { d->starttime.start(); diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index f428114bbe7..4d28dda7c75 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -2577,7 +2577,7 @@ void QWizard::setWizardStyle(WizardStyle style) //Send a resizeevent since the antiflicker widget probably needs a new size //because of the backbutton in the window title QResizeEvent ev(geometry().size(), geometry().size()); - QApplication::sendEvent(this, &ev); + QCoreApplication::sendEvent(this, &ev); } #endif d->updateLayout(); diff --git a/src/widgets/graphicsview/qgraphicslayout.cpp b/src/widgets/graphicsview/qgraphicslayout.cpp index ca0aef9e27f..8b52b57580a 100644 --- a/src/widgets/graphicsview/qgraphicslayout.cpp +++ b/src/widgets/graphicsview/qgraphicslayout.cpp @@ -338,7 +338,7 @@ void QGraphicsLayout::invalidate() } if (layoutItem && !layoutItem->isLayout()) { // If a layout has a parent that is not a layout it must be a QGraphicsWidget. - QApplication::postEvent(static_cast(layoutItem), new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(static_cast(layoutItem), new QEvent(QEvent::LayoutRequest)); } } } diff --git a/src/widgets/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp index ae1eeffa2bf..59ed7acd72b 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp @@ -108,7 +108,7 @@ Qt::LayoutDirection QGraphicsLayoutPrivate::visualDirection() const if (maybeWidget->isWidget()) return static_cast(maybeWidget)->layoutDirection(); } - return QApplication::layoutDirection(); + return QGuiApplication::layoutDirection(); } static bool removeLayoutItemFromLayout(QGraphicsLayout *lay, QGraphicsLayoutItem *layoutItem) diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index e9f092020f4..f1b01fbb4dd 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -342,7 +342,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(QKeyEvent *event) Q_ASSERT(receiver); do { - bool res = QApplication::sendEvent(receiver, event); + bool res = QCoreApplication::sendEvent(receiver, event); if ((res && event->isAccepted()) || (q->isWindow() && receiver == widget)) break; receiver = receiver->parentWidget(); @@ -356,9 +356,9 @@ void QGraphicsProxyWidgetPrivate::removeSubFocusHelper(QWidget *widget, Qt::Focu { QFocusEvent event(QEvent::FocusOut, reason); QPointer widgetGuard = widget; - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); if (widgetGuard && event.isAccepted()) - QApplication::sendEvent(widget->style(), &event); + QCoreApplication::sendEvent(widget->style(), &event); } /*! @@ -865,7 +865,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) case QEvent::ShortcutOverride: { QWidget *focusWidget = d->widget->focusWidget(); while (focusWidget) { - QApplication::sendEvent(focusWidget, event); + QCoreApplication::sendEvent(focusWidget, event); if (event->isAccepted()) return true; focusWidget = focusWidget->parentWidget(); @@ -878,7 +878,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier? QWidget *focusWidget = d->widget->focusWidget(); while (focusWidget) { - bool res = QApplication::sendEvent(focusWidget, event); + const bool res = QCoreApplication::sendEvent(focusWidget, event); if ((res && event->isAccepted()) || (isWindow() && focusWidget == d->widget)) { event->accept(); break; @@ -897,7 +897,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) QGraphicsSceneHelpEvent *he = static_cast(event); QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint(); QHelpEvent e(QEvent::ToolTip, pos, he->screenPos()); - QApplication::sendEvent(d->lastWidgetUnderMouse, &e); + QCoreApplication::sendEvent(d->lastWidgetUnderMouse, &e); event->setAccepted(e.isAccepted()); return e.isAccepted(); } @@ -919,7 +919,7 @@ bool QGraphicsProxyWidget::event(QEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(d->widget, event); else - QApplication::sendEvent(d->widget, event); + QCoreApplication::sendEvent(d->widget, event); if (event->isAccepted()) return true; @@ -1044,7 +1044,7 @@ void QGraphicsProxyWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *even // Send mouse event. ### Doesn't propagate the event. QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()), pos.toPoint(), globalPos, event->modifiers()); - QApplication::sendEvent(receiver, &contextMenuEvent); + QCoreApplication::sendEvent(receiver, &contextMenuEvent); event->setAccepted(contextMenuEvent.isAccepted()); } @@ -1065,7 +1065,7 @@ void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event) QDragEnterEvent proxyDragEnter(event->pos().toPoint(), event->dropAction(), event->mimeData(), event->buttons(), event->modifiers()); proxyDragEnter.setAccepted(event->isAccepted()); - QApplication::sendEvent(d->widget, &proxyDragEnter); + QCoreApplication::sendEvent(d->widget, &proxyDragEnter); event->setAccepted(proxyDragEnter.isAccepted()); if (proxyDragEnter.isAccepted()) // we discard answerRect event->setDropAction(proxyDragEnter.dropAction()); @@ -1082,7 +1082,7 @@ void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) if (!d->widget || !d->dragDropWidget) return; QDragLeaveEvent proxyDragLeave; - QApplication::sendEvent(d->dragDropWidget, &proxyDragLeave); + QCoreApplication::sendEvent(d->dragDropWidget, &proxyDragLeave); d->dragDropWidget = 0; #endif } @@ -1112,7 +1112,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) // Try to enter before we leave QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); dragEnter.setDropAction(event->proposedAction()); - QApplication::sendEvent(receiver, &dragEnter); + QCoreApplication::sendEvent(receiver, &dragEnter); event->setAccepted(dragEnter.isAccepted()); event->setDropAction(dragEnter.dropAction()); if (!event->isAccepted()) { @@ -1124,14 +1124,14 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) if (d->dragDropWidget) { QDragLeaveEvent dragLeave; - QApplication::sendEvent(d->dragDropWidget, &dragLeave); + QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave); } d->dragDropWidget = receiver; } QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); event->setDropAction(d->lastDropAction); - QApplication::sendEvent(receiver, &dragMove); + QCoreApplication::sendEvent(receiver, &dragMove); event->setAccepted(dragMove.isAccepted()); event->setDropAction(dragMove.dropAction()); if (event->isAccepted()) @@ -1144,7 +1144,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) if (d->dragDropWidget) { // Leave the last drag drop item QDragLeaveEvent dragLeave; - QApplication::sendEvent(d->dragDropWidget, &dragLeave); + QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave); d->dragDropWidget = 0; } // Propagate @@ -1165,7 +1165,7 @@ void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event) if (d->widget && d->dragDropWidget) { QPoint widgetPos = d->mapToReceiver(event->pos(), d->dragDropWidget).toPoint(); QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); - QApplication::sendEvent(d->dragDropWidget, &dropEvent); + QCoreApplication::sendEvent(d->dragDropWidget, &dropEvent); event->setAccepted(dropEvent.isAccepted()); d->dragDropWidget = 0; } @@ -1464,7 +1464,7 @@ void QGraphicsProxyWidget::inputMethodEvent(QInputMethodEvent *event) Q_D(const QGraphicsProxyWidget); QWidget *focusWidget = d->widget->focusWidget(); if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) - QApplication::sendEvent(focusWidget, event); + QCoreApplication::sendEvent(focusWidget, event); } /*! diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index e5bd65d61e9..2cdbdc20720 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -114,7 +114,7 @@ Another responsibility that QGraphicsScene has, is to propagate events from QGraphicsView. To send an event to a scene, you construct an event that inherits QEvent, and then send it using, for example, - QApplication::sendEvent(). event() is responsible for dispatching + QCoreApplication::sendEvent(). event() is responsible for dispatching the event to the individual items. Some common events are handled by convenience event handlers. For example, key press events are handled by keyPressEvent(), and mouse press events are handled by mousePressEvent(). @@ -451,7 +451,7 @@ void QGraphicsScenePrivate::_q_polishItems() } if (itemd->isWidget) { QEvent event(QEvent::Polish); - QApplication::sendEvent((QGraphicsWidget *)item, &event); + QCoreApplication::sendEvent((QGraphicsWidget *)item, &event); } } @@ -774,7 +774,7 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin // Update activate state. activePanel = panel; QEvent event(QEvent::ActivationChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); // Activate if (panel) { @@ -1243,7 +1243,7 @@ bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) return false; if (QGraphicsObject *o = item->toGraphicsObject()) { bool spont = event->spontaneous(); - if (spont ? qt_sendSpontaneousEvent(o, event) : QApplication::sendEvent(o, event)) + if (spont ? qt_sendSpontaneousEvent(o, event) : QCoreApplication::sendEvent(o, event)) return true; event->spont = spont; } @@ -1569,7 +1569,7 @@ void QGraphicsScenePrivate::updateFont(const QFont &font) // Send the scene a FontChange event. QEvent event(QEvent::FontChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); } /*! @@ -1593,7 +1593,7 @@ void QGraphicsScenePrivate::setPalette_helper(const QPalette &palette) */ void QGraphicsScenePrivate::resolvePalette() { - QPalette naturalPalette = QApplication::palette(); + QPalette naturalPalette = QGuiApplication::palette(); naturalPalette.resolve(0); QPalette resolvedPalette = palette.resolve(naturalPalette); updatePalette(resolvedPalette); @@ -1626,7 +1626,7 @@ void QGraphicsScenePrivate::updatePalette(const QPalette &palette) // Send the scene a PaletteChange event. QEvent event(QEvent::PaletteChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); } /*! @@ -3548,10 +3548,10 @@ bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event) switch (event->type()) { case QEvent::ApplicationPaletteChange: - QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); + QCoreApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); break; case QEvent::ApplicationFontChange: - QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange)); + QCoreApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange)); break; default: break; @@ -5605,7 +5605,7 @@ void QGraphicsScene::setStyle(QStyle *style) // Notify the scene. QEvent event(QEvent::StyleChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); // Notify all widgets that don't have a style explicitly set. const auto items_ = items(); @@ -5613,7 +5613,7 @@ void QGraphicsScene::setStyle(QStyle *style) if (item->isWidget()) { QGraphicsWidget *widget = static_cast(item); if (!widget->testAttribute(Qt::WA_SetStyle)) - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); } } } @@ -5686,7 +5686,7 @@ QPalette QGraphicsScene::palette() const void QGraphicsScene::setPalette(const QPalette &palette) { Q_D(QGraphicsScene); - QPalette naturalPalette = QApplication::palette(); + QPalette naturalPalette = QGuiApplication::palette(); naturalPalette.resolve(0); QPalette resolvedPalette = palette.resolve(naturalPalette); d->setPalette_helper(resolvedPalette); diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 5fe520132f5..3ec9668cde2 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -667,7 +667,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(scene, &mouseEvent); else - QApplication::sendEvent(scene, &mouseEvent); + QCoreApplication::sendEvent(scene, &mouseEvent); // Remember whether the last event was accepted or not. lastMouseEvent.setAccepted(mouseEvent.isAccepted()); @@ -1716,7 +1716,7 @@ void QGraphicsView::setScene(QGraphicsScene *scene) if (isActiveWindow() && isVisible()) { QEvent windowDeactivate(QEvent::WindowDeactivate); - QApplication::sendEvent(d->scene, &windowDeactivate); + QCoreApplication::sendEvent(d->scene, &windowDeactivate); } if(hasFocus()) d->scene->clearFocus(); @@ -1744,7 +1744,7 @@ void QGraphicsView::setScene(QGraphicsScene *scene) if (isActiveWindow() && isVisible()) { QEvent windowActivate(QEvent::WindowActivate); - QApplication::sendEvent(d->scene, &windowActivate); + QCoreApplication::sendEvent(d->scene, &windowActivate); } } else { d->recalculateContentSize(); @@ -2809,7 +2809,7 @@ bool QGraphicsView::event(QEvent *event) switch (event->type()) { case QEvent::ShortcutOverride: if (d->scene) - return QApplication::sendEvent(d->scene, event); + return QCoreApplication::sendEvent(d->scene, event); break; case QEvent::KeyPress: if (d->scene) { @@ -2821,7 +2821,7 @@ bool QGraphicsView::event(QEvent *event) // and the base implementation will call QGraphicsView's // focusNextPrevChild() function. If the event is ignored, // we fall back to standard tab focus handling. - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); if (event->isAccepted()) return true; // Ensure the event doesn't propagate just because the @@ -2850,10 +2850,10 @@ bool QGraphicsView::viewportEvent(QEvent *event) switch (event->type()) { case QEvent::Enter: - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); break; case QEvent::WindowActivate: - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); break; case QEvent::WindowDeactivate: // ### This is a temporary fix for until we get proper mouse @@ -2862,19 +2862,19 @@ bool QGraphicsView::viewportEvent(QEvent *event) // Remove all popups when the scene loses focus. if (!d->scene->d_func()->popupWidgets.isEmpty()) d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.constFirst()); - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); break; case QEvent::Show: if (d->scene && isActiveWindow()) { QEvent windowActivate(QEvent::WindowActivate); - QApplication::sendEvent(d->scene, &windowActivate); + QCoreApplication::sendEvent(d->scene, &windowActivate); } break; case QEvent::Hide: // spontaneous event will generate a WindowDeactivate. if (!event->spontaneous() && d->scene && isActiveWindow()) { QEvent windowDeactivate(QEvent::WindowDeactivate); - QApplication::sendEvent(d->scene, &windowDeactivate); + QCoreApplication::sendEvent(d->scene, &windowDeactivate); } break; case QEvent::Leave: { @@ -2892,7 +2892,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) Q_ASSERT(event->d == 0); QScopedValueRollback rb(event->d); event->d = reinterpret_cast(viewport()); - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); break; } #ifndef QT_NO_TOOLTIP @@ -2902,7 +2902,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) helpEvent.setWidget(viewport()); helpEvent.setScreenPos(toolTip->globalPos()); helpEvent.setScenePos(mapToScene(toolTip->pos())); - QApplication::sendEvent(d->scene, &helpEvent); + QCoreApplication::sendEvent(d->scene, &helpEvent); toolTip->setAccepted(helpEvent.isAccepted()); return true; } @@ -2940,7 +2940,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) QTouchEvent *touchEvent = static_cast(event); touchEvent->setTarget(viewport()); QGraphicsViewPrivate::translateTouchEvent(d, touchEvent); - (void) QApplication::sendEvent(d->scene, touchEvent); + QCoreApplication::sendEvent(d->scene, touchEvent); } else { event->ignore(); } @@ -2957,7 +2957,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) if (d->scene && d->sceneInteractionAllowed) { QGestureEvent *gestureEvent = static_cast(event); gestureEvent->setWidget(viewport()); - (void) QApplication::sendEvent(d->scene, gestureEvent); + QCoreApplication::sendEvent(d->scene, gestureEvent); } return true; } @@ -2992,7 +2992,7 @@ void QGraphicsView::contextMenuEvent(QContextMenuEvent *event) contextEvent.setModifiers(event->modifiers()); contextEvent.setReason((QGraphicsSceneContextMenuEvent::Reason)(event->reason())); contextEvent.setAccepted(event->isAccepted()); - QApplication::sendEvent(d->scene, &contextEvent); + QCoreApplication::sendEvent(d->scene, &contextEvent); event->setAccepted(contextEvent.isAccepted()); } #endif // QT_NO_CONTEXTMENU @@ -3012,7 +3012,7 @@ void QGraphicsView::dropEvent(QDropEvent *event) d->populateSceneDragDropEvent(&sceneEvent, event); // Send it to the scene. - QApplication::sendEvent(d->scene, &sceneEvent); + QCoreApplication::sendEvent(d->scene, &sceneEvent); // Accept the originating event if the scene accepted the scene event. event->setAccepted(sceneEvent.isAccepted()); @@ -3043,7 +3043,7 @@ void QGraphicsView::dragEnterEvent(QDragEnterEvent *event) d->storeDragDropEvent(&sceneEvent); // Send it to the scene. - QApplication::sendEvent(d->scene, &sceneEvent); + QCoreApplication::sendEvent(d->scene, &sceneEvent); // Accept the originating event if the scene accepted the scene event. if (sceneEvent.isAccepted()) { @@ -3081,7 +3081,7 @@ void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) d->lastDragDropEvent = 0; // Send it to the scene. - QApplication::sendEvent(d->scene, &sceneEvent); + QCoreApplication::sendEvent(d->scene, &sceneEvent); // Accept the originating event if the scene accepted the scene event. if (sceneEvent.isAccepted()) @@ -3105,7 +3105,7 @@ void QGraphicsView::dragMoveEvent(QDragMoveEvent *event) d->storeDragDropEvent(&sceneEvent); // Send it to the scene. - QApplication::sendEvent(d->scene, &sceneEvent); + QCoreApplication::sendEvent(d->scene, &sceneEvent); // Ignore the originating event if the scene ignored the scene event. event->setAccepted(sceneEvent.isAccepted()); @@ -3123,7 +3123,7 @@ void QGraphicsView::focusInEvent(QFocusEvent *event) d->updateInputMethodSensitivity(); QAbstractScrollArea::focusInEvent(event); if (d->scene) - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); // Pass focus on if the scene cannot accept focus. if (!d->scene || !event->isAccepted()) QAbstractScrollArea::focusInEvent(event); @@ -3145,7 +3145,7 @@ void QGraphicsView::focusOutEvent(QFocusEvent *event) Q_D(QGraphicsView); QAbstractScrollArea::focusOutEvent(event); if (d->scene) - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); } /*! @@ -3158,7 +3158,7 @@ void QGraphicsView::keyPressEvent(QKeyEvent *event) QAbstractScrollArea::keyPressEvent(event); return; } - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); if (!event->isAccepted()) QAbstractScrollArea::keyPressEvent(event); } @@ -3171,7 +3171,7 @@ void QGraphicsView::keyReleaseEvent(QKeyEvent *event) Q_D(QGraphicsView); if (!d->scene || !d->sceneInteractionAllowed) return; - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); if (!event->isAccepted()) QAbstractScrollArea::keyReleaseEvent(event); } @@ -3210,7 +3210,7 @@ void QGraphicsView::mouseDoubleClickEvent(QMouseEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(d->scene, &mouseEvent); else - QApplication::sendEvent(d->scene, &mouseEvent); + QCoreApplication::sendEvent(d->scene, &mouseEvent); // Update the original mouse event accepted state. const bool isAccepted = mouseEvent.isAccepted(); @@ -3261,7 +3261,7 @@ void QGraphicsView::mousePressEvent(QMouseEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(d->scene, &mouseEvent); else - QApplication::sendEvent(d->scene, &mouseEvent); + QCoreApplication::sendEvent(d->scene, &mouseEvent); // Update the original mouse event accepted state. bool isAccepted = mouseEvent.isAccepted(); @@ -3397,7 +3397,7 @@ void QGraphicsView::mouseReleaseEvent(QMouseEvent *event) if (event->spontaneous()) qt_sendSpontaneousEvent(d->scene, &mouseEvent); else - QApplication::sendEvent(d->scene, &mouseEvent); + QCoreApplication::sendEvent(d->scene, &mouseEvent); // Update the last mouse event selected state. d->lastMouseEvent.setAccepted(mouseEvent.isAccepted()); @@ -3433,7 +3433,7 @@ void QGraphicsView::wheelEvent(QWheelEvent *event) wheelEvent.setDelta(event->delta()); wheelEvent.setOrientation(event->orientation()); wheelEvent.setAccepted(false); - QApplication::sendEvent(d->scene, &wheelEvent); + QCoreApplication::sendEvent(d->scene, &wheelEvent); event->setAccepted(wheelEvent.isAccepted()); if (!event->isAccepted()) QAbstractScrollArea::wheelEvent(event); @@ -3720,7 +3720,7 @@ void QGraphicsView::inputMethodEvent(QInputMethodEvent *event) { Q_D(QGraphicsView); if (d->scene) - QApplication::sendEvent(d->scene, event); + QCoreApplication::sendEvent(d->scene, event); } /*! diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index cd647a5db11..643f0730857 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -390,7 +390,7 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) QGraphicsSceneMoveEvent event; event.setOldPos(oldPos); event.setNewPos(pos()); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); if (wd->inSetPos) { //set the new pos d->geom.moveTopLeft(pos()); @@ -413,10 +413,10 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) QGraphicsLayout *lay = wd->layout; if (QGraphicsLayout::instantInvalidatePropagation()) { if (!lay || lay->isActivated()) { - QApplication::sendEvent(this, &re); + QCoreApplication::sendEvent(this, &re); } } else { - QApplication::sendEvent(this, &re); + QCoreApplication::sendEvent(this, &re); } } } @@ -427,7 +427,7 @@ relayoutChildrenAndReturn: if (QGraphicsLayout *lay = wd->layout) { if (!lay->isActivated()) { QEvent layoutRequest(QEvent::LayoutRequest); - QApplication::sendEvent(this, &layoutRequest); + QCoreApplication::sendEvent(this, &layoutRequest); } } } @@ -507,7 +507,7 @@ void QGraphicsWidget::setContentsMargins(QMarginsF margins) updateGeometry(); QEvent e(QEvent::ContentsRectChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -963,7 +963,7 @@ void QGraphicsWidget::setStyle(QStyle *style) // Deliver StyleChange to the widget itself (doesn't propagate). QEvent event(QEvent::StyleChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } /*! @@ -1028,7 +1028,7 @@ void QGraphicsWidget::setFont(const QFont &font) By default, this property contains the application's default palette. - \sa QApplication::palette(), QGraphicsScene::palette, QPalette::resolve() + \sa QGuiApplication::palette(), QGraphicsScene::palette, QPalette::resolve() */ QPalette QGraphicsWidget::palette() const { @@ -1100,7 +1100,7 @@ void QGraphicsWidget::updateGeometry() // This is for custom layouting QGraphicsWidget *parentWid = parentWidget(); //### if (parentWid->isVisible()) - QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest)); } else { /** * If this is the topmost widget, post a LayoutRequest event to the widget. @@ -1108,7 +1108,7 @@ void QGraphicsWidget::updateGeometry() * widgets in one go. This will make a relayout flicker-free. */ if (QGraphicsLayout::instantInvalidatePropagation()) - QApplication::postEvent(static_cast(this), new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(static_cast(this), new QEvent(QEvent::LayoutRequest)); } if (!QGraphicsLayout::instantInvalidatePropagation()) { bool wasResized = testAttribute(Qt::WA_Resized); @@ -1145,14 +1145,14 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & case ItemEnabledHasChanged: { // Send EnabledChange after the enabled state has changed. QEvent event(QEvent::EnabledChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } case ItemVisibleChange: if (value.toBool()) { // Send Show event before the item has been shown. QShowEvent event; - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); bool resized = testAttribute(Qt::WA_Resized); if (!resized) { adjustSize(); @@ -1168,7 +1168,7 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & if (!value.toBool()) { // Send Hide event after the item has been hidden. QHideEvent event; - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } break; case ItemPositionHasChanged: @@ -1177,25 +1177,25 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant & case ItemParentChange: { // Deliver ParentAboutToChange. QEvent event(QEvent::ParentAboutToChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } case ItemParentHasChanged: { // Deliver ParentChange. QEvent event(QEvent::ParentChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } case ItemCursorHasChanged: { // Deliver CursorChange. QEvent event(QEvent::CursorChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } case ItemToolTipHasChanged: { // Deliver ToolTipChange. QEvent event(QEvent::ToolTipChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); break; } default: @@ -1930,7 +1930,7 @@ int QGraphicsWidget::grabShortcut(const QKeySequence &sequence, Qt::ShortcutCont if (sequence.isEmpty()) return 0; // ### setAttribute(Qt::WA_GrabbedShortcut); - return qApp->d_func()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher); + return QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence, context, qWidgetShortcutContextMatcher); } /*! @@ -1954,7 +1954,7 @@ void QGraphicsWidget::releaseShortcut(int id) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.removeShortcut(id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this, 0); } /*! @@ -1975,7 +1975,7 @@ void QGraphicsWidget::setShortcutEnabled(int id, bool enabled) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.setShortcutEnabled(enabled, id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enabled, id, this, 0); } /*! @@ -1990,7 +1990,7 @@ void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0); } #endif @@ -2068,7 +2068,7 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action) } QActionEvent e(QEvent::ActionAdded, action, before); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -2111,7 +2111,7 @@ void QGraphicsWidget::removeAction(QAction *action) if (d->actions.removeAll(action)) { QActionEvent e(QEvent::ActionRemoved, action); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } } @@ -2404,7 +2404,7 @@ QPainterPath QGraphicsWidget::shape() const bool QGraphicsWidget::close() { QCloseEvent closeEvent; - QApplication::sendEvent(this, &closeEvent); + QCoreApplication::sendEvent(this, &closeEvent); if (!closeEvent.isAccepted()) { return false; } diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index ce027c13195..cc08b1c5661 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -190,7 +190,7 @@ void QGraphicsWidgetPrivate::updatePalette(const QPalette &palette) // Notify change. QEvent event(QEvent::PaletteChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); } void QGraphicsWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) @@ -212,7 +212,7 @@ void QGraphicsWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direc // Send the notification event to this widget item. QEvent e(QEvent::LayoutDirectionChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } void QGraphicsWidgetPrivate::resolveLayoutDirection() @@ -226,9 +226,9 @@ void QGraphicsWidgetPrivate::resolveLayoutDirection() } else if (scene) { // ### shouldn't the scene have a layoutdirection really? how does // ### QGraphicsWidget get changes from QApplication::layoutDirection? - setLayoutDirection_helper(QApplication::layoutDirection()); + setLayoutDirection_helper(QGuiApplication::layoutDirection()); } else { - setLayoutDirection_helper(QApplication::layoutDirection()); + setLayoutDirection_helper(QGuiApplication::layoutDirection()); } } @@ -290,7 +290,7 @@ void QGraphicsWidgetPrivate::updateFont(const QFont &font) return; // Notify change. QEvent event(QEvent::FontChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); } QFont QGraphicsWidgetPrivate::naturalWidgetFont() const diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 1d1c144bb83..6ff0fe8132d 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -180,7 +180,7 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index QString statustip = model->data(index, Qt::StatusTipRole).toString(); if (parent && (shouldClearStatusTip || !statustip.isEmpty())) { QStatusTipEvent tip(statustip); - QApplication::sendEvent(parent, &tip); + QCoreApplication::sendEvent(parent, &tip); shouldClearStatusTip = !statustip.isEmpty(); } #endif @@ -189,7 +189,7 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index if (parent && shouldClearStatusTip) { QString emptyString; QStatusTipEvent tip( emptyString ); - QApplication::sendEvent(parent, &tip); + QCoreApplication::sendEvent(parent, &tip); } #endif emit q->viewportEntered(); @@ -521,7 +521,7 @@ void QAbstractItemViewPrivate::_q_scrollerStateChanged() the mouse was pressed on is specified by \a index. The signal is only emitted when the index is valid. - Use the QApplication::mouseButtons() function to get the state + Use the QGuiApplication::mouseButtons() function to get the state of the mouse buttons. \sa activated(), clicked(), doubleClicked(), entered() @@ -1713,7 +1713,7 @@ bool QAbstractItemView::viewportEvent(QEvent *event) if (d->shouldClearStatusTip && d->parent) { QString empty; QStatusTipEvent tip(empty); - QApplication::sendEvent(d->parent, &tip); + QCoreApplication::sendEvent(d->parent, &tip); d->shouldClearStatusTip = false; } #endif @@ -2338,7 +2338,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) if (d->model) variant = d->model->data(currentIndex(), Qt::DisplayRole); if (variant.type() == QVariant::String) - QApplication::clipboard()->setText(variant.toString()); + QGuiApplication::clipboard()->setText(variant.toString()); event->accept(); } #endif @@ -2845,7 +2845,7 @@ void QAbstractItemView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndE } QPointer ed = editor; - QApplication::sendPostedEvents(editor, 0); + QCoreApplication::sendPostedEvents(editor, 0); editor = ed; if (!isPersistent && editor) @@ -3957,7 +3957,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QM keyModifiers = (static_cast(event))->modifiers(); break; default: - keyModifiers = QApplication::keyboardModifiers(); + keyModifiers = QGuiApplication::keyboardModifiers(); } } switch (d->selectionMode) { @@ -4015,7 +4015,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::multiSelectionComm QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionCommand( const QModelIndex &index, const QEvent *event) const { - Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers(); + Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers(); if (event) { switch (event->type()) { case QEvent::MouseMove: { @@ -4425,7 +4425,7 @@ bool QAbstractItemViewPrivate::openEditor(const QModelIndex &index, QEvent *even w->setFocus(); if (event) - QApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event); + QCoreApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event); return true; } diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index b94c31fb426..13a1bbd8eb9 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1086,7 +1086,7 @@ QString QDirModel::filePath(const QModelIndex &index) const if (d->indexValid(index)) { QFileInfo fi = fileInfo(index); if (d->resolveSymlinks && fi.isSymLink()) - fi = d->resolvedInfo(fi); + fi = QDirModelPrivate::resolvedInfo(fi); return QDir::cleanPath(fi.absoluteFilePath()); } return QString(); // root path @@ -1108,7 +1108,7 @@ QString QDirModel::fileName(const QModelIndex &index) const if (QFileSystemEntry::isRootPath(path)) return path; if (d->resolveSymlinks && info.isSymLink()) - info = d->resolvedInfo(info); + info = QDirModelPrivate::resolvedInfo(info); return info.fileName(); } diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 1fcd5bdef2e..be80843b073 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2896,7 +2896,7 @@ bool QHeaderView::viewportEvent(QEvent *e) case QEvent::Wheel: { QAbstractScrollArea *asa = qobject_cast(parentWidget()); if (asa) - return QApplication::sendEvent(asa->viewport(), e); + return QCoreApplication::sendEvent(asa->viewport(), e); break; } default: break; diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 641b15f85b7..25facd1484a 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -821,13 +821,13 @@ void QListView::wheelEvent(QWheelEvent *e) if (e->spontaneous()) qt_sendSpontaneousEvent(d->hbar, &hwe); else - QApplication::sendEvent(d->hbar, &hwe); + QCoreApplication::sendEvent(d->hbar, &hwe); e->setAccepted(hwe.isAccepted()); } else { - QApplication::sendEvent(d->vbar, e); + QCoreApplication::sendEvent(d->vbar, e); } } else { - QApplication::sendEvent(d->hbar, e); + QCoreApplication::sendEvent(d->hbar, e); } } #endif // QT_CONFIG(wheelevent) diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index f6631199d6d..47e91bf8f96 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -47,15 +47,15 @@ #include "qlist.h" #include "qstylehints.h" #include -#include +#include #if QT_CONFIG(menu) #include #endif #include #define QAPP_CHECK(functionName) \ - if (Q_UNLIKELY(!qApp)) { \ - qWarning("QAction: Initialize QApplication before calling '" functionName "'."); \ + if (Q_UNLIKELY(!QCoreApplication::instance())) { \ + qWarning("QAction: Initialize Q(Gui)Application before calling '" functionName "'."); \ return; \ } @@ -101,7 +101,7 @@ bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) #else if(QObject *object = widget ? widget : parent) { QStatusTipEvent tip(str); - QApplication::sendEvent(object, &tip); + QCoreApplication::sendEvent(object, &tip); return true; } #endif @@ -114,15 +114,15 @@ void QActionPrivate::sendDataChanged() QActionEvent e(QEvent::ActionChanged, q); for (int i = 0; i < widgets.size(); ++i) { QWidget *w = widgets.at(i); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } #if QT_CONFIG(graphicsview) for (int i = 0; i < graphicsWidgets.size(); ++i) { QGraphicsWidget *w = graphicsWidgets.at(i); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } #endif - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); emit q->changed(); } @@ -391,7 +391,7 @@ void QAction::setShortcut(const QKeySequence &shortcut) return; d->shortcut = shortcut; - d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); d->sendDataChanged(); } @@ -420,8 +420,8 @@ void QAction::setShortcuts(const QList &shortcuts) d->shortcut = primary; d->alternateShortcuts = listCopy; - d->redoGrab(qApp->d_func()->shortcutMap); - d->redoGrabAlternate(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); + d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap); d->sendDataChanged(); } @@ -485,8 +485,8 @@ void QAction::setShortcutContext(Qt::ShortcutContext context) return; QAPP_CHECK("setShortcutContext"); d->shortcutContext = context; - d->redoGrab(qApp->d_func()->shortcutMap); - d->redoGrabAlternate(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); + d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap); d->sendDataChanged(); } @@ -513,8 +513,8 @@ void QAction::setAutoRepeat(bool on) return; QAPP_CHECK("setAutoRepeat"); d->autorepeat = on; - d->redoGrab(qApp->d_func()->shortcutMap); - d->redoGrabAlternate(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); + d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap); d->sendDataChanged(); } @@ -575,10 +575,10 @@ QAction::~QAction() d->group->removeAction(this); #ifndef QT_NO_SHORTCUT if (d->shortcutId && qApp) { - qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(d->shortcutId, this); for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { const int id = d->alternateShortcutIds.at(i); - qApp->d_func()->shortcutMap.removeShortcut(id, this); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this); } } #endif @@ -1028,7 +1028,7 @@ void QAction::setEnabled(bool b) QAPP_CHECK("setEnabled"); d->enabled = b; #ifndef QT_NO_SHORTCUT - d->setShortcutEnabled(b, qApp->d_func()->shortcutMap); + d->setShortcutEnabled(b, QGuiApplicationPrivate::instance()->shortcutMap); #endif d->sendDataChanged(); } @@ -1061,8 +1061,8 @@ void QAction::setVisible(bool b) d->forceInvisible = !b; d->visible = b; d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ; -#ifndef QT_NO_SHORTCUT - d->setShortcutEnabled(d->enabled, qApp->d_func()->shortcutMap); +#if QT_CONFIG(shortcut) + d->setShortcutEnabled(d->enabled, QGuiApplicationPrivate::instance()->shortcutMap); #endif d->sendDataChanged(); } @@ -1285,7 +1285,7 @@ void QAction::setIconVisibleInMenu(bool visible) d->iconVisibleInMenu = visible; // Only send data changed if we really need to. if (oldValue != -1 - || visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus)) { + || visible == !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus)) { d->sendDataChanged(); } } @@ -1295,7 +1295,7 @@ bool QAction::isIconVisibleInMenu() const { Q_D(const QAction); if (d->iconVisibleInMenu == -1) { - return !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus); + return !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus); } return d->iconVisibleInMenu; } @@ -1323,7 +1323,7 @@ void QAction::setShortcutVisibleInContextMenu(bool visible) d->shortcutVisibleInContextMenu = visible; // Only send data changed if we really need to. if (oldValue != -1 - || visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowShortcutsInContextMenus)) { + || visible == !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus)) { d->sendDataChanged(); } } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 526bf0a0ff6..22ebeaae51b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -622,7 +622,7 @@ void QApplicationPrivate::initialize() if (qt_is_gui_used) initializeMultitouch(); - if (QApplication::desktopSettingsAware()) + if (QGuiApplication::desktopSettingsAware()) if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt(); } @@ -1172,7 +1172,7 @@ void QApplication::setStyle(QStyle *style) QWidget *w = *it; if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) { QEvent e(QEvent::StyleChange); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); w->update(); } } @@ -1189,7 +1189,7 @@ void QApplication::setStyle(QStyle *style) if (QApplicationPrivate::focus_widget) { QFocusEvent in(QEvent::FocusIn, Qt::OtherFocusReason); - QApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in); + QCoreApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in); QApplicationPrivate::focus_widget->update(); } } @@ -1551,7 +1551,7 @@ void QApplication::setFont(const QFont &font, const char *className) if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { // Send ApplicationFontChange to qApp itself, and to the widgets. QEvent e(QEvent::ApplicationFontChange); - QApplication::sendEvent(QApplication::instance(), &e); + QCoreApplication::sendEvent(QApplication::instance(), &e); QWidgetList wids = QApplication::allWidgets(); for (QWidgetList::ConstIterator it = wids.constBegin(), cend = wids.constEnd(); it != cend; ++it) { @@ -1565,7 +1565,7 @@ void QApplication::setFont(const QFont &font, const char *className) QList &scenes = qApp->d_func()->scene_list; for (QList::ConstIterator it = scenes.constBegin(); it != scenes.constEnd(); ++it) { - QApplication::sendEvent(*it, &e); + QCoreApplication::sendEvent(*it, &e); } #endif // QT_CONFIG(graphicsview) } @@ -1739,16 +1739,16 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) #endif QFocusEvent out(QEvent::FocusOut, reason); QPointer that = prev; - QApplication::sendEvent(prev, &out); + QCoreApplication::sendEvent(prev, &out); if (that) - QApplication::sendEvent(that->style(), &out); + QCoreApplication::sendEvent(that->style(), &out); } if(focus && QApplicationPrivate::focus_widget == focus) { QFocusEvent in(QEvent::FocusIn, reason); QPointer that = focus; - QApplication::sendEvent(focus, &in); + QCoreApplication::sendEvent(focus, &in); if (that) - QApplication::sendEvent(that->style(), &in); + QCoreApplication::sendEvent(that->style(), &in); } emit qApp->focusChanged(prev, focus_widget); } @@ -1924,7 +1924,7 @@ bool QApplication::event(QEvent *e) } if (showToolTip) { QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos); - QApplication::sendEvent(d->toolTipWidget, &e); + QCoreApplication::sendEvent(d->toolTipWidget, &e); if (e.isAccepted()) { QStyle *s = d->toolTipWidget->style(); int sleepDelay = s->styleHint(QStyle::SH_ToolTip_FallAsleepDelay, 0, d->toolTipWidget, 0); @@ -2036,7 +2036,7 @@ void QApplication::setActiveWindow(QWidget* act) QGuiApplication::inputMethod()->commit(); QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason); - QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); + QCoreApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); } QApplicationPrivate::active_window = window; @@ -2111,7 +2111,7 @@ QWidget *qt_tlw_for_window(QWindow *wnd) wnd = wnd->parent(); } if (wnd) { - const auto tlws = qApp->topLevelWidgets(); + const auto tlws = QApplication::topLevelWidgets(); for (QWidget *tlw : tlws) { if (tlw->windowHandle() == wnd) return tlw; @@ -2205,12 +2205,12 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con #if 0 if (leave) { QEvent e(QEvent::Leave); - QApplication::sendEvent(leave, & e); + QCoreApplication::sendEvent(leave, & e); } if (enter) { const QPoint windowPos = enter->window()->mapFromGlobal(globalPos); QEnterEvent e(enter->mapFromGlobal(globalPos), windowPos, globalPos); - QApplication::sendEvent(enter, & e); + QCoreApplication::sendEvent(enter, & e); } return; #endif @@ -2271,12 +2271,12 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con for (int i = 0; i < leaveList.size(); ++i) { auto *w = leaveList.at(i); if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { - QApplication::sendEvent(w, &leaveEvent); + QCoreApplication::sendEvent(w, &leaveEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { Q_ASSERT(instance()); QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos), - QApplication::keyboardModifiers()); + QGuiApplication::keyboardModifiers()); qApp->d_func()->notify_helper(w, &he); } } @@ -2292,11 +2292,11 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { const QPointF localPos = w->mapFromGlobal(globalPos); QEnterEvent enterEvent(localPos, windowPos, globalPosF); - QApplication::sendEvent(w, &enterEvent); + QCoreApplication::sendEvent(w, &enterEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { QHoverEvent he(QEvent::HoverEnter, localPos, QPoint(-1, -1), - QApplication::keyboardModifiers()); + QGuiApplication::keyboardModifiers()); qApp->d_func()->notify_helper(w, &he); } } @@ -2644,7 +2644,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, if (spontaneous) result = QApplication::sendSpontaneousEvent(receiver, event); else - result = QApplication::sendEvent(receiver, event); + result = QCoreApplication::sendEvent(receiver, event); } if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease @@ -2898,7 +2898,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } #ifndef QT_NO_DEBUG - d->checkReceiverThread(receiver); + QCoreApplicationPrivate::checkReceiverThread(receiver); #endif if (receiver->isWindowType()) { @@ -3818,7 +3818,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) } else if (popupWidgets->count() == 1) { // this was the first popup if (QWidget *fw = QApplication::focusWidget()) { QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); - QApplication::sendEvent(fw, &e); + QCoreApplication::sendEvent(fw, &e); } } } @@ -4383,7 +4383,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, QTouchEvent touchEvent(eventType, device, - QApplication::keyboardModifiers(), + QGuiApplication::keyboardModifiers(), it.value().first, it.value().second); bool containsPress = updateTouchPointsForWidget(widget, &touchEvent); @@ -4426,7 +4426,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong timestamp) { - QTouchEvent touchEvent(QEvent::TouchCancel, device, QApplication::keyboardModifiers()); + QTouchEvent touchEvent(QEvent::TouchCancel, device, QGuiApplication::keyboardModifiers()); touchEvent.setTimestamp(timestamp); QHash::const_iterator it = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd(); @@ -4462,12 +4462,12 @@ void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const const QWidgetList widgets = QApplication::allWidgets(); for (auto widget : widgets) { if (toAllWidgets || (!className && widget->isWindow()) || (className && widget->inherits(className))) - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); } #if QT_CONFIG(graphicsview) for (auto scene : qAsConst(scene_list)) - QApplication::sendEvent(scene, &event); + QCoreApplication::sendEvent(scene, &event); #endif // QT_CONFIG(graphicsview) } diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index a368f379ada..76d8533271b 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -172,7 +172,7 @@ void QBoxLayoutPrivate::effectiveMargins(int *left, int *top, int *right, int *b rightDelta = w->geometry().right() - itm->geometry().right(); } QWidget *w = q->parentWidget(); - Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QApplication::layoutDirection(); + Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QGuiApplication::layoutDirection(); if (layoutDirection == Qt::RightToLeft) qSwap(leftDelta, rightDelta); diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 9146ba84c84..6f7527c0138 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -2178,7 +2178,7 @@ void QFormLayoutPrivate::arrangeWidgets(const QVector& layouts, Q int i; const int rr = m_matrix.rowCount(); QWidget *w = q->parentWidget(); - Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QApplication::layoutDirection(); + Qt::LayoutDirection layoutDirection = w ? w->layoutDirection() : QGuiApplication::layoutDirection(); Qt::Alignment formAlignment = fixedAlignment(q->formAlignment(), layoutDirection); int leftOffset = 0; diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index ff7bc1eccf3..1555c2a73a7 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -707,7 +707,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, foreach(QGesture *g, gestures) event.setAccepted(g, false); - QApplication::sendEvent(receiver, &event); + QCoreApplication::sendEvent(receiver, &event); bool eventAccepted = event.isAccepted(); const auto eventGestures = event.gestures(); for (QGesture *gesture : eventGestures) { @@ -734,7 +734,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, qCDebug(lcGestureManager) << "QGestureManager::deliverEvents: sending to" << it.key() << "gestures:" << it.value(); QGestureEvent event(it.value()); - QApplication::sendEvent(it.key(), &event); + QCoreApplication::sendEvent(it.key(), &event); bool eventAccepted = event.isAccepted(); const auto eventGestures = event.gestures(); for (QGesture *gesture : eventGestures) { diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index f71d038a5fa..3ce81a390bc 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1040,7 +1040,7 @@ void QLayout::update() if (layout->d_func()->topLevel) { Q_ASSERT(layout->parent()->isWidgetType()); QWidget *mw = static_cast(layout->parent()); - QApplication::postEvent(mw, new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(mw, new QEvent(QEvent::LayoutRequest)); break; } layout = static_cast(layout->parent()); @@ -1366,7 +1366,7 @@ QRect QLayout::alignmentRect(const QRect &r) const y += (r.height() - s.height()) / 2; QWidget *parent = parentWidget(); - a = QStyle::visualAlignment(parent ? parent->layoutDirection() : QApplication::layoutDirection(), a); + a = QStyle::visualAlignment(parent ? parent->layoutDirection() : QGuiApplication::layoutDirection(), a); if (a & Qt::AlignRight) x += (r.width() - s.width()); else if (!(a & Qt::AlignLeft)) diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index ae7729b49b5..451b18d8d3b 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -1432,7 +1432,7 @@ bool QOpenGLWidget::event(QEvent *e) Q_D(QOpenGLWidget); switch (e->type()) { case QEvent::WindowChangeInternal: - if (qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) + if (QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) break; if (d->initialized) d->reset(); @@ -1445,7 +1445,7 @@ bool QOpenGLWidget::event(QEvent *e) { // Special case: did grabFramebuffer() for a hidden widget that then became visible. // Recreate all resources since the context now needs to share with the TLW's. - if (!qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) + if (!QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) d->reset(); } if (!d->initialized && !size().isEmpty() && window()->windowHandle()) { diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index a680ff79130..c7b9f3ec7ae 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -228,7 +228,7 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW { bool visible = w->isVisible(); #if defined(Q_OS_DARWIN) && QT_CONFIG(menubar) - if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast(w)) + if (!QCoreApplication::testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast(w)) visible = true; #endif @@ -488,7 +488,7 @@ QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, Q_D(QShortcut); d->sc_context = context; d->sc_sequence = key; - d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); if (member) connect(this, SIGNAL(activated()), parent, member); if (ambiguousMember) @@ -502,7 +502,7 @@ QShortcut::~QShortcut() { Q_D(QShortcut); if (qApp) - qApp->d_func()->shortcutMap.removeShortcut(d->sc_id, this); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(d->sc_id, this); } /*! @@ -523,7 +523,7 @@ void QShortcut::setKey(const QKeySequence &key) return; QAPP_CHECK("setKey"); d->sc_sequence = key; - d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); } QKeySequence QShortcut::key() const @@ -554,7 +554,7 @@ void QShortcut::setEnabled(bool enable) return; QAPP_CHECK("setEnabled"); d->sc_enabled = enable; - qApp->d_func()->shortcutMap.setShortcutEnabled(enable, d->sc_id, this); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enable, d->sc_id, this); } bool QShortcut::isEnabled() const @@ -582,7 +582,7 @@ void QShortcut::setContext(Qt::ShortcutContext context) return; QAPP_CHECK("setContext"); d->sc_context = context; - d->redoGrab(qApp->d_func()->shortcutMap); + d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); } Qt::ShortcutContext QShortcut::context() const @@ -634,7 +634,7 @@ void QShortcut::setAutoRepeat(bool on) return; QAPP_CHECK("setAutoRepeat"); d->sc_autorepeat = on; - qApp->d_func()->shortcutMap.setShortcutAutoRepeat(on, d->sc_id, this); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(on, d->sc_id, this); } bool QShortcut::autoRepeat() const diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 4a798a74908..a48eae6628e 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -263,7 +263,7 @@ void QWhatsThat::mouseReleaseEvent(QMouseEvent* e) anchor.clear(); if (!href.isEmpty()) { QWhatsThisClickedEvent e(href); - if (QApplication::sendEvent(widget, &e)) + if (QCoreApplication::sendEvent(widget, &e)) return; } } @@ -380,7 +380,7 @@ void QWhatsThisPrivate::notifyToplevels(QEvent *e) { const QWidgetList toplevels = QApplication::topLevelWidgets(); for (auto *w : toplevels) - QApplication::sendEvent(w, e); + QCoreApplication::sendEvent(w, e); } QWhatsThisPrivate *QWhatsThisPrivate::instance = 0; @@ -394,7 +394,7 @@ QWhatsThisPrivate::QWhatsThisPrivate() QPoint pos = QCursor::pos(); if (QWidget *w = QApplication::widgetAt(pos)) { QHelpEvent e(QEvent::QueryWhatsThis, w->mapFromGlobal(pos), pos); - bool sentEvent = QApplication::sendEvent(w, &e); + const bool sentEvent = QCoreApplication::sendEvent(w, &e); #ifdef QT_NO_CURSOR Q_UNUSED(sentEvent); #else @@ -439,7 +439,7 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e) if (me->button() == Qt::RightButton || customWhatsThis) return false; QHelpEvent e(QEvent::WhatsThis, me->pos(), me->globalPos()); - if (!QApplication::sendEvent(w, &e) || !e.isAccepted()) + if (!QCoreApplication::sendEvent(w, &e) || !e.isAccepted()) leaveOnMouseRelease = true; } break; @@ -448,12 +448,12 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e) { QMouseEvent *me = static_cast(e); QHelpEvent e(QEvent::QueryWhatsThis, me->pos(), me->globalPos()); - bool sentEvent = QApplication::sendEvent(w, &e); + const bool sentEvent = QCoreApplication::sendEvent(w, &e); #ifdef QT_NO_CURSOR Q_UNUSED(sentEvent); #else - QApplication::changeOverrideCursor((!sentEvent || !e.isAccepted())? - Qt::ForbiddenCursor:Qt::WhatsThisCursor); + QGuiApplication::changeOverrideCursor((!sentEvent || !e.isAccepted())? + Qt::ForbiddenCursor:Qt::WhatsThisCursor); #endif Q_FALLTHROUGH(); } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 2176c612d03..f686341f6ef 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -359,7 +359,7 @@ void QWidgetPrivate::scrollChildren(int dx, int dy) w->d_func()->setWSGeometry(); w->d_func()->setDirtyOpaqueRegion(); QMoveEvent e(r.topLeft(), oldp); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } } } @@ -435,13 +435,13 @@ void QWidget::setEditFocus(bool on) if (!on && QWidgetPrivate::editingWidget == f) { QWidgetPrivate::editingWidget = 0; QEvent event(QEvent::LeaveEditFocus); - QApplication::sendEvent(f, &event); - QApplication::sendEvent(f->style(), &event); + QCoreApplication::sendEvent(f, &event); + QCoreApplication::sendEvent(f->style(), &event); } else if (on) { QWidgetPrivate::editingWidget = f; QEvent event(QEvent::EnterEditFocus); - QApplication::sendEvent(f, &event); - QApplication::sendEvent(f->style(), &event); + QCoreApplication::sendEvent(f, &event); + QCoreApplication::sendEvent(f->style(), &event); } } #endif @@ -1223,8 +1223,8 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) q->create(); QEvent e(QEvent::Create); - QApplication::sendEvent(q, &e); - QApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); + QCoreApplication::sendEvent(q, &e); + QCoreApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); extraPaintEngine = 0; @@ -1624,7 +1624,7 @@ QWidget::~QWidget() // Remove all shortcuts grabbed by this // widget, unless application is closing if (!QApplicationPrivate::is_app_closing && testAttribute(Qt::WA_GrabbedShortcut)) - qApp->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence()); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(0, this, QKeySequence()); #endif // delete layout while we still are a valid widget @@ -1732,7 +1732,7 @@ QWidget::~QWidget() if (!d->children.isEmpty()) d->deleteChildren(); - QApplication::removePostedEvents(this); + QCoreApplication::removePostedEvents(this); QT_TRY { destroy(); // platform-dependent cleanup @@ -2044,7 +2044,7 @@ void QWidgetPrivate::propagatePaletteChange() QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); QEvent pc(QEvent::PaletteChange); - QApplication::sendEvent(q, &pc); + QCoreApplication::sendEvent(q, &pc); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast(children.at(i)); if (w && (!w->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) @@ -2848,7 +2848,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate) #endif QEvent e(QEvent::StyleChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); #ifndef QT_NO_STYLE_STYLESHEET // dereference the old stylesheet style @@ -3066,7 +3066,7 @@ void QWidget::overrideWindowState(Qt::WindowStates newstate) { QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true); data->window_state = newstate; - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -3128,7 +3128,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) activateWindow(); QWindowStateChangeEvent e(oldstate); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -3354,7 +3354,7 @@ void QWidget::insertAction(QAction *before, QAction *action) apriv->widgets.append(this); QActionEvent e(QEvent::ActionAdded, action, before); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } /*! @@ -3392,7 +3392,7 @@ void QWidget::removeAction(QAction *action) if (d->actions.removeAll(action)) { QActionEvent e(QEvent::ActionRemoved, action); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } } @@ -3499,7 +3499,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable) } #endif //QT_NO_IM QEvent e(QEvent::EnabledChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } /*! @@ -4566,7 +4566,7 @@ void QWidget::setForegroundRole(QPalette::ColorRole role) the "color", "background-color", "selection-color", "selection-background-color" and "alternate-background-color". - \sa QApplication::palette(), QWidget::font(), {Qt Style Sheets} + \sa QGuiApplication::palette(), QWidget::font(), {Qt Style Sheets} */ const QPalette &QWidget::palette() const { @@ -4629,7 +4629,7 @@ QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const )) { if (QWidget *p = q->parentWidget()) { if (!p->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) { - if (!naturalPalette.isCopyOf(QApplication::palette())) { + if (!naturalPalette.isCopyOf(QGuiApplication::palette())) { QPalette inheritedPalette = p->palette(); inheritedPalette.resolve(inheritedMask); naturalPalette = inheritedPalette.resolve(naturalPalette); @@ -4895,7 +4895,7 @@ void QWidgetPrivate::updateFont(const QFont &font) #endif QEvent e(QEvent::FontChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) @@ -4913,14 +4913,14 @@ void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction) } } QEvent e(QEvent::LayoutDirectionChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } void QWidgetPrivate::resolveLayoutDirection() { Q_Q(const QWidget); if (!q->testAttribute(Qt::WA_SetLayoutDirection)) - setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection()); + setLayoutDirection_helper(q->isWindow() ? QGuiApplication::layoutDirection() : q->parentWidget()->layoutDirection()); } /*! @@ -5040,7 +5040,7 @@ void QWidget::setCursor(const QCursor &cursor) d->setCursor_sys(cursor); QEvent event(QEvent::CursorChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } void QWidgetPrivate::setCursor_sys(const QCursor &cursor) @@ -5062,7 +5062,7 @@ void QWidget::unsetCursor() d->unsetCursor_sys(); QEvent event(QEvent::CursorChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } void QWidgetPrivate::unsetCursor_sys() @@ -5260,7 +5260,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, static void sendResizeEvents(QWidget *target) { QResizeEvent e(target->size(), QSize()); - QApplication::sendEvent(target, &e); + QCoreApplication::sendEvent(target, &e); const QObjectList children = target->children(); for (int i = 0; i < children.size(); ++i) { @@ -6014,7 +6014,7 @@ void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate) } } QEvent e(QEvent::LocaleChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } void QWidget::setLocale(const QLocale &locale) @@ -6189,7 +6189,7 @@ void QWidget::setWindowIconText(const QString &iconText) d->setWindowIconText_helper(iconText); QEvent e(QEvent::IconTextChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); emit windowIconTextChanged(iconText); } @@ -6213,7 +6213,7 @@ void QWidget::setWindowTitle(const QString &title) d->setWindowTitle_helper(title); QEvent e(QEvent::WindowTitleChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); emit windowTitleChanged(title); } @@ -6251,11 +6251,11 @@ void QWidgetPrivate::setWindowIcon_helper() // QWidgetWindow to the top level QWidget ensures that the event reaches // the top level anyhow if (!q->windowHandle()) - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast(children.at(i)); if (w && !w->isWindow()) - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } } @@ -6598,7 +6598,7 @@ void QWidget::setFocus(Qt::FocusReason reason) if (reason != Qt::NoFocusReason) { QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, reason); - QApplication::sendEvent(prev, &focusAboutToChange); + QCoreApplication::sendEvent(prev, &focusAboutToChange); } } @@ -6625,9 +6625,9 @@ void QWidget::setFocus(Qt::FocusReason reason) // Send event to self QFocusEvent event(QEvent::FocusOut, reason); QPointer that = previousProxyFocus; - QApplication::sendEvent(previousProxyFocus, &event); + QCoreApplication::sendEvent(previousProxyFocus, &event); if (that) - QApplication::sendEvent(that->style(), &event); + QCoreApplication::sendEvent(that->style(), &event); } if (!isHidden()) { #if QT_CONFIG(graphicsview) @@ -6639,9 +6639,9 @@ void QWidget::setFocus(Qt::FocusReason reason) // Send event to self QFocusEvent event(QEvent::FocusIn, reason); QPointer that = f; - QApplication::sendEvent(f, &event); + QCoreApplication::sendEvent(f, &event); if (that) - QApplication::sendEvent(that->style(), &event); + QCoreApplication::sendEvent(that->style(), &event); } } } @@ -6748,7 +6748,7 @@ void QWidget::clearFocus() QGuiApplication::inputMethod()->commit(); QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); - QApplication::sendEvent(this, &focusAboutToChange); + QCoreApplication::sendEvent(this, &focusAboutToChange); } QWidget *w = this; @@ -7395,11 +7395,11 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) if (isMove) { QMoveEvent e(q->pos(), oldPos); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } if (isResize) { QResizeEvent e(r.size(), olds); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); if (q->windowHandle()) q->update(); } @@ -7697,13 +7697,13 @@ void QWidgetPrivate::updateContentsRect() if (q->isVisible()) { q->update(); QResizeEvent e(q->data->crect.size(), q->data->crect.size()); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } else { q->setAttribute(Qt::WA_PendingResizeEvent, true); } QEvent e(QEvent::ContentsRectChange); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); } /*! @@ -7999,13 +7999,13 @@ void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disable if (q->testAttribute(Qt::WA_PendingMoveEvent)) { QMoveEvent e(data.crect.topLeft(), data.crect.topLeft()); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); q->setAttribute(Qt::WA_PendingMoveEvent, false); } if (q->testAttribute(Qt::WA_PendingResizeEvent)) { QResizeEvent e(data.crect.size(), QSize()); - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); q->setAttribute(Qt::WA_PendingResizeEvent, false); } @@ -8115,7 +8115,7 @@ void QWidgetPrivate::show_helper() // send the show event before showing the window QShowEvent showEvent; - QApplication::sendEvent(q, &showEvent); + QCoreApplication::sendEvent(q, &showEvent); show_sys(); @@ -8138,7 +8138,7 @@ void QWidgetPrivate::show_helper() // is spinnning; otherwise it might not show up on particular platforms. // This makes QSplashScreen behave the same on all platforms. if (!qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen) - QApplication::processEvents(); + QCoreApplication::processEvents(); data.in_show = false; // reset qws optimization } @@ -8164,9 +8164,9 @@ void QWidgetPrivate::show_sys() } if (renderToTexture && !q->isWindow()) - QApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); + QCoreApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); else - QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); + QCoreApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow)) || q->testAttribute(Qt::WA_OutsideWSRange)) { @@ -8254,7 +8254,7 @@ void QWidgetPrivate::hide_helper() } QHideEvent hideEvent; - QApplication::sendEvent(q, &hideEvent); + QCoreApplication::sendEvent(q, &hideEvent); hideChildren(false); // next bit tries to move the focus if the focus widget is now @@ -8425,7 +8425,7 @@ void QWidgetPrivate::setVisible(bool visible) } QEvent showToParentEvent(QEvent::ShowToParent); - QApplication::sendEvent(q, &showToParentEvent); + QCoreApplication::sendEvent(q, &showToParentEvent); } else { // hide #if 0 // Used to be included in Qt4 for Q_WS_WIN // reset WS_DISABLED style in a Blocked window @@ -8456,11 +8456,11 @@ void QWidgetPrivate::setVisible(bool visible) if (q->parentWidget()->d_func()->layout) q->parentWidget()->d_func()->layout->invalidate(); else if (q->parentWidget()->isVisible()) - QApplication::postEvent(q->parentWidget(), new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(q->parentWidget(), new QEvent(QEvent::LayoutRequest)); } QEvent hideToParentEvent(QEvent::HideToParent); - QApplication::sendEvent(q, &hideToParentEvent); + QCoreApplication::sendEvent(q, &hideToParentEvent); } } @@ -8535,7 +8535,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous) if (spontaneous) { QApplication::sendSpontaneousEvent(widget, &e); } else { - QApplication::sendEvent(widget, &e); + QCoreApplication::sendEvent(widget, &e); if (widget->internalWinId() && widget->testAttribute(Qt::WA_DontCreateNativeAncestors)) { // hide_sys() on an ancestor won't have any affect on this @@ -8570,7 +8570,7 @@ bool QWidgetPrivate::close_helper(CloseMode mode) if (mode == CloseWithSpontaneousEvent) QApplication::sendSpontaneousEvent(q, &e); else - QApplication::sendEvent(q, &e); + QCoreApplication::sendEvent(q, &e); if (!that.isNull() && !e.isAccepted()) { data.is_closing = 0; return false; @@ -9085,7 +9085,7 @@ bool QWidget::event(QEvent *event) setAttribute(Qt::WA_WState_Polished); if (!QApplication::font(this).isCopyOf(QApplication::font())) d->resolveFont(); - if (!QApplication::palette(this).isCopyOf(QApplication::palette())) + if (!QApplication::palette(this).isCopyOf(QGuiApplication::palette())) d->resolvePalette(); } break; @@ -9109,7 +9109,7 @@ bool QWidget::event(QEvent *event) #if QT_CONFIG(statustip) if (d->statusTip.size()) { QStatusTipEvent tip(d->statusTip); - QApplication::sendEvent(const_cast(this), &tip); + QCoreApplication::sendEvent(const_cast(this), &tip); } #endif enterEvent(event); @@ -9120,7 +9120,7 @@ bool QWidget::event(QEvent *event) if (d->statusTip.size()) { QString empty; QStatusTipEvent tip(empty); - QApplication::sendEvent(const_cast(this), &tip); + QCoreApplication::sendEvent(const_cast(this), &tip); } #endif leaveEvent(event); @@ -9271,7 +9271,7 @@ bool QWidget::event(QEvent *event) for (int i = 0; i < childList.size(); ++i) { QWidget *w = qobject_cast(childList.at(i)); if (w && w->isVisible() && !w->isWindow()) - QApplication::sendEvent(w, event); + QCoreApplication::sendEvent(w, event); } break; } @@ -9282,7 +9282,7 @@ bool QWidget::event(QEvent *event) for (int i = 0; i < childList.size(); ++i) { QObject *o = childList.at(i); if (o) - QApplication::sendEvent(o, event); + QCoreApplication::sendEvent(o, event); } } update(); @@ -9321,7 +9321,7 @@ bool QWidget::event(QEvent *event) QWidget *w = static_cast(o); // do not forward the event to child windows; QApplication does this for us if (!w->isWindow()) - QApplication::sendEvent(w, event); + QCoreApplication::sendEvent(w, event); } } } @@ -9373,7 +9373,7 @@ bool QWidget::event(QEvent *event) for (int i = 0; i < childList.size(); ++i) { QWidget *w = qobject_cast(childList.at(i)); if (w && w->isVisible() && !w->isWindow()) - QApplication::sendEvent(w, event); + QCoreApplication::sendEvent(w, event); } break; } @@ -9482,8 +9482,8 @@ void QWidget::changeEvent(QEvent * event) break; case QEvent::ThemeChange: - if (QApplication::desktopSettingsAware() && windowType() != Qt::Desktop - && qApp && !QApplication::closingDown()) { + if (QGuiApplication::desktopSettingsAware() && windowType() != Qt::Desktop + && qApp && !QCoreApplication::closingDown()) { if (testAttribute(Qt::WA_WState_Polished)) QApplication::style()->unpolish(this); if (testAttribute(Qt::WA_WState_Polished)) @@ -10550,7 +10550,7 @@ void QWidgetPrivate::updateGeometry_helper(bool forceUpdate) if (parent->d_func()->layout) parent->d_func()->layout->invalidate(); else if (parent->isVisible()) - QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); + QCoreApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest)); } } } @@ -10704,7 +10704,7 @@ static void sendWindowChangeToTextureChildrenRecursively(QWidget *widget) QWidgetPrivate *d = QWidgetPrivate::get(widget); if (d->renderToTexture) { QEvent e(QEvent::WindowChangeInternal); - QApplication::sendEvent(widget, &e); + QCoreApplication::sendEvent(widget, &e); } for (int i = 0; i < d->children.size(); ++i) { @@ -10753,7 +10753,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; if (newParent && parent && !desktopWidget) { - if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) + if (testAttribute(Qt::WA_NativeWindow) && !QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) parent->d_func()->enforceNativeChildren(); else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen)) setAttribute(Qt::WA_NativeWindow); @@ -10766,7 +10766,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) } if (newParent) { QEvent e(QEvent::ParentAboutToChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } } if (newParent && isAncestorOf(focusWidget())) @@ -10839,7 +10839,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) // send and post remaining QObject events if (parent && d->sendChildEvents) { QChildEvent e(QEvent::ChildAdded, this); - QApplication::sendEvent(parent, &e); + QCoreApplication::sendEvent(parent, &e); } //### already hidden above ---> must probably do something smart on the mac @@ -10857,7 +10857,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) } QEvent e(QEvent::ParentChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } #ifndef QT_NO_OPENGL //renderToTexture widgets also need to know when their top-level window changes @@ -11220,7 +11220,7 @@ void QWidgetPrivate::update(T r) return; if (q->testAttribute(Qt::WA_WState_InPaintEvent)) { - QApplication::postEvent(q, new QUpdateLaterEvent(clipped)); + QCoreApplication::postEvent(q, new QUpdateLaterEvent(clipped)); return; } @@ -11257,7 +11257,7 @@ void QWidgetPrivate::macUpdateSizeAttribute() { Q_Q(QWidget); QEvent event(QEvent::MacSizeChange); - QApplication::sendEvent(q, &event); + QCoreApplication::sendEvent(q, &event); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast(children.at(i)); if (w && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) @@ -11313,7 +11313,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))) setAttribute(Qt::WA_DropSiteRegistered, false); QEvent e(QEvent::AcceptDropsChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); break; } case Qt::WA_DropSiteRegistered: { @@ -11396,11 +11396,11 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) break; case Qt::WA_MouseTracking: { QEvent e(QEvent::MouseTrackingChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); break; } case Qt::WA_TabletTracking: { QEvent e(QEvent::TabletTrackingChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); break; } case Qt::WA_NativeWindow: { d->createTLExtra(); @@ -11413,7 +11413,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) QGuiApplication::inputMethod()->commit(); QGuiApplication::inputMethod()->update(Qt::ImEnabled); } - if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) + if (!QCoreApplication::testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()) parentWidget()->d_func()->enforceNativeChildren(); if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created)) d->createWinId(); @@ -11649,7 +11649,7 @@ void QWidget::setWindowModified(bool mod) d->setWindowModified_helper(); QEvent e(QEvent::ModifiedChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } void QWidgetPrivate::setWindowModified_helper() @@ -11695,7 +11695,7 @@ void QWidget::setToolTip(const QString &s) d->toolTip = s; QEvent event(QEvent::ToolTipChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } QString QWidget::toolTip() const @@ -11872,7 +11872,7 @@ int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context) if (key.isEmpty()) return 0; setAttribute(Qt::WA_GrabbedShortcut); - return qApp->d_func()->shortcutMap.addShortcut(this, key, context, qWidgetShortcutContextMatcher); + return QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, key, context, qWidgetShortcutContextMatcher); } /*! @@ -11894,7 +11894,7 @@ void QWidget::releaseShortcut(int id) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.removeShortcut(id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this, 0); } /*! @@ -11913,7 +11913,7 @@ void QWidget::setShortcutEnabled(int id, bool enable) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enable, id, this, 0); } /*! @@ -11928,7 +11928,7 @@ void QWidget::setShortcutAutoRepeat(int id, bool enable) { Q_ASSERT(qApp); if (id) - qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0); + QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0); } #endif // QT_NO_SHORTCUT @@ -11983,7 +11983,7 @@ void QWidget::raise() QWindowContainer::parentWasRaised(this); QEvent e(QEvent::ZOrderChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } void QWidgetPrivate::raise_sys() @@ -12033,7 +12033,7 @@ void QWidget::lower() QWindowContainer::parentWasLowered(this); QEvent e(QEvent::ZOrderChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } void QWidgetPrivate::lower_sys() @@ -12080,7 +12080,7 @@ void QWidget::stackUnder(QWidget* w) d->stackUnder_sys(w); QEvent e(QEvent::ZOrderChange); - QApplication::sendEvent(this, &e); + QCoreApplication::sendEvent(this, &e); } void QWidgetPrivate::stackUnder_sys(QWidget*) diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 595beeaf470..ab33649b3e4 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -491,11 +491,11 @@ void QWidgetBackingStore::sendUpdateRequest(QWidget *widget, UpdateTime updateTi switch (updateTime) { case UpdateLater: updateRequestSent = true; - QApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority); + QCoreApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority); break; case UpdateNow: { QEvent event(QEvent::UpdateRequest); - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); break; } } @@ -1507,7 +1507,7 @@ void QWidgetPrivate::invalidateBackingStore(const T &r) if (r.isEmpty()) return; - if (QApplication::closingDown()) + if (QCoreApplication::closingDown()) return; Q_Q(QWidget); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index a5d9eee49de..ba100838292 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -155,7 +155,7 @@ QWidgetWindow::QWidgetWindow(QWidget *widget) // Enable QOpenGLWidget/QQuickWidget children if the platform plugin supports it, // and the application developer has not explicitly disabled it. if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface) - && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)) { + && !QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) { setSurfaceType(QSurface::RasterGLSurface); } connect(widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName); @@ -496,8 +496,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) static const QEvent::Type contextMenuTrigger = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ? QEvent::MouseButtonRelease : QEvent::MouseButtonPress; - if (qApp->d_func()->inPopupMode()) { - QWidget *activePopupWidget = qApp->activePopupWidget(); + if (QApplicationPrivate::inPopupMode()) { + QWidget *activePopupWidget = QApplication::activePopupWidget(); QPoint mapped = event->pos(); if (activePopupWidget != m_widget) mapped = activePopupWidget->mapFromGlobal(event->globalPos()); @@ -577,7 +577,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) } } - if (qApp->activePopupWidget() != activePopupWidget + if (QApplication::activePopupWidget() != activePopupWidget && qt_replay_popup_mouse_event && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) { if (m_widget->windowType() != Qt::Popup) @@ -680,7 +680,7 @@ void QWidgetWindow::handleTouchEvent(QTouchEvent *event) if (event->type() == QEvent::TouchCancel) { QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp()); event->accept(); - } else if (qApp->d_func()->inPopupMode()) { + } else if (QApplicationPrivate::inPopupMode()) { // Ignore touch events for popups. This will cause QGuiApplication to synthesise mouse // events instead, which QWidgetWindow::handleMouseEvent will forward correctly: event->ignore(); @@ -744,7 +744,7 @@ void QWidgetWindow::updateMargins() static void sendScreenChangeRecursively(QWidget *widget) { QEvent e(QEvent::ScreenChangeInternal); - QApplication::sendEvent(widget, &e); + QCoreApplication::sendEvent(widget, &e); QWidgetPrivate *d = QWidgetPrivate::get(widget); for (int i = 0; i < d->children.size(); ++i) { QWidget *w = qobject_cast(d->children.at(i)); diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 4b289d2d33c..fd8581edbba 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -223,7 +223,7 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt: // Otherwise we may end up with BadMatch failures on X11. if (embeddedWindow->surfaceType() == QSurface::RasterSurface && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface) - && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)) + && !QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) embeddedWindow->setSurfaceType(QSurface::RasterGLSurface); d->window = embeddedWindow; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 9e701995a46..7b53f5272c9 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1253,12 +1253,12 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w *iconRect = QRect(tr.left() + offsetX, tr.center().y() - tabIconSize.height() / 2, tabIconSize.width(), tabIconSize.height()); if (!verticalTabs) - *iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect); + *iconRect = QStyle::visualRect(opt->direction, opt->rect, *iconRect); tr.setLeft(tr.left() + tabIconSize.width() + 4); } if (!verticalTabs) - tr = proxyStyle->visualRect(opt->direction, opt->rect, tr); + tr = QStyle::visualRect(opt->direction, opt->rect, tr); *textRect = tr; } @@ -4835,7 +4835,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_MessageBoxIconSize: #ifdef Q_OS_MAC - if (QApplication::desktopSettingsAware()) { + if (QGuiApplication::desktopSettingsAware()) { ret = 64; // No DPI scaling, it's handled elsewhere. } else #endif @@ -5460,14 +5460,14 @@ static QIcon clearTextIcon(bool rtl) QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option, const QWidget *widget) const { - const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); + const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QGuiApplication::isRightToLeft()); #ifdef QT_NO_IMAGEFORMAT_PNG Q_UNUSED(widget); Q_UNUSED(sp); #else QPixmap pixmap; - if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { + if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { switch (sp) { case SP_DialogYesButton: case SP_DialogOkButton: @@ -5829,7 +5829,7 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption const QWidget *widget) const { QIcon icon; - const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); + const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QGuiApplication::isRightToLeft()); #ifdef Q_OS_WIN switch (standardIcon) { @@ -5881,7 +5881,7 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption #endif - if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { + if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { switch (standardIcon) { case SP_DirHomeIcon: icon = QIcon::fromTheme(QLatin1String("user-home")); @@ -6057,13 +6057,13 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption default: break; } - } // if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) + } // if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) if (!icon.isNull()) return icon; #if defined(Q_OS_MAC) - if (QApplication::desktopSettingsAware()) { + if (QGuiApplication::desktopSettingsAware()) { switch (standardIcon) { case SP_DirIcon: { // A rather special case @@ -6129,7 +6129,7 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption default: break; } - } // if (QApplication::desktopSettingsAware()) + } // if (QGuiApplication::desktopSettingsAware()) #endif // Q_OS_MAC switch (standardIcon) { diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 2c1132da196..6cbed34c3a7 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -560,7 +560,7 @@ QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pi x += w - pixmapWidth; else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter) x += w/2 - pixmapWidth/2; - else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft()) + else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QGuiApplication::isRightToLeft()) x += w - pixmapWidth; result = QRect(x, y, pixmapWidth, pixmapHeight); return result; @@ -624,7 +624,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const { qreal scale = pixmap.devicePixelRatio(); - QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size() / scale, rect); + QRect aligned = alignedRect(QGuiApplication::layoutDirection(), QFlag(alignment), pixmap.size() / scale, rect); QRect inter = aligned.intersected(rect); painter->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width() * scale, inter.height() *scale); diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 88031a9f1ed..4faf98a0a3e 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -151,7 +151,7 @@ QT_BEGIN_NAMESPACE QStyleOption::QStyleOption(int version, int type) : version(version), type(type), state(QStyle::State_None), - direction(QApplication::layoutDirection()), fontMetrics(QFont()), styleObject(0) + direction(QGuiApplication::layoutDirection()), fontMetrics(QFont()), styleObject(0) { } diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index c1f498cd0cc..ea653459d35 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -909,7 +909,7 @@ static QStyle::StandardPixmap subControlIcon(int pe) QRenderRule::QRenderRule(const QVector &declarations, const QObject *object) : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { - QPalette palette = QApplication::palette(); // ###: ideally widget's palette + QPalette palette = QGuiApplication::palette(); // ###: ideally widget's palette ValueExtractor v(declarations, palette); features = v.extractStyleFeatures(); @@ -2734,7 +2734,7 @@ static void updateObjects(const QList& objects) for (const QObject *object : objects) { if (auto widget = qobject_cast(const_cast(object))) { widget->style()->polish(widget); - QApplication::sendEvent(widget, &event); + QCoreApplication::sendEvent(widget, &event); } } } @@ -6073,7 +6073,7 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const w->d_func()->directFontResolveMask = font.resolve(); QEvent e(QEvent::FontChange); - QApplication::sendEvent(w, &e); + QCoreApplication::sendEvent(w, &e); } } diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 3c0478b84e9..1d5934e3f73 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -244,11 +244,12 @@ void QWindowsStyle::polish(QApplication *app) if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app) app->installEventFilter(this); - d->activeCaptionColor = app->palette().highlight().color(); - d->activeGradientCaptionColor = app->palette().highlight() .color(); - d->inactiveCaptionColor = app->palette().dark().color(); - d->inactiveGradientCaptionColor = app->palette().dark().color(); - d->inactiveCaptionText = app->palette().window().color(); + const auto &palette = QGuiApplication::palette(); + d->activeGradientCaptionColor = palette.highlight().color(); + d->activeCaptionColor = d->activeGradientCaptionColor; + d->inactiveGradientCaptionColor = palette.dark().color(); + d->inactiveCaptionColor = d->inactiveGradientCaptionColor; + d->inactiveCaptionText = palette.window().color(); #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //fetch native title bar colors if(app->desktopSettingsAware()){ diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index e41f7e75730..04407cdb1d9 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -1504,7 +1504,7 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e) case QEvent::InputMethod: case QEvent::ShortcutOverride: - QApplication::sendEvent(d->widget, e); + QCoreApplication::sendEvent(d->widget, e); break; default: diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index a8b2a00a804..55ec93c7d39 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -228,7 +228,7 @@ public: // we did send a press, so we need to fake a release now // release all pressed mouse buttons - /* Qt::MouseButtons mouseButtons = QApplication::mouseButtons(); + /* Qt::MouseButtons mouseButtons = QGuiApplication::mouseButtons(); for (int i = 0; i < 32; ++i) { if (mouseButtons & (1 << i)) { Qt::MouseButton b = static_cast(1 << i); @@ -237,7 +237,7 @@ public: qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget; QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, - b, mouseButtons, QApplication::keyboardModifiers()); + b, mouseButtons, QGuiApplication::keyboardModifiers()); sendMouseEvent(&re); } }*/ @@ -246,8 +246,8 @@ public: qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget; QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway, - mouseButton, QApplication::mouseButtons() & ~mouseButton, - QApplication::keyboardModifiers(), mouseEventSource); + mouseButton, QGuiApplication::mouseButtons() & ~mouseButton, + QGuiApplication::keyboardModifiers(), mouseEventSource); sendMouseEvent(&re, RegrabMouseAfterwards); // don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release! } diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 70e5f3678ea..0c7bb94a917 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -151,11 +151,11 @@ bool QSystemTrayIconSys::event(QEvent *e) { switch (e->type()) { case QEvent::ToolTip: - QApplication::sendEvent(q, e); + QCoreApplication::sendEvent(q, e); break; #if QT_CONFIG(wheelevent) case QEvent::Wheel: - return QApplication::sendEvent(q, e); + return QCoreApplication::sendEvent(q, e); #endif default: break; diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 5ea8330db22..b9e0d3280fa 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1086,7 +1086,7 @@ bool QAbstractScrollArea::event(QEvent *e) QScrollBar *vBar = verticalScrollBar(); QPointF delta = g->delta(); if (!delta.isNull()) { - if (QApplication::isRightToLeft()) + if (QGuiApplication::isRightToLeft()) delta.rx() *= -1; int newX = hBar->value() - delta.x(); int newY = vBar->value() - delta.y(); @@ -1325,9 +1325,9 @@ void QAbstractScrollArea::wheelEvent(QWheelEvent *e) { Q_D(QAbstractScrollArea); if (e->orientation() == Qt::Horizontal) - QApplication::sendEvent(d->hbar, e); + QCoreApplication::sendEvent(d->hbar, e); else - QApplication::sendEvent(d->vbar, e); + QCoreApplication::sendEvent(d->vbar, e); } #endif diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 04276aa4005..e6e9939a10a 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -333,7 +333,7 @@ void QAbstractSpinBox::setReadOnly(bool enable) d->readOnly = enable; d->edit->setReadOnly(enable); QEvent event(QEvent::ReadOnlyChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); update(); } @@ -574,10 +574,10 @@ QAbstractSpinBox::StepEnabled QAbstractSpinBox::stepEnabled() const if (d->wrapping) return StepEnabled(StepUpEnabled | StepDownEnabled); StepEnabled ret = StepNone; - if (d->variantCompare(d->value, d->maximum) < 0) { + if (QAbstractSpinBoxPrivate::variantCompare(d->value, d->maximum) < 0) { ret |= StepUpEnabled; } - if (d->variantCompare(d->value, d->minimum) > 0) { + if (QAbstractSpinBoxPrivate::variantCompare(d->value, d->minimum) > 0) { ret |= StepDownEnabled; } return ret; diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index a052f2df79f..0b52747b6a9 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2618,7 +2618,7 @@ bool QComboBoxPrivate::showNativePopup() // We need to fake one here to un-press the button. QMouseEvent mouseReleased(QEvent::MouseButtonRelease, q->pos(), Qt::LeftButton, Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers()); - qApp->sendEvent(q, &mouseReleased); + QCoreApplication::sendEvent(q, &mouseReleased); #endif return true; @@ -2915,7 +2915,7 @@ void QComboBox::hidePopup() bool didFade = false; if (needFade) { #if defined(Q_OS_MAC) - QPlatformNativeInterface *platformNativeInterface = qApp->platformNativeInterface(); + QPlatformNativeInterface *platformNativeInterface = QGuiApplication::platformNativeInterface(); int at = platformNativeInterface->metaObject()->indexOfMethod("fadeWindow()"); if (at != -1) { QMetaMethod windowFade = platformNativeInterface->metaObject()->method(at); diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 1dac496bef9..45c72e24d45 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -645,7 +645,7 @@ QDateTimeEdit::Section QDateTimeEdit::currentSection() const if (QApplication::keypadNavigationEnabled() && d->focusOnButton) return NoSection; #endif - return d->convertToPublic(d->sectionType(d->currentSectionIndex)); + return QDateTimeEditPrivate::convertToPublic(d->sectionType(d->currentSectionIndex)); } void QDateTimeEdit::setCurrentSection(Section section) @@ -659,7 +659,7 @@ void QDateTimeEdit::setCurrentSection(Section section) int index = d->currentSectionIndex + 1; for (int i=0; i<2; ++i) { while (index < size) { - if (d->convertToPublic(d->sectionType(index)) == section) { + if (QDateTimeEditPrivate::convertToPublic(d->sectionType(index)) == section) { d->edit->setCursorPosition(d->sectionPos(index)); QDTEDEBUG << d->sectionPos(index); return; @@ -685,7 +685,7 @@ QDateTimeEdit::Section QDateTimeEdit::sectionAt(int index) const Q_D(const QDateTimeEdit); if (index < 0 || index >= d->sectionNodes.size()) return NoSection; - return d->convertToPublic(d->sectionType(index)); + return QDateTimeEditPrivate::convertToPublic(d->sectionType(index)); } /*! @@ -879,7 +879,7 @@ void QDateTimeEdit::setDisplayFormat(const QString &format) } d->formatExplicitlySet = true; - d->sections = d->convertSections(d->display); + d->sections = QDateTimeEditPrivate::convertSections(d->display); d->clearCache(); d->currentSectionIndex = qMin(d->currentSectionIndex, d->sectionNodes.size() - 1); diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index b8b6c12bf39..dc3b77b7bce 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -1590,7 +1590,7 @@ bool QDockWidget::event(QEvent *event) // This is a workaround for loosing the mouse on Vista. QPoint pos = QCursor::pos(); QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, - QApplication::mouseButtons(), QApplication::keyboardModifiers()); + QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); d->mouseMoveEvent(&fake); } break; diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index bcc8d7815dd..94636413692 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -569,8 +569,8 @@ void qScrollEffect(QWidget* w, QEffects::DirFlags orient, int time) if (!w) return; - QApplication::sendPostedEvents(w, QEvent::Move); - QApplication::sendPostedEvents(w, QEvent::Resize); + QCoreApplication::sendPostedEvents(w, QEvent::Move); + QCoreApplication::sendPostedEvents(w, QEvent::Resize); Qt::WindowFlags flags = Qt::ToolTip; // those can be popups - they would steal the focus, but are disabled @@ -591,8 +591,8 @@ void qFadeEffect(QWidget* w, int time) if (!w) return; - QApplication::sendPostedEvents(w, QEvent::Move); - QApplication::sendPostedEvents(w, QEvent::Resize); + QCoreApplication::sendPostedEvents(w, QEvent::Move); + QCoreApplication::sendPostedEvents(w, QEvent::Resize); Qt::WindowFlags flags = Qt::ToolTip; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 09b7687d8e6..68e3de05bc9 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -84,7 +84,7 @@ #include "qkeysequence.h" #define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus) \ && QGuiApplication::styleHints()->showShortcutsInContextMenus()) \ - && !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ + && !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \ QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) #else #define ACCEL_KEY(k) QString() @@ -684,10 +684,10 @@ QSize QLineEdit::sizeHint() const ensurePolished(); QFontMetrics fm(font()); const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); - int h = qMax(fm.height(), iconSize - 2) + 2*d->verticalMargin + int h = qMax(fm.height(), iconSize - 2) + 2 * QLineEditPrivate::verticalMargin + d->topTextMargin + d->bottomTextMargin + d->topmargin + d->bottommargin; - int w = fm.horizontalAdvance(QLatin1Char('x')) * 17 + 2*d->horizontalMargin + int w = fm.horizontalAdvance(QLatin1Char('x')) * 17 + 2 * QLineEditPrivate::horizontalMargin + d->effectiveLeftTextMargin() + d->effectiveRightTextMargin() + d->leftmargin + d->rightmargin; // "some" QStyleOptionFrame opt; @@ -708,7 +708,7 @@ QSize QLineEdit::minimumSizeHint() const Q_D(const QLineEdit); ensurePolished(); QFontMetrics fm = fontMetrics(); - int h = fm.height() + qMax(2*d->verticalMargin, fm.leading()) + int h = fm.height() + qMax(2 * QLineEditPrivate::verticalMargin, fm.leading()) + d->topTextMargin + d->bottomTextMargin + d->topmargin + d->bottommargin; int w = fm.maxWidth() @@ -1606,7 +1606,7 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e) } #endif #ifndef QT_NO_CLIPBOARD - if (QApplication::clipboard()->supportsSelection()) { + if (QGuiApplication::clipboard()->supportsSelection()) { if (e->button() == Qt::LeftButton) { d->control->copy(QClipboard::Selection); } else if (!d->control->isReadOnly() && e->button() == Qt::MidButton) { @@ -1960,17 +1960,18 @@ void QLineEdit::paintEvent(QPaintEvent *) Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment)); switch (va & Qt::AlignVertical_Mask) { case Qt::AlignBottom: - d->vscroll = r.y() + r.height() - fm.height() - d->verticalMargin; + d->vscroll = r.y() + r.height() - fm.height() - QLineEditPrivate::verticalMargin; break; case Qt::AlignTop: - d->vscroll = r.y() + d->verticalMargin; + d->vscroll = r.y() + QLineEditPrivate::verticalMargin; break; default: //center d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2; break; } - QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height()); + QRect lineRect(r.x() + QLineEditPrivate::horizontalMargin, d->vscroll, + r.width() - 2 * QLineEditPrivate::horizontalMargin, fm.height()); if (d->shouldShowPlaceholderText()) { if (!d->placeholderText.isEmpty()) { @@ -2206,7 +2207,7 @@ QMenu *QLineEdit::createStandardContextMenu() if (!isReadOnly()) { action = popup->addAction(QLineEdit::tr("&Paste") + ACCEL_KEY(QKeySequence::Paste)); - action->setEnabled(!d->control->isReadOnly() && !QApplication::clipboard()->text().isEmpty()); + action->setEnabled(!d->control->isReadOnly() && !QGuiApplication::clipboard()->text().isEmpty()); setActionIcon(action, QStringLiteral("edit-paste")); connect(action, SIGNAL(triggered()), SLOT(paste())); } diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index fe3d1663a8e..c7b7e5bf97b 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -2525,7 +2525,7 @@ bool QMdiArea::event(QEvent *event) case QEvent::WindowIconChange: foreach (QMdiSubWindow *window, d->childWindows) { if (sanityCheck(window, "QMdiArea::WindowIconChange")) - QApplication::sendEvent(window, event); + QCoreApplication::sendEvent(window, event); } break; case QEvent::Hide: diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 685c5e159ee..77692930fce 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1826,7 +1826,7 @@ void QMdiSubWindowPrivate::showButtonsInMenuBar(QMenuBar *menuBar) // Make sure topLevelWindow->contentsRect returns correct geometry. // topLevelWidget->updateGeoemtry will not do the trick here since it will post the event. QEvent event(QEvent::LayoutRequest); - QApplication::sendEvent(topLevelWindow, &event); + QCoreApplication::sendEvent(topLevelWindow, &event); } } @@ -1936,7 +1936,7 @@ QPalette QMdiSubWindowPrivate::desktopPalette() const #ifndef COLOR_GRADIENTINACTIVECAPTION #define COLOR_GRADIENTINACTIVECAPTION 28 #endif - if (QApplication::desktopSettingsAware()) { + if (QGuiApplication::desktopSettingsAware()) { newPalette.setColor(QPalette::Active, QPalette::Highlight, colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION))); newPalette.setColor(QPalette::Inactive, QPalette::Highlight, @@ -3050,7 +3050,7 @@ void QMdiSubWindow::closeEvent(QCloseEvent *closeEvent) d->setActive(false); if (parentWidget() && testAttribute(Qt::WA_DeleteOnClose)) { QChildEvent childRemoved(QEvent::ChildRemoved, this); - QApplication::sendEvent(parentWidget(), &childRemoved); + QCoreApplication::sendEvent(parentWidget(), &childRemoved); } closeEvent->accept(); } diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 7b6a1b6da8d..72653b377d1 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -264,7 +264,7 @@ void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenu item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w)); } else { QStyleOption opt; - item->setIconSize(qApp->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0)); + item->setIconSize(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0)); } } else { item->setIcon(QIcon()); @@ -907,7 +907,7 @@ void QMenuPrivate::updateLayoutDirection() else if (QWidget *w = q->parentWidget()) setLayoutDirection_helper(w->layoutDirection()); else - setLayoutDirection_helper(QApplication::layoutDirection()); + setLayoutDirection_helper(QGuiApplication::layoutDirection()); } } @@ -1335,7 +1335,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) if (e->type() != QEvent::MouseButtonRelease || mouseDown == caused) { QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); - QApplication::sendEvent(caused, &new_e); + QCoreApplication::sendEvent(caused, &new_e); return true; } } @@ -1543,7 +1543,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) if (d->currentAction && d->currentAction == action && !d->currentAction->isSeparator()) { option->state |= QStyle::State_Selected - | (d->mouseDown ? QStyle::State_Sunken : QStyle::State_None); + | (QMenuPrivate::mouseDown ? QStyle::State_Sunken : QStyle::State_None); } option->menuHasCheckableItems = d->hasCheckableItems; @@ -2362,7 +2362,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) QRect screen; #if QT_CONFIG(graphicsview) - bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); + bool isEmbedded = !bypassGraphicsProxyWidget(this) && QMenuPrivate::nearestGraphicsProxyWidget(this); if (isEmbedded) screen = d->popupGeometry(); else @@ -2698,8 +2698,8 @@ void QMenu::hideEvent(QHideEvent *) if (QMenuBar *mb = qobject_cast(d->causedPopup.widget)) mb->d_func()->setCurrentAction(0); #endif - if (d->mouseDown == this) - d->mouseDown = 0; + if (QMenuPrivate::mouseDown == this) + QMenuPrivate::mouseDown = nullptr; d->hasHadMouse = false; if (d->activeMenu) d->hideMenu(d->activeMenu); @@ -2874,7 +2874,7 @@ void QMenu::mousePressEvent(QMouseEvent *e) d->hideUpToMenuBar(); return; } - d->mouseDown = this; + QMenuPrivate::mouseDown = this; QAction *action = d->actionAt(e->pos()); d->setCurrentAction(action, 20); @@ -2889,12 +2889,12 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e) Q_D(QMenu); if (d->aboutToHide || d->mouseEventTaken(e)) return; - if(d->mouseDown != this) { - d->mouseDown = 0; + if (QMenuPrivate::mouseDown != this) { + QMenuPrivate::mouseDown = nullptr; return; } - d->mouseDown = 0; + QMenuPrivate::mouseDown = nullptr; d->setSyncAction(); QAction *action = d->actionAt(e->pos()); @@ -2995,7 +2995,7 @@ QMenu::event(QEvent *e) d->updateActionRects(); break; } case QEvent::Show: - d->mouseDown = 0; + QMenuPrivate::mouseDown = nullptr; d->updateActionRects(); d->sloppyState.reset(); if (d->currentAction) @@ -3385,7 +3385,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) #if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(d->topCausedWidget())) { QAction *oldAct = mb->d_func()->currentAction; - QApplication::sendEvent(mb, e); + QCoreApplication::sendEvent(mb, e); if (mb->d_func()->currentAction != oldAct) key_consumed = true; } @@ -3428,7 +3428,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) } if (e->buttons()) - d->mouseDown = this; + QMenuPrivate::mouseDown = this; if (d->activeMenu) d->activeMenu->d_func()->setCurrentAction(0); @@ -3593,7 +3593,7 @@ void QMenu::internalDelayedPopup() QRect screen; #if QT_CONFIG(graphicsview) - bool isEmbedded = !bypassGraphicsProxyWidget(this) && d->nearestGraphicsProxyWidget(this); + bool isEmbedded = !bypassGraphicsProxyWidget(this) && QMenuPrivate::nearestGraphicsProxyWidget(this); if (isEmbedded) screen = d->popupGeometry(); else diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 9a60f1477d0..3d31a3b73a5 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -404,7 +404,7 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat } else if (previousAction) { QString empty; QStatusTipEvent tip(empty); - QApplication::sendEvent(q, &tip); + QCoreApplication::sendEvent(q, &tip); #endif } if (fw) @@ -701,7 +701,7 @@ void QMenuBarPrivate::init() q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); q->setAttribute(Qt::WA_CustomWhatsThis); - if (!QApplication::instance()->testAttribute(Qt::AA_DontUseNativeMenuBar)) + if (!QCoreApplication::testAttribute(Qt::AA_DontUseNativeMenuBar)) platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); if (platformMenuBar) diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 4a875975a4d..397304ec440 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -1588,7 +1588,7 @@ bool QPlainTextEdit::event(QEvent *e) d->originalOffsetY = vBar->value(); QPointF offset = g->offset(); if (!offset.isNull()) { - if (QApplication::isRightToLeft()) + if (QGuiApplication::isRightToLeft()) offset.rx() *= -1; // QPlainTextEdit scrolls by lines only in vertical direction QFontMetrics fm(document()->defaultFont()); @@ -2649,7 +2649,7 @@ void QPlainTextEdit::setReadOnly(bool ro) d->control->setTextInteractionFlags(flags); setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); QEvent event(QEvent::ReadOnlyChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } /*! diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 97a3a12336e..61ea81c8925 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -384,7 +384,7 @@ void QSpinBox::setMinimum(int minimum) { Q_D(QSpinBox); const QVariant m(minimum); - d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); + d->setRange(m, (QSpinBoxPrivate::variantCompare(d->maximum, m) > 0 ? d->maximum : m)); } /*! @@ -412,7 +412,7 @@ void QSpinBox::setMaximum(int maximum) { Q_D(QSpinBox); const QVariant m(maximum); - d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); + d->setRange((QSpinBoxPrivate::variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); } /*! @@ -864,7 +864,7 @@ void QDoubleSpinBox::setMinimum(double minimum) Q_D(QDoubleSpinBox); d->actualMin = minimum; const QVariant m(d->round(minimum)); - d->setRange(m, (d->variantCompare(d->maximum, m) > 0 ? d->maximum : m)); + d->setRange(m, (QDoubleSpinBoxPrivate::variantCompare(d->maximum, m) > 0 ? d->maximum : m)); } /*! @@ -895,7 +895,7 @@ void QDoubleSpinBox::setMaximum(double maximum) Q_D(QDoubleSpinBox); d->actualMax = maximum; const QVariant m(d->round(maximum)); - d->setRange((d->variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); + d->setRange((QDoubleSpinBoxPrivate::variantCompare(d->minimum, m) < 0 ? d->minimum : m), m); } /*! diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index bf6bf1c7c9a..e39ef6d1cd2 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -111,7 +111,7 @@ public: The user can hide the splash screen by clicking on it with the mouse. Since the splash screen is typically displayed before the event loop has started running, it is necessary to periodically - call QApplication::processEvents() to receive the mouse clicks. + call QCoreApplication::processEvents() to receive the mouse clicks. It is sometimes useful to update the splash screen with messages, for example, announcing connections established or modules loaded @@ -170,13 +170,13 @@ void QSplashScreen::mousePressEvent(QMouseEvent *) /*! This overrides QWidget::repaint(). It differs from the standard repaint - function in that it also calls QApplication::processEvents() to ensure + function in that it also calls QCoreApplication::processEvents() to ensure the updates are displayed, even when there is no event loop present. */ void QSplashScreen::repaint() { QWidget::repaint(); - QApplication::processEvents(); + QCoreApplication::processEvents(); } /*! diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index b13f4da9d21..f6f56c12d18 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -843,7 +843,7 @@ void QTabBarPrivate::refresh() // be safe in case a subclass is also handling move with the tabs if (pressedIndex != -1 && movable - && QApplication::mouseButtons() == Qt::NoButton) { + && QGuiApplication::mouseButtons() == Qt::NoButton) { moveTabFinished(pressedIndex); if (!validIndex(pressedIndex)) pressedIndex = -1; diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 01f7c34f932..8c1d7e7a03e 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -2260,7 +2260,7 @@ void QTextEdit::setReadOnly(bool ro) d->control->setTextInteractionFlags(flags); setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); QEvent event(QEvent::ReadOnlyChange); - QApplication::sendEvent(this, &event); + QCoreApplication::sendEvent(this, &event); } /*! diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index bcf5a40ae30..fcaafbc5818 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -1172,7 +1172,7 @@ bool QToolBar::event(QEvent *event) // This is a workaround for loosing the mouse on Vista. QPoint pos = QCursor::pos(); QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, - QApplication::mouseButtons(), QApplication::keyboardModifiers()); + QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); d->mouseMoveEvent(&fake); #endif } else { diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index cf2d885b527..56dba1dd32f 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -158,7 +158,7 @@ void QWidgetLineControl::copy(QClipboard::Mode mode) const { QString t = selectedText(); if (!t.isEmpty() && m_echoMode == QLineEdit::Normal) { - QApplication::clipboard()->setText(t, mode); + QGuiApplication::clipboard()->setText(t, mode); } } @@ -172,7 +172,7 @@ void QWidgetLineControl::copy(QClipboard::Mode mode) const */ void QWidgetLineControl::paste(QClipboard::Mode clipboardMode) { - QString clip = QApplication::clipboard()->text(clipboardMode); + QString clip = QGuiApplication::clipboard()->text(clipboardMode); if (!clip.isEmpty() || hasSelectedText()) { separate(); //make it a separate undo/redo command insert(clip); @@ -1524,9 +1524,9 @@ void QWidgetLineControl::setBlinkingCursorEnabled(bool enable) m_blinkEnabled = enable; if (enable) - connect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); + connect(QGuiApplication::styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); else - disconnect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); + disconnect(QGuiApplication::styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetLineControl::updateCursorBlinking); updateCursorBlinking(); } @@ -1680,7 +1680,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { if (hasAcceptableInput() || fixup()) { - QInputMethod *inputMethod = QApplication::inputMethod(); + QInputMethod *inputMethod = QGuiApplication::inputMethod(); inputMethod->commit(); QWidget *lineEdit = qobject_cast(parent()); if (!(lineEdit && lineEdit->inputMethodHints() & Qt::ImhMultiLine)) diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index cad3a64749e..ccf02da219f 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -97,7 +97,7 @@ #include #define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \ && QGuiApplication::styleHints()->showShortcutsInContextMenus()) \ - && !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ + && !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \ QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) #else @@ -648,7 +648,7 @@ void QWidgetTextControlPrivate::_q_updateCurrentCharFormatAndSelection() #ifndef QT_NO_CLIPBOARD void QWidgetTextControlPrivate::setClipboardSelection() { - QClipboard *clipboard = QApplication::clipboard(); + QClipboard *clipboard = QGuiApplication::clipboard(); if (!cursor.hasSelection() || !clipboard->supportsSelection()) return; Q_Q(QWidgetTextControl); @@ -719,9 +719,9 @@ void QWidgetTextControlPrivate::setCursorVisible(bool visible) updateCursorBlinking(); if (cursorVisible) - connect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); + connect(QGuiApplication::styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); else - disconnect(qApp->styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); + disconnect(QGuiApplication::styleHints(), &QStyleHints::cursorFlashTimeChanged, this, &QWidgetTextControlPrivate::updateCursorBlinking); } void QWidgetTextControlPrivate::updateCursorBlinking() @@ -959,12 +959,12 @@ void QWidgetTextControl::copy() if (!d->cursor.hasSelection()) return; QMimeData *data = createMimeDataFromSelection(); - QApplication::clipboard()->setMimeData(data); + QGuiApplication::clipboard()->setMimeData(data); } void QWidgetTextControl::paste(QClipboard::Mode mode) { - const QMimeData *md = QApplication::clipboard()->mimeData(mode); + const QMimeData *md = QGuiApplication::clipboard()->mimeData(mode); if (md) insertFromMimeData(md); } @@ -1787,9 +1787,9 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but selectionChanged(true); } else if (button == Qt::MidButton && (interactionFlags & Qt::TextEditable) - && QApplication::clipboard()->supportsSelection()) { + && QGuiApplication::clipboard()->supportsSelection()) { setCursorPosition(pos); - const QMimeData *md = QApplication::clipboard()->mimeData(QClipboard::Selection); + const QMimeData *md = QGuiApplication::clipboard()->mimeData(QClipboard::Selection); if (md) q->insertFromMimeData(md); #endif @@ -2598,7 +2598,7 @@ bool QWidgetTextControl::canPaste() const #ifndef QT_NO_CLIPBOARD Q_D(const QWidgetTextControl); if (d->interactionFlags & Qt::TextEditable) { - const QMimeData *md = QApplication::clipboard()->mimeData(); + const QMimeData *md = QGuiApplication::clipboard()->mimeData(); return md && canInsertFromMimeData(md); } #endif @@ -3331,7 +3331,7 @@ void QWidgetTextControlPrivate::_q_copyLink() #ifndef QT_NO_CLIPBOARD QMimeData *md = new QMimeData; md->setText(linkToCopy); - QApplication::clipboard()->setMimeData(md); + QGuiApplication::clipboard()->setMimeData(md); #endif } From 168b18de2d1429dc4f8c8db538c0a2cf3141c694 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 20 Jun 2019 12:52:15 +0200 Subject: [PATCH 049/172] QtWidgets: Preparatory change for moving out QAction (or parts of it) - Fix some spelling - Use QT_CONFIG for shortcuts - Quick C++ brush up, use member initialization Preemptively fix sanity bot warnings about missing space after flow control keyword, introducing range-based for on this occasion - Remove unused member variable Task-number: QTBUG-69478 Change-Id: I6af21886d5a0b48f4b2d11082991a877bd8d817d Reviewed-by: Oliver Wolff --- src/widgets/kernel/qaction.cpp | 36 ++++++++++++----------------- src/widgets/kernel/qaction.h | 4 ++-- src/widgets/kernel/qaction_p.h | 18 +++++++-------- src/widgets/kernel/qactiongroup.cpp | 23 +++++++++--------- 4 files changed, 36 insertions(+), 45 deletions(-) diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 47e91bf8f96..19ad65692ba 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -75,23 +75,17 @@ static QString qt_strippedText(QString s) } -QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), - visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), - iconVisibleInMenu(-1), - shortcutVisibleInContextMenu(-1), - menuRole(QAction::TextHeuristicRole), - priority(QAction::NormalPriority) -{ -#ifndef QT_NO_SHORTCUT - shortcutId = 0; - shortcutContext = Qt::WindowShortcut; - autorepeat = true; +QActionPrivate::QActionPrivate() : +#if QT_CONFIG(shortcut) + autorepeat(1), #endif + enabled(1), forceDisabled(0), visible(1), forceInvisible(0), checkable(0), + checked(0), separator(0), fontSet(false), + iconVisibleInMenu(-1), shortcutVisibleInContextMenu(-1) +{ } -QActionPrivate::~QActionPrivate() -{ -} +QActionPrivate::~QActionPrivate() = default; bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) { @@ -127,7 +121,7 @@ void QActionPrivate::sendDataChanged() emit q->changed(); } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) void QActionPrivate::redoGrab(QShortcutMap &map) { Q_Q(QAction); @@ -345,7 +339,7 @@ QWidget *QAction::parentWidget() const QObject *ret = parent(); while (ret && !ret->isWidgetType()) ret = ret->parent(); - return (QWidget*)ret; + return static_cast(ret); } /*! @@ -374,7 +368,7 @@ QList QAction::associatedGraphicsWidgets() const } #endif -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) /*! \property QAction::shortcut \brief the action's primary shortcut key @@ -573,7 +567,7 @@ QAction::~QAction() #endif if (d->group) d->group->removeAction(this); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (d->shortcutId && qApp) { QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(d->shortcutId, this); for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { @@ -1027,7 +1021,7 @@ void QAction::setEnabled(bool b) return; QAPP_CHECK("setEnabled"); d->enabled = b; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) d->setShortcutEnabled(b, QGuiApplicationPrivate::instance()->shortcutMap); #endif d->sendDataChanged(); @@ -1080,7 +1074,7 @@ bool QAction::isVisible() const bool QAction::event(QEvent *e) { -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (e->type() == QEvent::Shortcut) { QShortcutEvent *se = static_cast(e); Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()), @@ -1351,7 +1345,7 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action) d << " toolTip=" << action->toolTip(); if (action->isCheckable()) d << " checked=" << action->isChecked(); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (!action->shortcut().isEmpty()) d << " shortcut=" << action->shortcut(); #endif diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index 84bf92d2acc..f7693f4dde0 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -72,7 +72,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip NOTIFY changed) Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis NOTIFY changed) Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed) -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut NOTIFY changed) Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext NOTIFY changed) Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY changed) @@ -129,7 +129,7 @@ public: void setSeparator(bool b); bool isSeparator() const; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) void setShortcut(const QKeySequence &shortcut); QKeySequence shortcut() const; diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h index 19ae47c7b90..6b6ca8076f3 100644 --- a/src/widgets/kernel/qaction_p.h +++ b/src/widgets/kernel/qaction_p.h @@ -89,15 +89,15 @@ public: QString tooltip; QString statustip; QString whatsthis; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) QKeySequence shortcut; QList alternateShortcuts; #endif QVariant userData; -#ifndef QT_NO_SHORTCUT - int shortcutId; +#if QT_CONFIG(shortcut) + int shortcutId = 0; QVector alternateShortcutIds; - Qt::ShortcutContext shortcutContext; + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut; uint autorepeat : 1; #endif QFont font; @@ -112,19 +112,17 @@ public: int iconVisibleInMenu : 2; // Only has values -1, 0, and 1 int shortcutVisibleInContextMenu : 2; // Only has values -1, 0, and 1 - QAction::MenuRole menuRole; - QAction::Priority priority; + QAction::MenuRole menuRole = QAction::TextHeuristicRole; + QAction::Priority priority = QAction::NormalPriority; - QList widgets; + QWidgetList widgets; #if QT_CONFIG(graphicsview) QList graphicsWidgets; #endif -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) void redoGrab(QShortcutMap &map); void redoGrabAlternate(QShortcutMap &map); void setShortcutEnabled(bool enable, QShortcutMap &map); - - static QShortcutMap *globalMap; #endif // QT_NO_SHORTCUT void sendDataChanged(); diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp index ab42b1c7aaa..1d9213de0c0 100644 --- a/src/widgets/kernel/qactiongroup.cpp +++ b/src/widgets/kernel/qactiongroup.cpp @@ -42,7 +42,6 @@ #ifndef QT_NO_ACTION #include "qaction_p.h" -#include "qapplication.h" #include "qevent.h" #include "qlist.h" @@ -73,7 +72,7 @@ void QActionGroupPrivate::_q_actionChanged() { Q_Q(QActionGroup); QAction *action = qobject_cast(q->sender()); - Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionChanged", "internal error"); + Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionChanged", "internal error"); if (exclusionPolicy != QActionGroup::ExclusionPolicy::None) { if (action->isChecked()) { if (action != current) { @@ -91,7 +90,7 @@ void QActionGroupPrivate::_q_actionTriggered() { Q_Q(QActionGroup); QAction *action = qobject_cast(q->sender()); - Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionTriggered", "internal error"); + Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionTriggered", "internal error"); emit q->triggered(action); } @@ -99,7 +98,7 @@ void QActionGroupPrivate::_q_actionHovered() { Q_Q(QActionGroup); QAction *action = qobject_cast(q->sender()); - Q_ASSERT_X(action != 0, "QWidgetGroup::_q_actionHovered", "internal error"); + Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionHovered", "internal error"); emit q->hovered(action); } @@ -363,10 +362,10 @@ void QActionGroup::setEnabled(bool b) { Q_D(QActionGroup); d->enabled = b; - for(QList::const_iterator it = d->actions.constBegin(); it != d->actions.constEnd(); ++it) { - if(!(*it)->d_func()->forceDisabled) { - (*it)->setEnabled(b); - (*it)->d_func()->forceDisabled = false; + for (auto action : qAsConst(d->actions)) { + if (!action->d_func()->forceDisabled) { + action->setEnabled(b); + action->d_func()->forceDisabled = false; } } } @@ -400,10 +399,10 @@ void QActionGroup::setVisible(bool b) { Q_D(QActionGroup); d->visible = b; - for(QList::Iterator it = d->actions.begin(); it != d->actions.end(); ++it) { - if(!(*it)->d_func()->forceInvisible) { - (*it)->setVisible(b); - (*it)->d_func()->forceInvisible = false; + for (auto action : qAsConst(d->actions)) { + if (!action->d_func()->forceInvisible) { + action->setVisible(b); + action->d_func()->forceInvisible = false; } } } From 3ccbf19761ec203a88480d25f147cac047a58ee3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 24 Jun 2019 13:38:54 +0200 Subject: [PATCH 050/172] QSocks5SocketEnginePrivate::sendRequestMethod(): Fix out of bounds string access Fix warnings showing in network tests: tst_QNetworkReply::headFromHttp(rfc+socks): Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt. introduced by qtbase/c2d2757bccc68e1b981df059786c2e76f2969530 (5.14). Replace index access by QByteArray::append(). Change-Id: I0b4aed563d076237d5f9cc6aa438c7502eb3568c Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira Reviewed-by: Timur Pocheptsov --- src/network/socket/qsocks5socketengine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 23aec123904..47b500227f0 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -801,9 +801,9 @@ void QSocks5SocketEnginePrivate::sendRequestMethod() QByteArray buf; buf.reserve(270); // big enough for domain name; - buf[0] = S5_VERSION_5; - buf[1] = command; - buf[2] = 0x00; + buf.append(char(S5_VERSION_5)); + buf.append(command); + buf.append('\0'); if (peerName.isEmpty() && !qt_socks5_set_host_address_and_port(address, port, &buf)) { QSOCKS5_DEBUG << "error setting address" << address << " : " << port; //### set error code .... From e65ea360187bbbf50f844a965faddc392322a0e7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 26 Jun 2019 10:36:46 +0200 Subject: [PATCH 051/172] RHI: Fix deprecation warnings about QAtomicInteger::load() Replace by loadRelaxed(), fixing: rhi\qrhi.cpp: In static member function 'static QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBuffer(int, QRhiShaderResourceBinding::StageFlags, QRhiBuffer*)': rhi\qrhi.cpp:2578:26: warning: 'T QBasicAtomicInteger::load() const [with T = int]' is deprecated: Use loadRelaxed [-Wdeprecated-declarations] Q_ASSERT(d->ref.load() == 1); Change-Id: Iebe9a62d20498e67bde34b2f0cab8cc38682154f Reviewed-by: Laszlo Agocs Reviewed-by: Giuseppe D'Angelo --- src/gui/rhi/qrhi.cpp | 8 ++++---- src/gui/rhi/qshader.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 927de859dde..334fa1064a6 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2575,7 +2575,7 @@ QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBuffer( { QRhiShaderResourceBinding b; QRhiShaderResourceBindingPrivate *d = QRhiShaderResourceBindingPrivate::get(&b); - Q_ASSERT(d->ref.load() == 1); + Q_ASSERT(d->ref.loadRelaxed() == 1); d->binding = binding; d->stage = stage; d->type = UniformBuffer; @@ -2639,7 +2639,7 @@ QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTexture( { QRhiShaderResourceBinding b; QRhiShaderResourceBindingPrivate *d = QRhiShaderResourceBindingPrivate::get(&b); - Q_ASSERT(d->ref.load() == 1); + Q_ASSERT(d->ref.loadRelaxed() == 1); d->binding = binding; d->stage = stage; d->type = SampledTexture; @@ -2661,7 +2661,7 @@ QRhiShaderResourceBinding QRhiShaderResourceBinding::imageLoad( { QRhiShaderResourceBinding b; QRhiShaderResourceBindingPrivate *d = QRhiShaderResourceBindingPrivate::get(&b); - Q_ASSERT(d->ref.load() == 1); + Q_ASSERT(d->ref.loadRelaxed() == 1); d->binding = binding; d->stage = stage; d->type = ImageLoad; @@ -2715,7 +2715,7 @@ QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoad( { QRhiShaderResourceBinding b; QRhiShaderResourceBindingPrivate *d = QRhiShaderResourceBindingPrivate::get(&b); - Q_ASSERT(d->ref.load() == 1); + Q_ASSERT(d->ref.loadRelaxed() == 1); d->binding = binding; d->stage = stage; d->type = BufferLoad; diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 4676ec3f5b2..9098180f69d 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -389,7 +389,7 @@ QShader QShader::fromSerialized(const QByteArray &data) QShader bs; QShaderPrivate *d = QShaderPrivate::get(&bs); - Q_ASSERT(d->ref.load() == 1); // must be detached + Q_ASSERT(d->ref.loadRelaxed() == 1); // must be detached int intVal; ds >> intVal; if (intVal != QSB_VERSION) From 4b63288a60ae47777427f08951b7cb4ede12a804 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 20 Jun 2019 15:00:51 +0200 Subject: [PATCH 052/172] tst_QAction(Group): Brush up the tests - Use nullptr - Use Qt 5 connection syntax - Remove C-Style casts Task-number: QTBUG-69478 Change-Id: Icf8faf3433ff3bff667db050e79b560b221867b0 Reviewed-by: Richard Moe Gustavsen --- .../widgets/kernel/qaction/tst_qaction.cpp | 60 +++++++++---------- .../kernel/qactiongroup/tst_qactiongroup.cpp | 18 +++--- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 3d68e42baf2..0d62c2cd4b2 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -70,7 +70,7 @@ private slots: void shortcutFromKeyEvent(); // QTBUG-48325 private: - int m_lastEventType; + QEvent::Type m_lastEventType; const int m_keyboardScheme; QAction *m_lastAction; }; @@ -82,7 +82,7 @@ tst_QAction::tst_QAction() void tst_QAction::init() { - m_lastEventType = 0; + m_lastEventType = QEvent::None; m_lastAction = nullptr; } @@ -94,23 +94,23 @@ void tst_QAction::cleanup() // Testing get/set functions void tst_QAction::getSetCheck() { - QAction obj1(0); + QAction obj1(nullptr); // QActionGroup * QAction::actionGroup() // void QAction::setActionGroup(QActionGroup *) - QActionGroup *var1 = new QActionGroup(0); + QActionGroup *var1 = new QActionGroup(nullptr); obj1.setActionGroup(var1); QCOMPARE(var1, obj1.actionGroup()); - obj1.setActionGroup((QActionGroup *)0); - QCOMPARE((QActionGroup *)0, obj1.actionGroup()); + obj1.setActionGroup(nullptr); + QCOMPARE(obj1.actionGroup(), nullptr); delete var1; // QMenu * QAction::menu() // void QAction::setMenu(QMenu *) - QMenu *var2 = new QMenu(0); + QMenu *var2 = new QMenu(nullptr); obj1.setMenu(var2); QCOMPARE(var2, obj1.menu()); - obj1.setMenu((QMenu *)0); - QCOMPARE((QMenu *)0, obj1.menu()); + obj1.setMenu(nullptr); + QCOMPARE(obj1.menu(), nullptr); delete var2; QCOMPARE(obj1.priority(), QAction::NormalPriority); @@ -148,7 +148,7 @@ void tst_QAction::setText() { QFETCH(QString, text); - QAction action(0); + QAction action(nullptr); action.setText(text); QCOMPARE(action.text(), text); @@ -161,7 +161,7 @@ void tst_QAction::setIconText() { QFETCH(QString, iconText); - QAction action(0); + QAction action(nullptr); action.setIconText(iconText); QCOMPARE(action.iconText(), iconText); @@ -171,7 +171,7 @@ void tst_QAction::setIconText() void tst_QAction::setUnknownFont() // QTBUG-42728 { - QAction action(0); + QAction action(nullptr); QFont font("DoesNotExist", 11); action.setFont(font); @@ -182,17 +182,17 @@ void tst_QAction::setUnknownFont() // QTBUG-42728 void tst_QAction::updateState(QActionEvent *e) { if (!e) { - m_lastEventType = 0; - m_lastAction = 0; + m_lastEventType = QEvent::None; + m_lastAction = nullptr; } else { - m_lastEventType = (int)e->type(); + m_lastEventType = e->type(); m_lastAction = e->action(); } } void tst_QAction::actionEvent() { - QAction a(0); + QAction a(nullptr); a.setText("action text"); // add action @@ -202,33 +202,33 @@ void tst_QAction::actionEvent() testWidget.addAction(&a); qApp->processEvents(); - QCOMPARE(m_lastEventType, (int)QEvent::ActionAdded); + QCOMPARE(m_lastEventType, QEvent::ActionAdded); QCOMPARE(m_lastAction, &a); // change action a.setText("new action text"); qApp->processEvents(); - QCOMPARE(m_lastEventType, (int)QEvent::ActionChanged); + QCOMPARE(m_lastEventType, QEvent::ActionChanged); QCOMPARE(m_lastAction, &a); // remove action testWidget.removeAction(&a); qApp->processEvents(); - QCOMPARE(m_lastEventType, (int)QEvent::ActionRemoved); + QCOMPARE(m_lastEventType, QEvent::ActionRemoved); QCOMPARE(m_lastAction, &a); } //basic testing of standard keys void tst_QAction::setStandardKeys() { - QAction act(0); + QAction act(nullptr); act.setShortcut(QKeySequence("CTRL+L")); QList list; act.setShortcuts(list); act.setShortcuts(QKeySequence::Copy); - QCOMPARE(act.shortcut(), act.shortcuts().first()); + QCOMPARE(act.shortcut(), act.shortcuts().constFirst()); QList expected; const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); @@ -263,7 +263,7 @@ void tst_QAction::alternateShortcuts() QList shlist = QList() << QKeySequence("CTRL+P") << QKeySequence("CTRL+A"); act.setShortcuts(shlist); - QSignalSpy spy(&act, SIGNAL(triggered())); + QSignalSpy spy(&act, &QAction::triggered); act.setAutoRepeat(true); QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier); @@ -322,7 +322,7 @@ void tst_QAction::enabledVisibleInteraction() testWidget.show(); QApplication::setActiveWindow(&testWidget); - QAction act(0); + QAction act(nullptr); // check defaults QVERIFY(act.isEnabled()); QVERIFY(act.isVisible()); @@ -370,7 +370,7 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup() { // test without a group const QScopedPointer actionWithoutGroup(new QAction("Test", nullptr)); - QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), SIGNAL(triggered(bool))); + QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload::of(&QAction::triggered)); QCOMPARE(spyWithoutGroup.count(), 0); actionWithoutGroup->trigger(); // signal should be emitted @@ -388,7 +388,7 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup() void tst_QAction::task229128TriggeredSignalWhenInActiongroup() { - QActionGroup ag(0); + QActionGroup ag(nullptr); QAction *action = new QAction("Test", &ag); QAction *checkedAction = new QAction("Test 2", &ag); ag.addAction(action); @@ -397,8 +397,8 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() checkedAction->setCheckable(true); checkedAction->setChecked(true); - QSignalSpy actionSpy(checkedAction, SIGNAL(triggered(bool))); - QSignalSpy actionGroupSpy(&ag, SIGNAL(triggered(QAction*))); + QSignalSpy actionSpy(checkedAction, QOverload::of(&QAction::triggered)); + QSignalSpy actionGroupSpy(&ag, QOverload::of(&QActionGroup::triggered)); QCOMPARE(actionGroupSpy.count(), 0); QCOMPARE(actionSpy.count(), 0); checkedAction->trigger(); @@ -513,10 +513,10 @@ void tst_QAction::disableShortcutsWithBlockedWidgets() class ShortcutOverrideWidget : public QWidget { public: - ShortcutOverrideWidget(QWidget *parent = 0) : QWidget(parent), shortcutOverrideCount(0) {} - int shortcutOverrideCount; + using QWidget::QWidget; + int shortcutOverrideCount = 0; protected: - bool event(QEvent *e) + bool event(QEvent *e) override { if (e->type() == QEvent::ShortcutOverride) ++shortcutOverrideCount; diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp index 64e5b969e7e..524040d0039 100644 --- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp @@ -49,11 +49,11 @@ private slots: void tst_QActionGroup::enabledPropagation() { - QActionGroup testActionGroup( 0 ); + QActionGroup testActionGroup(nullptr); QAction* childAction = new QAction( &testActionGroup ); QAction* anotherChildAction = new QAction( &testActionGroup ); - QAction* freeAction = new QAction(0); + QAction* freeAction = new QAction(nullptr); QVERIFY( testActionGroup.isEnabled() ); QVERIFY( childAction->isEnabled() ); @@ -88,11 +88,11 @@ void tst_QActionGroup::enabledPropagation() void tst_QActionGroup::visiblePropagation() { - QActionGroup testActionGroup( 0 ); + QActionGroup testActionGroup(nullptr); QAction* childAction = new QAction( &testActionGroup ); QAction* anotherChildAction = new QAction( &testActionGroup ); - QAction* freeAction = new QAction(0); + QAction* freeAction = new QAction(nullptr); QVERIFY( testActionGroup.isVisible() ); QVERIFY( childAction->isVisible() ); @@ -125,7 +125,7 @@ void tst_QActionGroup::visiblePropagation() void tst_QActionGroup::exclusive() { - QActionGroup group(0); + QActionGroup group(nullptr); group.setExclusive(false); QVERIFY( !group.isExclusive() ); @@ -215,7 +215,7 @@ void tst_QActionGroup::separators() menu.addActions(actGroup.actions()); - QCOMPARE((int)menu.actions().size(), 2); + QCOMPARE(menu.actions().size(), 2); const auto removeActions = [&menu](const QList &actions) { for (QAction *action : actions) @@ -223,14 +223,14 @@ void tst_QActionGroup::separators() }; removeActions(actGroup.actions()); - QCOMPARE((int)menu.actions().size(), 0); + QCOMPARE(menu.actions().size(), 0); action = new QAction(&actGroup); action->setText("test two"); menu.addActions(actGroup.actions()); - QCOMPARE((int)menu.actions().size(), 3); + QCOMPARE(menu.actions().size(), 3); } void tst_QActionGroup::testActionInTwoQActionGroup() @@ -250,7 +250,7 @@ void tst_QActionGroup::testActionInTwoQActionGroup() void tst_QActionGroup::unCheckCurrentAction() { - QActionGroup group(0); + QActionGroup group(nullptr); QAction action1(&group) ,action2(&group); action1.setCheckable(true); action2.setCheckable(true); From 5fb5ec93d69e6bfa918b643f2291503e57d13ad0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 Jun 2019 11:20:55 +0200 Subject: [PATCH 053/172] QImageWriter/XPM: Fix out of bounds string access Fix warnings: QWWARN : tst_QImageReader::readFromFileAfterJunk(xpm) Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt. QWARN : tst_QImageReader::readFromFileAfterJunk(xpm) Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt. QWARN : tst_QImageReader::readFromFileAfterJunk(xpm) Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt. introduced by qtbase/c2d2757bccc68e1b981df059786c2e76f2969530 (5.14). Refactor write_xpm_image() to use a QByteArray and append(). Change-Id: I25e6270e2e5fcb868d4ee38e3b294afc7ee27dcc Reviewed-by: Eirik Aavitsland --- src/gui/image/qxpmhandler.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index deff56aa588..cf105b250ad 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1125,8 +1125,6 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const break; } - QString line; - // write header QTextStream s(device); s << "/* XPM */" << Qt::endl @@ -1137,35 +1135,29 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const QMap::Iterator c = colorMap.begin(); while (c != colorMap.end()) { QRgb color = c.key(); - if (image.format() != QImage::Format_RGB32 && !qAlpha(color)) - line = QString::asprintf("\"%s c None\"", - xpm_color_name(cpp, *c)); - else - line = QString::asprintf("\"%s c #%02x%02x%02x\"", - xpm_color_name(cpp, *c), - qRed(color), - qGreen(color), - qBlue(color)); + const QString line = image.format() != QImage::Format_RGB32 && !qAlpha(color) + ? QString::asprintf("\"%s c None\"", xpm_color_name(cpp, *c)) + : QString::asprintf("\"%s c #%02x%02x%02x\"", xpm_color_name(cpp, *c), + qRed(color), qGreen(color), qBlue(color)); ++c; s << ',' << Qt::endl << line; } // write pixels, limit to 4 characters per pixel - line.truncate(cpp*w); + QByteArray line; for(y=0; y(image.constScanLine(y)); - int cc = 0; for(x=0; x 1) { - line[cc++] = QLatin1Char(chars[1]); + line.append(chars[1]); if (cpp > 2) { - line[cc++] = QLatin1Char(chars[2]); - if (cpp > 3) { - line[cc++] = QLatin1Char(chars[3]); - } + line.append(chars[2]); + if (cpp > 3) + line.append(chars[3]); } } } From 6301d5e51b0c56d09b0bd1cb63f4908c3f8e2c70 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 27 Jun 2019 14:58:41 +0200 Subject: [PATCH 054/172] uic: Add option to disable the call to QObject::connectSlotsByName() The code was actually there, but not connected to the command line parser. Task-number: QTBUG-76375 Change-Id: I801cf2bbd2f207a6ce1dabd1ee1dfbd892089bbc Reviewed-by: Jarek Kobus --- src/tools/uic/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index 439789d2210..9cf22d502d1 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -68,6 +68,10 @@ int runUic(int argc, char *argv[]) outputOption.setValueName(QStringLiteral("file")); parser.addOption(outputOption); + QCommandLineOption noAutoConnectionOption(QStringList() << QStringLiteral("a") << QStringLiteral("no-autoconnection")); + noAutoConnectionOption.setDescription(QStringLiteral("Do not generate a call to QObject::connectSlotsByName().")); + parser.addOption(noAutoConnectionOption); + QCommandLineOption noProtOption(QStringList() << QStringLiteral("p") << QStringLiteral("no-protection")); noProtOption.setDescription(QStringLiteral("Disable header protection.")); parser.addOption(noProtOption); @@ -110,6 +114,7 @@ int runUic(int argc, char *argv[]) driver.option().dependencies = parser.isSet(dependenciesOption); driver.option().outputFile = parser.value(outputOption); + driver.option().autoConnection = !parser.isSet(noAutoConnectionOption); driver.option().headerProtection = !parser.isSet(noProtOption); driver.option().implicitIncludes = !parser.isSet(noImplicitIncludesOption); driver.option().idBased = parser.isSet(idBasedOption); From 94bee657c1d6d1207c82cdb5eddef8945f262618 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 27 Jun 2019 15:17:29 +0200 Subject: [PATCH 055/172] uic: Fix remaining clang warnings Fix remaining nullptr and member initialization issues which Qt Creator did not catch. Change-Id: If5492259aea9849c790f00809a27f4c78b446b9b Reviewed-by: Jarek Kobus --- src/tools/uic/cpp/cppwriteincludes.cpp | 2 +- src/tools/uic/cpp/cppwriteincludes.h | 2 +- src/tools/uic/cpp/cppwriteinitialization.cpp | 13 ++++--------- src/tools/uic/cpp/cppwriteinitialization.h | 10 +++++----- src/tools/uic/customwidgetsinfo.cpp | 4 ++-- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 0ba49627c0f..71e02ae9c91 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -69,7 +69,7 @@ static inline QString moduleHeader(const QString &module, const QString &header) namespace CPP { WriteIncludes::WriteIncludes(Uic *uic) - : m_uic(uic), m_output(uic->output()), m_laidOut(false) + : m_uic(uic), m_output(uic->output()) { // When possible (no namespace) use the "QtModule/QClass" convention // and create a re-mapping of the old header "qclass.h" to it. Do not do this diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h index aadc6f54fc8..9b9ac283fe7 100644 --- a/src/tools/uic/cpp/cppwriteincludes.h +++ b/src/tools/uic/cpp/cppwriteincludes.h @@ -101,7 +101,7 @@ private: StringMap m_classToHeader; StringMap m_oldHeaderToNewHeader; - bool m_laidOut; + bool m_laidOut = false; }; } // namespace CPP diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 85b9a9f60b7..4185d3ba703 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -455,22 +455,17 @@ WriteInitialization::WriteInitialization(Uic *uic) : m_driver(uic->driver()), m_output(uic->output()), m_option(uic->option()), m_indent(m_option.indent + m_option.indent), m_dindent(m_indent + m_option.indent), - m_stdsetdef(true), - m_layoutMarginType(TopLevelMargin), - m_mainFormUsedInRetranslateUi(false), m_delayedOut(&m_delayedInitialization, QIODevice::WriteOnly), m_refreshOut(&m_refreshInitialization, QIODevice::WriteOnly), - m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly), - m_layoutWidget(false), - m_firstThemeIcon(true) + m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly) { } void WriteInitialization::acceptUI(DomUI *node) { - m_actionGroupChain.push(0); - m_widgetChain.push(0); - m_layoutChain.push(0); + m_actionGroupChain.push(nullptr); + m_widgetChain.push(nullptr); + m_layoutChain.push(nullptr); acceptLayoutDefault(node->elementLayoutDefault()); acceptLayoutFunction(node->elementLayoutFunction()); diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index 3cd0efeaac5..a28dfc1b25f 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -244,7 +244,7 @@ private: const Option &m_option; QString m_indent; QString m_dindent; - bool m_stdsetdef; + bool m_stdsetdef = true; struct Buddy { @@ -294,11 +294,11 @@ private: // layout defaults LayoutDefaultHandler m_LayoutDefaultHandler; - int m_layoutMarginType; + int m_layoutMarginType = TopLevelMargin; QString m_generatedClass; QString m_mainFormVarName; - bool m_mainFormUsedInRetranslateUi; + bool m_mainFormUsedInRetranslateUi = false; QString m_delayedInitialization; QTextStream m_delayedOut; @@ -309,8 +309,8 @@ private: QString m_delayedActionInitialization; QTextStream m_actionOut; - bool m_layoutWidget; - bool m_firstThemeIcon; + bool m_layoutWidget = false; + bool m_firstThemeIcon = true; }; } // namespace CPP diff --git a/src/tools/uic/customwidgetsinfo.cpp b/src/tools/uic/customwidgetsinfo.cpp index d6a409152b8..c838feaf730 100644 --- a/src/tools/uic/customwidgetsinfo.cpp +++ b/src/tools/uic/customwidgetsinfo.cpp @@ -95,7 +95,7 @@ bool CustomWidgetsInfo::extendsOneOf(const QString &classNameIn, bool CustomWidgetsInfo::isCustomWidgetContainer(const QString &className) const { - if (const DomCustomWidget *dcw = m_customWidgets.value(className, 0)) + if (const DomCustomWidget *dcw = m_customWidgets.value(className, nullptr)) if (dcw->hasElementContainer()) return dcw->elementContainer() != 0; return false; @@ -111,7 +111,7 @@ QString CustomWidgetsInfo::realClassName(const QString &className) const QString CustomWidgetsInfo::customWidgetAddPageMethod(const QString &name) const { - if (DomCustomWidget *dcw = m_customWidgets.value(name, 0)) + if (DomCustomWidget *dcw = m_customWidgets.value(name, nullptr)) return dcw->elementAddPageMethod(); return QString(); } From 8f0e3ad5188d17c88f624eeea9a67ab17e55cc6f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 24 Jun 2019 14:41:36 +0200 Subject: [PATCH 056/172] Corelib tests: Fix out of bounds string access Fix warnings: Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt. introduced by qtbase/c2d2757bccc68e1b981df059786c2e76f2969530 (5.14). Change-Id: Ie6f0e2e3bb198a95dd40e7416adc8ffb29f3b2ba Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/collections/tst_collections.cpp | 2 +- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index b911be3ffb6..2a8b2649981 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -1370,7 +1370,7 @@ void tst_Collections::hash() { typedef QHash Hash; Hash hash; - QString key; + QString key = QLatin1String(" "); for (int i = 0; i < 10; ++i) { key[0] = i + '0'; for (int j = 0; j < 10; ++j) { diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index d70d488e961..f0aaad98bd2 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -273,7 +273,7 @@ void tst_QHash::insert1() { typedef QHash Hash; Hash hash; - QString key; + QString key = QLatin1String(" "); for (int i = 0; i < 10; ++i) { key[0] = i + '0'; for (int j = 0; j < 10; ++j) { From df7c97f8eed00a1dcd24a815d89d2842f7d6d116 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 27 Jun 2019 16:14:30 +0200 Subject: [PATCH 057/172] qsslsocket_openssl.cpp - restructure the code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit not to resolve merge conflicts on every 5.13->dev merge. Change-Id: Id41a7efff52148fe46bedcde828646694fd1764d Reviewed-by: Mårten Nordheim --- src/network/ssl/qsslsocket_openssl.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 4bd2f4c99a4..c0035d23a84 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1572,12 +1572,10 @@ bool QSslSocketBackendPrivate::checkOcspStatus() // verify the responder's chain (see their commit 4ba9a4265bd). // Working this around - is too much fuss for ancient versions we // are dropping quite soon anyway. - { - const unsigned long verificationFlags = 0; - const int success = q_OCSP_basic_verify(basicResponse, peerChain, store, verificationFlags); - if (success <= 0) - ocspErrors.push_back(QSslError::OcspResponseCannotBeTrusted); - } + const unsigned long verificationFlags = 0; + const int success = q_OCSP_basic_verify(basicResponse, peerChain, store, verificationFlags); + if (success <= 0) + ocspErrors.push_back(QSslError::OcspResponseCannotBeTrusted); if (q_OCSP_resp_count(basicResponse) != 1) { ocspErrors.push_back(QSslError::OcspMalformedResponse); From f66c1db16c050c9d685a44a38ad7c5cf9f6fcc96 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 30 Apr 2019 09:39:21 +0200 Subject: [PATCH 058/172] Introduce Q_NAMESPACE_EXPORT A recurring problem with the Q_NAMESPACE macro is that it declares an object (staticMetaObject) in the surrounding namespace. That object lacks any export/import qualification to make it usable with shared libraries. Introduce therefore another macro to work around this issue, allowing the user to prefix the object with an exporting macro, f.i. like this: Q_NAMESPACE_EXPORT(Q_CORE_EXPORT) The old macro can simply then be rewritten in terms of this new one, supplying an empty export macro. Note that NOT passing an argument to a macro expecting one is well defined behavior in C99 -- the macro will expand an empty token. Of course, MSVC doesn't like this and emits warnings. As a workaround, use a variadic macro. [ChangeLog][QtCore] Added the new Q_NAMESPACE_EXPORT macro. It can be used just like Q_NAMESPACE to add meta-object information to a namespace; however it also supports exporting of such information from shared libraries. [ChangeLog][Potentially Source-Incompatible Changes] Prefixing Q_NAMESPACE with an export macro may no longer work. Use the new Q_NAMESPACE_EXPORT macro for that use case. Fixes: QTBUG-68014 Change-Id: Ib044a555ace1f77ae8e0244d824ec473550f3d8e Reviewed-by: Edward Welbourne Reviewed-by: Qt CI Bot Reviewed-by: BogDan Vatra --- doc/global/qt-cpp-defines.qdocconf | 1 + qmake/generators/makefiledeps.cpp | 14 +- src/corelib/kernel/qobject.cpp | 18 ++ src/corelib/kernel/qobjectdefs.h | 10 +- src/gui/util/qshaderlanguage_p.h | 2 +- src/tools/moc/keywords.cpp | 359 ++++++++++++----------- src/tools/moc/moc.cpp | 7 + src/tools/moc/token.h | 1 + src/tools/moc/util/generate_keywords.cpp | 1 + tests/auto/tools/moc/tst_moc.cpp | 15 + 10 files changed, 245 insertions(+), 183 deletions(-) diff --git a/doc/global/qt-cpp-defines.qdocconf b/doc/global/qt-cpp-defines.qdocconf index a4864701873..4cf895b05e7 100644 --- a/doc/global/qt-cpp-defines.qdocconf +++ b/doc/global/qt-cpp-defines.qdocconf @@ -118,6 +118,7 @@ Cpp.ignoretokens += \ Q_POSITIONING_EXPORT \ Q_MULTIMEDIA_EXPORT \ Q_NAMESPACE \ + Q_NAMESPACE_EXPORT \ Q_NETWORK_EXPORT \ Q_NEVER_INLINE \ Q_NORETURN \ diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index 1995cf63ba5..69a32177235 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -946,10 +946,12 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) debug_msg(2, "findMocs: %s", file->file.local().toLatin1().constData()); int line_count = 1; - bool ignore[3] = { false, false, false }; // [0] for Q_OBJECT, [1] for Q_GADGET, [2] for Q_NAMESPACE + // [0] for Q_OBJECT, [1] for Q_GADGET, [2] for Q_NAMESPACE, [3] for Q_NAMESPACE_EXPORT + bool ignore[4] = { false, false, false, false }; /* qmake ignore Q_GADGET */ /* qmake ignore Q_OBJECT */ /* qmake ignore Q_NAMESPACE */ + /* qmake ignore Q_NAMESPACE_EXPORT */ for(int x = 0; x < buffer_len; x++) { #define SKIP_BSNL(pos) skipEscapedLineEnds(buffer, buffer_len, (pos), &line_count) x = SKIP_BSNL(x); @@ -988,6 +990,12 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) file->file.real().toLatin1().constData(), line_count); x += 23; ignore[2] = true; + } else if (buffer_len >= (x + 30) && + !strncmp(buffer + x + 1, "make ignore Q_NAMESPACE_EXPORT", 30)) { + debug_msg(2, "Mocgen: %s:%d Found \"qmake ignore Q_NAMESPACE_EXPORT\"", + file->file.real().toLatin1().constData(), line_count); + x += 30; + ignore[3] = true; } } else if (buffer[x] == '*') { extralines = 0; @@ -1015,8 +1023,8 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) int morelines = 0; int y = skipEscapedLineEnds(buffer, buffer_len, x + 1, &morelines); if (buffer[y] == 'Q') { - static const char interesting[][12] = { "Q_OBJECT", "Q_GADGET", "Q_NAMESPACE"}; - for (int interest = 0; interest < 3; ++interest) { + static const char interesting[][19] = { "Q_OBJECT", "Q_GADGET", "Q_NAMESPACE", "Q_NAMESPACE_EXPORT" }; + for (int interest = 0; interest < 4; ++interest) { if (ignore[interest]) continue; diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index e3b25f8bf7a..1540ebfe122 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4526,6 +4526,24 @@ QDebug operator<<(QDebug dbg, const QObject *o) Q_NAMESPACE makes an external variable, \c{staticMetaObject}, available. \c{staticMetaObject} is of type QMetaObject and provides access to the enums declared with Q_ENUM_NS/Q_FLAG_NS. + + \sa Q_NAMESPACE_EXPORT +*/ + +/*! + \macro Q_NAMESPACE_EXPORT(EXPORT_MACRO) + \relates QObject + \since 5.14 + + The Q_NAMESPACE_EXPORT macro can be used to add QMetaObject capabilities + to a namespace. + + It works exactly like the Q_NAMESPACE macro. However, the external + \c{staticMetaObject} variable that gets defined in the namespace + is declared with the supplied \c{EXPORT_MACRO} qualifier. This is + useful f.i. if the object needs to be exported from a dynamic library. + + \sa Q_NAMESPACE, {Creating Shared Libraries} */ /*! diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 4d5ac4dcb26..ef22b6e67fa 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -201,12 +201,16 @@ private: \ QT_ANNOTATE_CLASS(qt_qgadget, "") \ /*end*/ -/* qmake ignore Q_NAMESPACE */ -#define Q_NAMESPACE \ - extern const QMetaObject staticMetaObject; \ +/* qmake ignore Q_NAMESPACE_EXPORT */ +#define Q_NAMESPACE_EXPORT(...) \ + extern __VA_ARGS__ const QMetaObject staticMetaObject; \ QT_ANNOTATE_CLASS(qt_qnamespace, "") \ /*end*/ +/* qmake ignore Q_NAMESPACE */ +#define Q_NAMESPACE Q_NAMESPACE_EXPORT() \ + /*end*/ + #endif // QT_NO_META_MACROS #else // Q_MOC_RUN diff --git a/src/gui/util/qshaderlanguage_p.h b/src/gui/util/qshaderlanguage_p.h index 3af967b8c67..193f797cc30 100644 --- a/src/gui/util/qshaderlanguage_p.h +++ b/src/gui/util/qshaderlanguage_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE namespace QShaderLanguage { - Q_GUI_EXPORT Q_NAMESPACE + Q_NAMESPACE_EXPORT(Q_GUI_EXPORT) enum StorageQualifier : char { Const = 1, diff --git a/src/tools/moc/keywords.cpp b/src/tools/moc/keywords.cpp index 07c59d155f5..7da8d94efc1 100644 --- a/src/tools/moc/keywords.cpp +++ b/src/tools/moc/keywords.cpp @@ -30,12 +30,12 @@ // DO NOT EDIT. static const short keyword_trans[][128] = { - {0,0,0,0,0,0,0,0,0,561,558,0,0,0,0,0, + {0,0,0,0,0,0,0,0,0,568,565,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 561,252,559,562,8,38,239,560,25,26,236,234,30,235,27,237, + 568,252,566,569,8,38,239,567,25,26,236,234,30,235,27,237, 22,22,22,22,22,22,22,22,22,22,34,41,23,39,24,43, 0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,21,8,8,8,8,8,8,8,8,8,31,564,32,238,8, + 8,21,8,8,8,8,8,8,8,8,8,31,571,32,238,8, 0,1,2,3,4,5,6,7,8,9,8,8,10,11,12,13, 14,8,15,16,17,18,19,20,8,8,8,36,245,37,248,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -116,7 +116,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,290,222,0,0,490,0,0,0, + 0,0,0,0,0,0,0,0,290,222,0,0,497,0,0,0, 0,0,0,0,55,0,0,330,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -155,7 +155,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,514,0,0,0,0,0,0,0,0,0,0,357, + 0,0,0,0,521,0,0,0,0,0,0,0,0,0,0,357, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -177,7 +177,7 @@ static const short keyword_trans[][128] = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,42,0,0,0,28,0, - 567,567,567,567,567,567,567,567,567,567,0,0,0,0,0,0, + 574,574,574,574,574,574,574,574,574,574,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -336,7 +336,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,566,0,0,0,0,565, + 0,0,0,0,0,0,0,0,0,0,573,0,0,0,0,572, 0,0,0,0,0,0,0,0,0,0,0,0,0,258,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -372,29 +372,29 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,487,0,0,0,300,0,0,0,0,0,0,0,0,0,0, + 0,494,0,0,0,300,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,468,417,401,409,373,0,477,0,0,0,0,364,358, - 379,0,550,465,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,475,424,408,416,380,0,484,0,0,0,0,364,358, + 386,0,557,472,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,387,0,0,0, - 0,0,380,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,394,0,0,0, + 0,0,387,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,504,0,0,0,0,0,381, + 0,0,0,0,0,0,0,0,0,511,0,0,0,0,0,388, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, @@ -403,7 +403,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,405,0,0,0,0,0,0,0,0,0,0,0,406, + 0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,413, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -411,14 +411,14 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,413,0,0,0,0,0,0,0,0,0,0,0,414, + 0,0,0,420,0,0,0,0,0,0,0,0,0,0,0,421, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,447,425,0,0,430,0,0,0,439,0,0, + 0,0,0,0,0,454,432,0,0,437,0,0,0,446,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, @@ -426,7 +426,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,533,0,466,0,0,0,494,0,0,500,0,0,0, + 0,0,0,540,0,473,0,0,0,501,0,0,507,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, @@ -435,7 +435,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,479,0,526,0,0,0,0,0,0,0,0,0, + 0,0,0,0,486,0,533,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -443,7 +443,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 542,0,0,510,0,0,0,0,0,0,0,0,0,0,0,0, + 549,0,0,517,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; @@ -828,197 +828,204 @@ static const struct {CHARACTER, 0, 65, 370, CHARACTER}, {CHARACTER, 0, 67, 371, CHARACTER}, {CHARACTER, 0, 69, 372, CHARACTER}, - {Q_NAMESPACE_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 65, 374, CHARACTER}, - {CHARACTER, 0, 68, 375, CHARACTER}, - {CHARACTER, 0, 71, 376, CHARACTER}, - {CHARACTER, 0, 69, 377, CHARACTER}, - {CHARACTER, 0, 84, 378, CHARACTER}, + {Q_NAMESPACE_TOKEN, 0, 95, 373, CHARACTER}, + {CHARACTER, 0, 69, 374, CHARACTER}, + {CHARACTER, 0, 88, 375, CHARACTER}, + {CHARACTER, 0, 80, 376, CHARACTER}, + {CHARACTER, 0, 79, 377, CHARACTER}, + {CHARACTER, 0, 82, 378, CHARACTER}, + {CHARACTER, 0, 84, 379, CHARACTER}, + {Q_NAMESPACE_EXPORT_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 65, 381, CHARACTER}, + {CHARACTER, 0, 68, 382, CHARACTER}, + {CHARACTER, 0, 71, 383, CHARACTER}, + {CHARACTER, 0, 69, 384, CHARACTER}, + {CHARACTER, 0, 84, 385, CHARACTER}, {Q_GADGET_TOKEN, 0, 0, 0, CHARACTER}, {CHARACTER, 44, 0, 0, CHARACTER}, {CHARACTER, 45, 0, 0, CHARACTER}, - {CHARACTER, 0, 80, 382, CHARACTER}, - {CHARACTER, 0, 69, 383, CHARACTER}, - {CHARACTER, 0, 82, 384, CHARACTER}, - {CHARACTER, 0, 84, 385, CHARACTER}, - {CHARACTER, 0, 89, 386, CHARACTER}, + {CHARACTER, 0, 80, 389, CHARACTER}, + {CHARACTER, 0, 69, 390, CHARACTER}, + {CHARACTER, 0, 82, 391, CHARACTER}, + {CHARACTER, 0, 84, 392, CHARACTER}, + {CHARACTER, 0, 89, 393, CHARACTER}, {Q_PROPERTY_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 85, 388, CHARACTER}, - {CHARACTER, 0, 71, 389, CHARACTER}, - {CHARACTER, 0, 73, 390, CHARACTER}, - {CHARACTER, 0, 78, 391, CHARACTER}, - {CHARACTER, 0, 95, 392, CHARACTER}, - {CHARACTER, 0, 77, 393, CHARACTER}, - {CHARACTER, 0, 69, 394, CHARACTER}, - {CHARACTER, 0, 84, 395, CHARACTER}, - {CHARACTER, 0, 65, 396, CHARACTER}, - {CHARACTER, 0, 68, 397, CHARACTER}, - {CHARACTER, 0, 65, 398, CHARACTER}, - {CHARACTER, 0, 84, 399, CHARACTER}, - {CHARACTER, 0, 65, 400, CHARACTER}, + {CHARACTER, 0, 85, 395, CHARACTER}, + {CHARACTER, 0, 71, 396, CHARACTER}, + {CHARACTER, 0, 73, 397, CHARACTER}, + {CHARACTER, 0, 78, 398, CHARACTER}, + {CHARACTER, 0, 95, 399, CHARACTER}, + {CHARACTER, 0, 77, 400, CHARACTER}, + {CHARACTER, 0, 69, 401, CHARACTER}, + {CHARACTER, 0, 84, 402, CHARACTER}, + {CHARACTER, 0, 65, 403, CHARACTER}, + {CHARACTER, 0, 68, 404, CHARACTER}, + {CHARACTER, 0, 65, 405, CHARACTER}, + {CHARACTER, 0, 84, 406, CHARACTER}, + {CHARACTER, 0, 65, 407, CHARACTER}, {Q_PLUGIN_METADATA_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 402, CHARACTER}, - {CHARACTER, 0, 85, 403, CHARACTER}, - {CHARACTER, 0, 77, 404, CHARACTER}, + {CHARACTER, 0, 78, 409, CHARACTER}, + {CHARACTER, 0, 85, 410, CHARACTER}, + {CHARACTER, 0, 77, 411, CHARACTER}, {Q_ENUM_TOKEN, 46, 0, 0, CHARACTER}, {Q_ENUMS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 407, CHARACTER}, - {CHARACTER, 0, 83, 408, CHARACTER}, + {CHARACTER, 0, 78, 414, CHARACTER}, + {CHARACTER, 0, 83, 415, CHARACTER}, {Q_ENUM_NS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 76, 410, CHARACTER}, - {CHARACTER, 0, 65, 411, CHARACTER}, - {CHARACTER, 0, 71, 412, CHARACTER}, + {CHARACTER, 0, 76, 417, CHARACTER}, + {CHARACTER, 0, 65, 418, CHARACTER}, + {CHARACTER, 0, 71, 419, CHARACTER}, {Q_FLAG_TOKEN, 47, 0, 0, CHARACTER}, {Q_FLAGS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 415, CHARACTER}, - {CHARACTER, 0, 83, 416, CHARACTER}, + {CHARACTER, 0, 78, 422, CHARACTER}, + {CHARACTER, 0, 83, 423, CHARACTER}, {Q_FLAG_NS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 69, 418, CHARACTER}, - {CHARACTER, 0, 67, 419, CHARACTER}, - {CHARACTER, 0, 76, 420, CHARACTER}, - {CHARACTER, 0, 65, 421, CHARACTER}, - {CHARACTER, 0, 82, 422, CHARACTER}, - {CHARACTER, 0, 69, 423, CHARACTER}, - {CHARACTER, 0, 95, 424, CHARACTER}, + {CHARACTER, 0, 69, 425, CHARACTER}, + {CHARACTER, 0, 67, 426, CHARACTER}, + {CHARACTER, 0, 76, 427, CHARACTER}, + {CHARACTER, 0, 65, 428, CHARACTER}, + {CHARACTER, 0, 82, 429, CHARACTER}, + {CHARACTER, 0, 69, 430, CHARACTER}, + {CHARACTER, 0, 95, 431, CHARACTER}, {CHARACTER, 48, 0, 0, CHARACTER}, - {CHARACTER, 0, 76, 426, CHARACTER}, - {CHARACTER, 0, 65, 427, CHARACTER}, - {CHARACTER, 0, 71, 428, CHARACTER}, - {CHARACTER, 0, 83, 429, CHARACTER}, + {CHARACTER, 0, 76, 433, CHARACTER}, + {CHARACTER, 0, 65, 434, CHARACTER}, + {CHARACTER, 0, 71, 435, CHARACTER}, + {CHARACTER, 0, 83, 436, CHARACTER}, {Q_DECLARE_FLAGS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 431, CHARACTER}, - {CHARACTER, 0, 84, 432, CHARACTER}, - {CHARACTER, 0, 69, 433, CHARACTER}, - {CHARACTER, 0, 82, 434, CHARACTER}, - {CHARACTER, 0, 70, 435, CHARACTER}, - {CHARACTER, 0, 65, 436, CHARACTER}, - {CHARACTER, 0, 67, 437, CHARACTER}, - {CHARACTER, 0, 69, 438, CHARACTER}, - {Q_DECLARE_INTERFACE_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 78, 438, CHARACTER}, + {CHARACTER, 0, 84, 439, CHARACTER}, {CHARACTER, 0, 69, 440, CHARACTER}, - {CHARACTER, 0, 84, 441, CHARACTER}, - {CHARACTER, 0, 65, 442, CHARACTER}, - {CHARACTER, 0, 84, 443, CHARACTER}, - {CHARACTER, 0, 89, 444, CHARACTER}, - {CHARACTER, 0, 80, 445, CHARACTER}, - {CHARACTER, 0, 69, 446, CHARACTER}, + {CHARACTER, 0, 82, 441, CHARACTER}, + {CHARACTER, 0, 70, 442, CHARACTER}, + {CHARACTER, 0, 65, 443, CHARACTER}, + {CHARACTER, 0, 67, 444, CHARACTER}, + {CHARACTER, 0, 69, 445, CHARACTER}, + {Q_DECLARE_INTERFACE_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 69, 447, CHARACTER}, + {CHARACTER, 0, 84, 448, CHARACTER}, + {CHARACTER, 0, 65, 449, CHARACTER}, + {CHARACTER, 0, 84, 450, CHARACTER}, + {CHARACTER, 0, 89, 451, CHARACTER}, + {CHARACTER, 0, 80, 452, CHARACTER}, + {CHARACTER, 0, 69, 453, CHARACTER}, {Q_DECLARE_METATYPE_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 88, 448, CHARACTER}, - {CHARACTER, 0, 84, 449, CHARACTER}, - {CHARACTER, 0, 69, 450, CHARACTER}, - {CHARACTER, 0, 78, 451, CHARACTER}, - {CHARACTER, 0, 83, 452, CHARACTER}, - {CHARACTER, 0, 73, 453, CHARACTER}, - {CHARACTER, 0, 79, 454, CHARACTER}, - {CHARACTER, 0, 78, 455, CHARACTER}, - {CHARACTER, 0, 95, 456, CHARACTER}, - {CHARACTER, 0, 73, 457, CHARACTER}, + {CHARACTER, 0, 88, 455, CHARACTER}, + {CHARACTER, 0, 84, 456, CHARACTER}, + {CHARACTER, 0, 69, 457, CHARACTER}, {CHARACTER, 0, 78, 458, CHARACTER}, - {CHARACTER, 0, 84, 459, CHARACTER}, - {CHARACTER, 0, 69, 460, CHARACTER}, - {CHARACTER, 0, 82, 461, CHARACTER}, - {CHARACTER, 0, 70, 462, CHARACTER}, - {CHARACTER, 0, 65, 463, CHARACTER}, - {CHARACTER, 0, 67, 464, CHARACTER}, - {CHARACTER, 0, 69, 438, CHARACTER}, - {CHARACTER, 49, 0, 0, CHARACTER}, - {CHARACTER, 0, 84, 467, CHARACTER}, - {CHARACTER, 0, 83, 413, CHARACTER}, - {CHARACTER, 0, 76, 469, CHARACTER}, + {CHARACTER, 0, 83, 459, CHARACTER}, + {CHARACTER, 0, 73, 460, CHARACTER}, + {CHARACTER, 0, 79, 461, CHARACTER}, + {CHARACTER, 0, 78, 462, CHARACTER}, + {CHARACTER, 0, 95, 463, CHARACTER}, + {CHARACTER, 0, 73, 464, CHARACTER}, + {CHARACTER, 0, 78, 465, CHARACTER}, + {CHARACTER, 0, 84, 466, CHARACTER}, + {CHARACTER, 0, 69, 467, CHARACTER}, + {CHARACTER, 0, 82, 468, CHARACTER}, + {CHARACTER, 0, 70, 469, CHARACTER}, {CHARACTER, 0, 65, 470, CHARACTER}, - {CHARACTER, 0, 83, 471, CHARACTER}, - {CHARACTER, 0, 83, 472, CHARACTER}, - {CHARACTER, 0, 73, 473, CHARACTER}, - {CHARACTER, 0, 78, 474, CHARACTER}, - {CHARACTER, 0, 70, 475, CHARACTER}, - {CHARACTER, 0, 79, 476, CHARACTER}, - {Q_CLASSINFO_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 478, CHARACTER}, - {CHARACTER, 50, 0, 0, CHARACTER}, - {CHARACTER, 0, 69, 480, CHARACTER}, - {CHARACTER, 0, 82, 481, CHARACTER}, + {CHARACTER, 0, 67, 471, CHARACTER}, + {CHARACTER, 0, 69, 445, CHARACTER}, + {CHARACTER, 49, 0, 0, CHARACTER}, + {CHARACTER, 0, 84, 474, CHARACTER}, + {CHARACTER, 0, 83, 420, CHARACTER}, + {CHARACTER, 0, 76, 476, CHARACTER}, + {CHARACTER, 0, 65, 477, CHARACTER}, + {CHARACTER, 0, 83, 478, CHARACTER}, + {CHARACTER, 0, 83, 479, CHARACTER}, + {CHARACTER, 0, 73, 480, CHARACTER}, + {CHARACTER, 0, 78, 481, CHARACTER}, {CHARACTER, 0, 70, 482, CHARACTER}, - {CHARACTER, 0, 65, 483, CHARACTER}, - {CHARACTER, 0, 67, 484, CHARACTER}, - {CHARACTER, 0, 69, 485, CHARACTER}, - {CHARACTER, 0, 83, 486, CHARACTER}, + {CHARACTER, 0, 79, 483, CHARACTER}, + {Q_CLASSINFO_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 78, 485, CHARACTER}, + {CHARACTER, 50, 0, 0, CHARACTER}, + {CHARACTER, 0, 69, 487, CHARACTER}, + {CHARACTER, 0, 82, 488, CHARACTER}, + {CHARACTER, 0, 70, 489, CHARACTER}, + {CHARACTER, 0, 65, 490, CHARACTER}, + {CHARACTER, 0, 67, 491, CHARACTER}, + {CHARACTER, 0, 69, 492, CHARACTER}, + {CHARACTER, 0, 83, 493, CHARACTER}, {Q_INTERFACES_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 108, 488, CHARACTER}, - {CHARACTER, 0, 115, 489, CHARACTER}, + {CHARACTER, 0, 108, 495, CHARACTER}, + {CHARACTER, 0, 115, 496, CHARACTER}, {SIGNALS, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 111, 491, CHARACTER}, - {CHARACTER, 0, 116, 492, CHARACTER}, - {CHARACTER, 0, 115, 493, CHARACTER}, + {CHARACTER, 0, 111, 498, CHARACTER}, + {CHARACTER, 0, 116, 499, CHARACTER}, + {CHARACTER, 0, 115, 500, CHARACTER}, {SLOTS, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 71, 495, CHARACTER}, - {CHARACTER, 0, 78, 496, CHARACTER}, - {CHARACTER, 0, 65, 497, CHARACTER}, - {CHARACTER, 0, 76, 498, CHARACTER}, - {Q_SIGNAL_TOKEN, 0, 83, 499, CHARACTER}, + {CHARACTER, 0, 71, 502, CHARACTER}, + {CHARACTER, 0, 78, 503, CHARACTER}, + {CHARACTER, 0, 65, 504, CHARACTER}, + {CHARACTER, 0, 76, 505, CHARACTER}, + {Q_SIGNAL_TOKEN, 0, 83, 506, CHARACTER}, {Q_SIGNALS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 79, 501, CHARACTER}, - {CHARACTER, 0, 84, 502, CHARACTER}, - {Q_SLOT_TOKEN, 0, 83, 503, CHARACTER}, + {CHARACTER, 0, 79, 508, CHARACTER}, + {CHARACTER, 0, 84, 509, CHARACTER}, + {Q_SLOT_TOKEN, 0, 83, 510, CHARACTER}, {Q_SLOTS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 86, 505, CHARACTER}, - {CHARACTER, 0, 65, 506, CHARACTER}, - {CHARACTER, 0, 84, 507, CHARACTER}, - {CHARACTER, 0, 69, 508, CHARACTER}, - {CHARACTER, 0, 95, 509, CHARACTER}, + {CHARACTER, 0, 86, 512, CHARACTER}, + {CHARACTER, 0, 65, 513, CHARACTER}, + {CHARACTER, 0, 84, 514, CHARACTER}, + {CHARACTER, 0, 69, 515, CHARACTER}, + {CHARACTER, 0, 95, 516, CHARACTER}, {CHARACTER, 51, 0, 0, CHARACTER}, - {CHARACTER, 0, 76, 511, CHARACTER}, - {CHARACTER, 0, 79, 512, CHARACTER}, - {CHARACTER, 0, 84, 513, CHARACTER}, + {CHARACTER, 0, 76, 518, CHARACTER}, + {CHARACTER, 0, 79, 519, CHARACTER}, + {CHARACTER, 0, 84, 520, CHARACTER}, {Q_PRIVATE_SLOT_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 95, 515, CHARACTER}, - {CHARACTER, 0, 77, 516, CHARACTER}, - {CHARACTER, 0, 79, 517, CHARACTER}, - {CHARACTER, 0, 67, 518, CHARACTER}, - {CHARACTER, 0, 95, 519, CHARACTER}, - {CHARACTER, 0, 67, 520, CHARACTER}, - {CHARACTER, 0, 79, 521, CHARACTER}, - {CHARACTER, 0, 77, 522, CHARACTER}, - {CHARACTER, 0, 80, 523, CHARACTER}, - {CHARACTER, 0, 65, 524, CHARACTER}, - {CHARACTER, 0, 84, 525, CHARACTER}, + {CHARACTER, 0, 95, 522, CHARACTER}, + {CHARACTER, 0, 77, 523, CHARACTER}, + {CHARACTER, 0, 79, 524, CHARACTER}, + {CHARACTER, 0, 67, 525, CHARACTER}, + {CHARACTER, 0, 95, 526, CHARACTER}, + {CHARACTER, 0, 67, 527, CHARACTER}, + {CHARACTER, 0, 79, 528, CHARACTER}, + {CHARACTER, 0, 77, 529, CHARACTER}, + {CHARACTER, 0, 80, 530, CHARACTER}, + {CHARACTER, 0, 65, 531, CHARACTER}, + {CHARACTER, 0, 84, 532, CHARACTER}, {Q_MOC_COMPAT_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 79, 527, CHARACTER}, - {CHARACTER, 0, 75, 528, CHARACTER}, - {CHARACTER, 0, 65, 529, CHARACTER}, - {CHARACTER, 0, 66, 530, CHARACTER}, - {CHARACTER, 0, 76, 531, CHARACTER}, - {CHARACTER, 0, 69, 532, CHARACTER}, + {CHARACTER, 0, 79, 534, CHARACTER}, + {CHARACTER, 0, 75, 535, CHARACTER}, + {CHARACTER, 0, 65, 536, CHARACTER}, + {CHARACTER, 0, 66, 537, CHARACTER}, + {CHARACTER, 0, 76, 538, CHARACTER}, + {CHARACTER, 0, 69, 539, CHARACTER}, {Q_INVOKABLE_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 82, 534, CHARACTER}, - {CHARACTER, 0, 73, 535, CHARACTER}, - {CHARACTER, 0, 80, 536, CHARACTER}, - {CHARACTER, 0, 84, 537, CHARACTER}, - {CHARACTER, 0, 65, 538, CHARACTER}, - {CHARACTER, 0, 66, 539, CHARACTER}, - {CHARACTER, 0, 76, 540, CHARACTER}, - {CHARACTER, 0, 69, 541, CHARACTER}, + {CHARACTER, 0, 82, 541, CHARACTER}, + {CHARACTER, 0, 73, 542, CHARACTER}, + {CHARACTER, 0, 80, 543, CHARACTER}, + {CHARACTER, 0, 84, 544, CHARACTER}, + {CHARACTER, 0, 65, 545, CHARACTER}, + {CHARACTER, 0, 66, 546, CHARACTER}, + {CHARACTER, 0, 76, 547, CHARACTER}, + {CHARACTER, 0, 69, 548, CHARACTER}, {Q_SCRIPTABLE_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 82, 543, CHARACTER}, - {CHARACTER, 0, 79, 544, CHARACTER}, - {CHARACTER, 0, 80, 545, CHARACTER}, - {CHARACTER, 0, 69, 546, CHARACTER}, - {CHARACTER, 0, 82, 547, CHARACTER}, - {CHARACTER, 0, 84, 548, CHARACTER}, - {CHARACTER, 0, 89, 549, CHARACTER}, + {CHARACTER, 0, 82, 550, CHARACTER}, + {CHARACTER, 0, 79, 551, CHARACTER}, + {CHARACTER, 0, 80, 552, CHARACTER}, + {CHARACTER, 0, 69, 553, CHARACTER}, + {CHARACTER, 0, 82, 554, CHARACTER}, + {CHARACTER, 0, 84, 555, CHARACTER}, + {CHARACTER, 0, 89, 556, CHARACTER}, {Q_PRIVATE_PROPERTY_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 69, 551, CHARACTER}, - {CHARACTER, 0, 86, 552, CHARACTER}, - {CHARACTER, 0, 73, 553, CHARACTER}, - {CHARACTER, 0, 83, 554, CHARACTER}, - {CHARACTER, 0, 73, 555, CHARACTER}, - {CHARACTER, 0, 79, 556, CHARACTER}, - {CHARACTER, 0, 78, 557, CHARACTER}, + {CHARACTER, 0, 69, 558, CHARACTER}, + {CHARACTER, 0, 86, 559, CHARACTER}, + {CHARACTER, 0, 73, 560, CHARACTER}, + {CHARACTER, 0, 83, 561, CHARACTER}, + {CHARACTER, 0, 73, 562, CHARACTER}, + {CHARACTER, 0, 79, 563, CHARACTER}, + {CHARACTER, 0, 78, 564, CHARACTER}, {Q_REVISION_TOKEN, 0, 0, 0, CHARACTER}, {NEWLINE, 0, 0, 0, NOTOKEN}, {QUOTE, 0, 0, 0, NOTOKEN}, {SINGLEQUOTE, 0, 0, 0, NOTOKEN}, {WHITESPACE, 0, 0, 0, NOTOKEN}, - {HASH, 0, 35, 563, HASH}, + {HASH, 0, 35, 570, HASH}, {PP_HASHHASH, 0, 0, 0, NOTOKEN}, {BACKSLASH, 0, 0, 0, NOTOKEN}, {CPP_COMMENT, 0, 0, 0, NOTOKEN}, diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 2f0ea633fa8..50946443be7 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -620,6 +620,13 @@ void Moc::parse() case Q_NAMESPACE_TOKEN: def.hasQNamespace = true; break; + case Q_NAMESPACE_EXPORT_TOKEN: + next(LPAREN); + while (test(IDENTIFIER)) + {} + next(RPAREN); + def.hasQNamespace = true; + break; case Q_ENUMS_TOKEN: case Q_ENUM_NS_TOKEN: parseEnumOrFlag(&def, false); diff --git a/src/tools/moc/token.h b/src/tools/moc/token.h index db9d319b78b..0cc163f9e4c 100644 --- a/src/tools/moc/token.h +++ b/src/tools/moc/token.h @@ -155,6 +155,7 @@ QT_BEGIN_NAMESPACE F(Q_OBJECT_TOKEN) \ F(Q_GADGET_TOKEN) \ F(Q_NAMESPACE_TOKEN) \ + F(Q_NAMESPACE_EXPORT_TOKEN) \ F(Q_PROPERTY_TOKEN) \ F(Q_PLUGIN_METADATA_TOKEN) \ F(Q_ENUMS_TOKEN) \ diff --git a/src/tools/moc/util/generate_keywords.cpp b/src/tools/moc/util/generate_keywords.cpp index df850c1bdc2..9248e9e2e7f 100644 --- a/src/tools/moc/util/generate_keywords.cpp +++ b/src/tools/moc/util/generate_keywords.cpp @@ -214,6 +214,7 @@ static const Keyword keywords[] = { { "return", "RETURN" }, { "Q_OBJECT", "Q_OBJECT_TOKEN" }, { "Q_NAMESPACE", "Q_NAMESPACE_TOKEN" }, + { "Q_NAMESPACE_EXPORT", "Q_NAMESPACE_EXPORT_TOKEN" }, { "Q_GADGET", "Q_GADGET_TOKEN" }, { "Q_PROPERTY", "Q_PROPERTY_TOKEN" }, { "Q_PLUGIN_METADATA", "Q_PLUGIN_METADATA_TOKEN" }, diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index ec4a44e6721..b88d929ca96 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -149,6 +149,17 @@ namespace TestQNamespace { Q_FLAG_NS(TestFlag2) } + +#define TESTEXPORTMACRO Q_DECL_EXPORT + +namespace TestExportNamespace { + Q_NAMESPACE_EXPORT(TESTEXPORTMACRO) + enum class MyEnum { + Key1, Key2 + }; + Q_ENUM_NS(MyEnum) +} + QT_USE_NAMESPACE template struct QTBUG_31218 {}; @@ -3893,6 +3904,10 @@ void tst_Moc::testQNamespace() QCOMPARE(meta.enclosingMetaObject(), &TestQNamespace::staticMetaObject); QCOMPARE(meta.keyCount(), 2); + QCOMPARE(TestExportNamespace::staticMetaObject.enumeratorCount(), 1); + checkEnum(TestExportNamespace::staticMetaObject.enumerator(0), "MyEnum", + {{"Key1", 0}, {"Key2", 1}}); + QCOMPARE(FooNamespace::staticMetaObject.enumeratorCount(), 1); QCOMPARE(FooNamespace::FooNestedNamespace::staticMetaObject.enumeratorCount(), 2); QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1); From 1e4dec12d5c0152d5c3eee3b612a0af4bf389a37 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 27 Jun 2019 11:51:26 +0300 Subject: [PATCH 059/172] Android: Stick with buildToolsVersion 28.0.3 On Windows buildToolsVersion 29.0.0 have problems, therefore, it's better to use a version that we know it works on all platofrms. Change-Id: I25cdea4b8101bfe5f022025fcd7cc4cbf358fa03 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/android/templates/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/templates/build.gradle b/src/android/templates/build.gradle index 989d0792cf0..ed704c4957b 100644 --- a/src/android/templates/build.gradle +++ b/src/android/templates/build.gradle @@ -36,7 +36,7 @@ android { compileSdkVersion androidCompileSdkVersion.toInteger() - buildToolsVersion androidBuildToolsVersion + buildToolsVersion '28.0.3' sourceSets { main { From d1141b6c90e53554f69fd6a7a272988211f5bd34 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 28 Feb 2019 09:54:20 +0200 Subject: [PATCH 060/172] Fix crash with drag cursor handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7a7c722782a435f7c01b94f48df7a5f4ff4d599e caused a regresssion in some cases. Change-Id: I1089a79534d811b195de663ff664d9ba5a6ac6c5 Fixes: QTBUG-74110 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qsimpledrag.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 9aab332ef59..bd409c124f0 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -310,11 +310,15 @@ void QBasicDrag::updateCursor(Qt::DropAction action) m_dndHasSetOverrideCursor = true; } else { QCursor *cursor = QGuiApplication::overrideCursor(); - if (!pixmap.isNull()) { - if (cursor->pixmap().cacheKey() != pixmap.cacheKey()) - QGuiApplication::changeOverrideCursor(QCursor(pixmap)); - } else if (cursorShape != cursor->shape()) { - QGuiApplication::changeOverrideCursor(QCursor(cursorShape)); + if (!cursor) { + QGuiApplication::changeOverrideCursor(pixmap.isNull() ? QCursor(cursorShape) : QCursor(pixmap)); + } else { + if (!pixmap.isNull()) { + if (cursor->pixmap().cacheKey() != pixmap.cacheKey()) + QGuiApplication::changeOverrideCursor(QCursor(pixmap)); + } else if (cursorShape != cursor->shape()) { + QGuiApplication::changeOverrideCursor(QCursor(cursorShape)); + } } } #endif From e19d93b212d71521b7edd3a7e45e4b9319cd5c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 27 Jun 2019 11:38:43 +0200 Subject: [PATCH 061/172] QSocks5SocketEngine: avoid dereferencing null-pointer The header argument is optional Change-Id: I035e11db5ee70183274afb48ba67c4d3ed2f615d Reviewed-by: Timur Pocheptsov --- src/network/socket/qsocks5socketengine.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index dd2bc908558..6791b85273b 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1611,8 +1611,10 @@ qint64 QSocks5SocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea QSocks5RevivedDatagram datagram = d->udpData->pendingDatagrams.dequeue(); int copyLen = qMin(maxlen, datagram.data.size()); memcpy(data, datagram.data.constData(), copyLen); - header->senderAddress = datagram.address; - header->senderPort = datagram.port; + if (header) { + header->senderAddress = datagram.address; + header->senderPort = datagram.port; + } return copyLen; #else Q_UNUSED(data) From 399bf445771936648691c48bebca500b36ae69dd Mon Sep 17 00:00:00 2001 From: Vova Mshanetskiy Date: Fri, 31 May 2019 18:51:43 +0300 Subject: [PATCH 062/172] QAndroidInputContext: Consider preedit text in getCursorCapsMode() Fixes auto-capitalization in AnySoftKeyboard. It was typing the whole first word in a sentence in upper case. Change-Id: I605a1aee39d432a3474c0bf706445d354562285f Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidinputcontext.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index fa07af8c464..bab71751f85 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -1200,13 +1200,18 @@ jint QAndroidInputContext::getCursorCapsMode(jint /*reqModes*/) const uint qtInputMethodHints = query->value(Qt::ImHints).toUInt(); const int localPos = query->value(Qt::ImCursorPosition).toInt(); - bool atWordBoundary = (localPos == 0); + bool atWordBoundary = + localPos == 0 + && (!focusObjectIsComposing() || m_composingCursor == m_composingTextStart); + if (!atWordBoundary) { QString surroundingText = query->value(Qt::ImSurroundingText).toString(); surroundingText.truncate(localPos); + if (focusObjectIsComposing()) + surroundingText += m_composingText.leftRef(m_composingCursor - m_composingTextStart); // Add a character to see if it is at the end of the sentence or not QTextBoundaryFinder finder(QTextBoundaryFinder::Sentence, surroundingText + QLatin1Char('A')); - finder.setPosition(localPos); + finder.setPosition(surroundingText.length()); if (finder.isAtBoundary()) atWordBoundary = finder.isAtBoundary(); } From 2c61b4e0f08e55d5478e710fe66eb12594ae17cb Mon Sep 17 00:00:00 2001 From: Vova Mshanetskiy Date: Fri, 31 May 2019 19:42:57 +0300 Subject: [PATCH 063/172] QAndroidInputContext: Do not stop composing when user taps the cursor There is no need to tell the editor to stop composing if user taps so close to the cursor position that the cursor will not move anyway. If we do stop composing in such case, then since there will be no cursor position change notification, we will never start composing again (before the cursor is actually moved), and the current composing region will remain being displayed as normal text instead of being displayed as composing text. Change-Id: I4ebe6442e1ba8c365d6754c1a8487235d177c732 Reviewed-by: BogDan Vatra --- .../android/qandroidinputcontext.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index bab71751f85..69b100fa4e5 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -792,7 +792,25 @@ void QAndroidInputContext::touchDown(int x, int y) m_handleMode = ShowCursor; // The VK will appear in a moment, stop the timer m_hideCursorHandleTimer.stop(); - focusObjectStopComposing(); + + if (focusObjectIsComposing()) { + const double pixelDensity = + QGuiApplication::focusWindow() + ? QHighDpiScaling::factor(QGuiApplication::focusWindow()) + : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); + + const QPointF touchPointLocal = + QGuiApplication::inputMethod()->inputItemTransform().inverted().map( + QPointF(x / pixelDensity, y / pixelDensity)); + + const int curBlockPos = getBlockPosition( + focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImAbsolutePosition)); + const int touchPosition = curBlockPos + + QInputMethod::queryFocusObject(Qt::ImCursorPosition, touchPointLocal).toInt(); + if (touchPosition != m_composingCursor) + focusObjectStopComposing(); + } + updateSelectionHandles(); } } From 346f1999f579c76c98eaa53c5bec2510ae596c22 Mon Sep 17 00:00:00 2001 From: Vova Mshanetskiy Date: Wed, 5 Jun 2019 14:59:18 +0300 Subject: [PATCH 064/172] QAndroidInputContext: Generate a QInputMethodEvent in reset() Although QPlatformInputContext::reset() documentation says that reset() should not send any QInputMethodEvents, implementations on Windows, macOS and iOS do send a QInputMethodEvent which clears preedit text in their reimplementations of reset(). Text editing controls depend on that and may not clear preedit text if such event is not sent. Change-Id: I75ab73946cb06e93e5fc5e98e0cc503a7de5c2e0 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidinputcontext.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 69b100fa4e5..5614d3b04fc 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -558,6 +558,7 @@ static inline int getBlockPosition(const QSharedPointer void QAndroidInputContext::reset() { + focusObjectStopComposing(); clear(); m_batchEditNestingLevel = 0; m_handleMode = Hidden; From 57eed823e412d587e051bff0d4775f08024d4169 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 28 Jun 2019 14:41:56 +0200 Subject: [PATCH 065/172] Fix build with Android NDK's make on Windows The make executable that comes with Android's NDK tries to execute the shell-builtin "move" as a stand-alone executable unless you trick it to execute "move" through the shell by surrounding one argument with double quotes or such. Force the execution of "move" through shell by altering QMAKE_MOVE for Android on Windows. Change-Id: I5b1490ad0606960dbd06a4cafb0b0b983e265159 Fixes: QTBUG-35713 Reviewed-by: Andy Shaw --- mkspecs/features/android/spec_post.prf | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 mkspecs/features/android/spec_post.prf diff --git a/mkspecs/features/android/spec_post.prf b/mkspecs/features/android/spec_post.prf new file mode 100644 index 00000000000..4d11efb2cfc --- /dev/null +++ b/mkspecs/features/android/spec_post.prf @@ -0,0 +1,6 @@ +load(spec_post) + +# Work around idiosyncracy in Android NDK's make executable +# which tries to call the shell-builtin "move" as direct process +equals(QMAKE_HOST.os, Windows):equals(QMAKE_MOVE, move): \ + QMAKE_MOVE = cmd /c move From 1ce832648e05ad6226071ec38a5da0ef08d3ab8e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 25 Jun 2019 00:56:31 +0200 Subject: [PATCH 066/172] forkfd: port to loadRelaxed / storeRelaxed The usages were hidden behind clever macros. Change-Id: I594814cd45b19841880e9a88f40af8805c97fe79 Reviewed-by: Thiago Macieira --- src/corelib/io/forkfd_qt.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp index dce0ebb4da8..80d1cd54d7d 100644 --- a/src/corelib/io/forkfd_qt.cpp +++ b/src/corelib/io/forkfd_qt.cpp @@ -56,8 +56,6 @@ QT_BEGIN_NAMESPACE #define FFD_ATOMIC_RELAXED Relaxed #define FFD_ATOMIC_ACQUIRE Acquire #define FFD_ATOMIC_RELEASE Release -#define loadRelaxed load -#define storeRelaxed store #define FFD_CONCAT(x, y) x ## y From 9520ba5a73cd9d6cb8ef47f10837b92494c8221e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 17 Jun 2019 12:41:59 +0200 Subject: [PATCH 067/172] Improve performance when loading application fonts Since it was added in Qt 4.2, addAppFont() has been written to first register the font, then immediately invalidate the font database and later reload the font again the next time the db is used. This caused all application fonts to be reloaded *at least* once, an operation which can be quite heavy for large fonts, such as CJK fonts. If an application loaded multiple fonts at different stages of execution, you could end up loading the same fonts a large number of times, since all application fonts would be reregistered every time a new one was added. When calling removeApplicationFont(), this is okay-ish, since we need to remove all traces of the font from the platform database and clearing the whole thing is a convenient way of making sure there is nothing left. There might be more efficient ways of doing this, but unloading fonts is not a common operation, so it is fine to keep this behavior there. This change removes the invalidation of the font database from addAppFont(), since this should not be necessary as long as we are adding fonts. It also removes the reregisterAppFonts flag, which was a bit of a convoluted way of saying that the database had been invalidated and needed repopulating. Instead, we use the same mechanism as for repopulating the system database: We just check if it is currently empty, which means it has been invalidated and the application fonts have to be reregistered. It does not touch the logic in qt_cleanupFontDatabase(), which is kind of broken (it will leave application fonts in memory and reregister them if the application continues to run). But this is only actually called during shutdown (from application destructor). [ChangeLog][QtGui][Text] Fixed an issue where application fonts would be parsed multiple times, causing some unnecessary overhead when during application startup. Task-number: QTBUG-76239 Change-Id: Idfb62f73133b55e0909bb398631c8e762442e95b Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qfontdatabase.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 5350a9c5ecc..562ee3e2b1e 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -451,8 +451,7 @@ class QFontDatabasePrivate public: QFontDatabasePrivate() : count(0), families(0), - fallbacksCache(64), - reregisterAppFonts(false) + fallbacksCache(64) { } ~QFontDatabasePrivate() { @@ -488,7 +487,6 @@ public: }; QVector applicationFonts; int addAppFont(const QByteArray &fontData, const QString &fileName); - bool reregisterAppFonts; bool isApplicationFont(const QString &fileName); void invalidate(); @@ -897,15 +895,12 @@ static void initializeDb() QFontDatabasePrivate *db = privateDb(); // init by asking for the platformfontdb for the first time or after invalidation - if (!db->count) + if (!db->count) { QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase(); - - if (db->reregisterAppFonts) { for (int i = 0; i < db->applicationFonts.count(); i++) { if (!db->applicationFonts.at(i).families.isEmpty()) registerFont(&db->applicationFonts[i]); } - db->reregisterAppFonts = false; } } @@ -1033,11 +1028,7 @@ QFontEngine *loadEngine(int script, const QFontDef &request, static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) { - QFontDatabasePrivate *db = privateDb(); - fnt->families = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName); - - db->reregisterAppFonts = true; } static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &styleKey, @@ -2451,13 +2442,18 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString & if (font.fileName.isEmpty() && !fontData.isEmpty()) font.fileName = QLatin1String(":qmemoryfonts/") + QString::number(i); + bool wasEmpty = privateDb()->count == 0; registerFont(&font); if (font.families.isEmpty()) return -1; applicationFonts[i] = font; - invalidate(); + // If the cache has not yet been populated, we need to reload the application font later + if (wasEmpty) + invalidate(); + else + emit qApp->fontDatabaseChanged(); return i; } @@ -2598,7 +2594,6 @@ bool QFontDatabase::removeApplicationFont(int handle) db->applicationFonts[handle] = QFontDatabasePrivate::ApplicationFont(); - db->reregisterAppFonts = true; db->invalidate(); return true; } From a03270f8917a5e5e6fd0c3ffcf3fb4f705e8cffa Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Sun, 28 Oct 2018 01:52:15 +0200 Subject: [PATCH 068/172] rcc: Add -d option to output a Makefile-syntax depfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The -d option makes rcc output a dependency file with the specified file name. The resulting dependency file is useful for make or ninja based build systems. [ChangeLog][Tools][rcc] Added -d option to generate a dependency file. Fixes: QTBUG-45460 Change-Id: I495ade50f8d9865d4c00dce9373b2b6d1a6c8f2f Reviewed-by: Jörg Bornemann --- src/tools/rcc/main.cpp | 58 +++++++++++++++++++ .../tools/rcc/data/depfile/simple.d.expected | 1 + tests/auto/tools/rcc/data/depfile/simple.qrc | 6 ++ .../rcc/data/depfile/specialchar$file.txt | 1 + .../rcc/data/depfile/specialchar.d.expected | 1 + .../tools/rcc/data/depfile/specialchar.qrc | 6 ++ tests/auto/tools/rcc/tst_rcc.cpp | 48 +++++++++++++++ 7 files changed, 121 insertions(+) create mode 100644 tests/auto/tools/rcc/data/depfile/simple.d.expected create mode 100644 tests/auto/tools/rcc/data/depfile/simple.qrc create mode 100644 tests/auto/tools/rcc/data/depfile/specialchar$file.txt create mode 100644 tests/auto/tools/rcc/data/depfile/specialchar.d.expected create mode 100644 tests/auto/tools/rcc/data/depfile/specialchar.qrc diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 0eb6766b5a8..ac87e48e393 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -99,6 +99,37 @@ int createProject(const QString &outFileName) return 0; } +// Escapes a path for use in a Depfile (Makefile syntax) +QString makefileEscape(const QString &filepath) +{ + // Always use forward slashes + QString result = QDir::cleanPath(filepath); + // Spaces are escaped with a backslash + result.replace(QLatin1Char(' '), QLatin1String("\\ ")); + // Pipes are escaped with a backslash + result.replace(QLatin1Char('|'), QLatin1String("\\|")); + // Dollars are escaped with a dollar + result.replace(QLatin1Char('$'), QLatin1String("$$")); + + return result; +} + +void writeDepFile(QIODevice &iodev, const QStringList &depsList, const QString &targetName) +{ + QTextStream out(&iodev); + out << qPrintable(makefileEscape(targetName)); + out << QLatin1Char(':'); + + // Write depfile + for (int i = 0; i < depsList.size(); ++i) { + out << QLatin1Char(' '); + + out << qPrintable(makefileEscape(depsList.at(i))); + } + + out << QLatin1Char('\n'); +} + int runRcc(int argc, char *argv[]) { QCoreApplication app(argc, argv); @@ -176,6 +207,10 @@ int runRcc(int argc, char *argv[]) QStringLiteral("Only output a mapping of resource paths to file system paths defined in the .qrc file, do not generate code.")); parser.addOption(mapOption); + QCommandLineOption depFileOption(QStringList{QStringLiteral("d"), QStringLiteral("depfile")}, + QStringLiteral("Write a depfile with the .qrc dependencies to ."), QStringLiteral("file")); + parser.addOption(depFileOption); + QCommandLineOption projectOption(QStringLiteral("project"), QStringLiteral("Output a resource file containing all files from the current directory.")); parser.addOption(projectOption); @@ -266,6 +301,7 @@ int runRcc(int argc, char *argv[]) QString outFilename = parser.value(outputOption); QString tempFilename = parser.value(tempOption); + QString depFilename = parser.value(depFileOption); if (projectRequested) { return createProject(outFilename); @@ -352,6 +388,28 @@ int runRcc(int argc, char *argv[]) return 0; } + // Write depfile + if (!depFilename.isEmpty()) { + QFile depout; + depout.setFileName(depFilename); + + if (outFilename.isEmpty() || outFilename == QLatin1String("-")) { + const QString msg = QString::fromUtf8("Unable to write depfile when outputting to stdout!\n"); + errorDevice.write(msg.toUtf8()); + return 1; + } + + if (!depout.open(QIODevice::WriteOnly | QIODevice::Text)) { + const QString msg = QString::fromUtf8("Unable to open depfile %1 for writing: %2\n") + .arg(depout.fileName(), depout.errorString()); + errorDevice.write(msg.toUtf8()); + return 1; + } + + writeDepFile(depout, library.dataFiles(), outFilename); + depout.close(); + } + QFile temp; if (!tempFilename.isEmpty()) { temp.setFileName(tempFilename); diff --git a/tests/auto/tools/rcc/data/depfile/simple.d.expected b/tests/auto/tools/rcc/data/depfile/simple.d.expected new file mode 100644 index 00000000000..a89b61bdc7c --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/simple.d.expected @@ -0,0 +1 @@ +simple.qrc.cpp: ../images/images/circle.png ../images/images/square.png diff --git a/tests/auto/tools/rcc/data/depfile/simple.qrc b/tests/auto/tools/rcc/data/depfile/simple.qrc new file mode 100644 index 00000000000..521dc4d4a0a --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/simple.qrc @@ -0,0 +1,6 @@ + + + ../images/images/circle.png + ../images/images/square.png + + diff --git a/tests/auto/tools/rcc/data/depfile/specialchar$file.txt b/tests/auto/tools/rcc/data/depfile/specialchar$file.txt new file mode 100644 index 00000000000..5da849b5c6f --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar$file.txt @@ -0,0 +1 @@ +ABC diff --git a/tests/auto/tools/rcc/data/depfile/specialchar.d.expected b/tests/auto/tools/rcc/data/depfile/specialchar.d.expected new file mode 100644 index 00000000000..9dd1af09585 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar.d.expected @@ -0,0 +1 @@ +specialchar.qrc.cpp: specialchar$$file.txt ../images/images/subdir/triangle.png diff --git a/tests/auto/tools/rcc/data/depfile/specialchar.qrc b/tests/auto/tools/rcc/data/depfile/specialchar.qrc new file mode 100644 index 00000000000..133cbc76559 --- /dev/null +++ b/tests/auto/tools/rcc/data/depfile/specialchar.qrc @@ -0,0 +1,6 @@ + + + ../images/images/subdir/triangle.png + specialchar$file.txt + + diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 24fd79cf195..42a4134e5f1 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -89,6 +89,9 @@ private slots: void readback_data(); void readback(); + void depFileGeneration_data(); + void depFileGeneration(); + void python(); void cleanupTestCase(); @@ -416,6 +419,49 @@ void tst_rcc::readback() QCOMPARE(resourceData, fileSystemData); } +void tst_rcc::depFileGeneration_data() +{ + QTest::addColumn("qrcfile"); + QTest::addColumn("depfile"); + QTest::addColumn("expected"); + + QTest::newRow("simple") << "simple.qrc" << "simple.d" << "simple.d.expected"; + QTest::newRow("specialchar") << "specialchar.qrc" << "specialchar.d" << "specialchar.d.expected"; +} + +void tst_rcc::depFileGeneration() +{ + QFETCH(QString, qrcfile); + QFETCH(QString, depfile); + QFETCH(QString, expected); + const QString directory = m_dataPath + QLatin1String("/depfile"); + + QProcess process; + process.setWorkingDirectory(directory); + process.start(m_rcc, { "-d", depfile, "-o", qrcfile + ".cpp", qrcfile }); + QVERIFY2(process.waitForStarted(), msgProcessStartFailed(process).constData()); + if (!process.waitForFinished()) { + process.kill(); + QFAIL(msgProcessTimeout(process).constData()); + } + QVERIFY2(process.exitStatus() == QProcess::NormalExit, + msgProcessCrashed(process).constData()); + QVERIFY2(process.exitCode() == 0, + msgProcessFailed(process).constData()); + + QFile depFileOutput(directory + QLatin1String("/") + depfile); + QVERIFY(depFileOutput.open(QIODevice::ReadOnly | QIODevice::Text)); + QByteArray depFileData = depFileOutput.readAll(); + depFileOutput.close(); + + QFile depFileExpected(directory + QLatin1String("/") + expected); + QVERIFY(depFileExpected.open(QIODevice::ReadOnly | QIODevice::Text)); + QByteArray expectedData = depFileExpected.readAll(); + depFileExpected.close(); + + QCOMPARE(depFileData, expectedData); +} + void tst_rcc::python() { const QString path = m_dataPath + QLatin1String("/sizes"); @@ -450,6 +496,8 @@ void tst_rcc::cleanupTestCase() { QDir dataDir(m_dataPath + QLatin1String("/binary")); QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc")); + QDir dataDepDir(m_dataPath + QLatin1String("/depfile")); + entries += dataDepDir.entryInfoList({QLatin1String("*.d"), QLatin1String("*.qrc.cpp")}); foreach (const QFileInfo &entry, entries) QFile::remove(entry.absoluteFilePath()); } From 282c030785498d94c3ccee59a1a201f090e69248 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 13 May 2019 16:13:08 +0900 Subject: [PATCH 069/172] Remove property usage in QHttp2ProtocolHandler This helps to fix build without feature.properties Change-Id: Ia1fd2a1ca88105048e75694874058bb1292899a0 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttp2protocolhandler.cpp | 24 +++++++++++++++----- src/network/access/qhttp2protocolhandler_p.h | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 87a70d8a557..93afcf0ee12 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -219,7 +219,8 @@ void QHttp2ProtocolHandler::_q_uploadDataReadyRead() auto data = qobject_cast(sender()); Q_ASSERT(data); - const qint32 streamID = data->property("HTTP2StreamID").toInt(); + const qint32 streamID = streamIDs.value(data); + Q_ASSERT(streamID != 0); Q_ASSERT(activeStreams.contains(streamID)); auto &stream = activeStreams[streamID]; @@ -234,7 +235,7 @@ void QHttp2ProtocolHandler::_q_uploadDataReadyRead() void QHttp2ProtocolHandler::_q_replyDestroyed(QObject *reply) { - const quint32 streamID = reply->property("HTTP2StreamID").toInt(); + const quint32 streamID = streamIDs.take(reply); if (activeStreams.contains(streamID)) { sendRST_STREAM(streamID, CANCEL); markAsReset(streamID); @@ -242,6 +243,11 @@ void QHttp2ProtocolHandler::_q_replyDestroyed(QObject *reply) } } +void QHttp2ProtocolHandler::_q_uploadDataDestroyed(QObject *uploadData) +{ + streamIDs.remove(uploadData); +} + void QHttp2ProtocolHandler::_q_readyRead() { _q_receiveReply(); @@ -1249,7 +1255,7 @@ quint32 QHttp2ProtocolHandler::createNewStream(const HttpMessagePair &message, b replyPrivate->connection = m_connection; replyPrivate->connectionChannel = m_channel; reply->setSpdyWasUsed(true); - reply->setProperty("HTTP2StreamID", newStreamID); + streamIDs.insert(reply, newStreamID); connect(reply, SIGNAL(destroyed(QObject*)), this, SLOT(_q_replyDestroyed(QObject*))); @@ -1261,7 +1267,9 @@ quint32 QHttp2ProtocolHandler::createNewStream(const HttpMessagePair &message, b if (auto src = newStream.data()) { connect(src, SIGNAL(readyRead()), this, SLOT(_q_uploadDataReadyRead()), Qt::QueuedConnection); - src->setProperty("HTTP2StreamID", newStreamID); + connect(src, &QHttp2ProtocolHandler::destroyed, + this, &QHttp2ProtocolHandler::_q_uploadDataDestroyed); + streamIDs.insert(src, newStreamID); } } @@ -1343,10 +1351,14 @@ void QHttp2ProtocolHandler::deleteActiveStream(quint32 streamID) { if (activeStreams.contains(streamID)) { auto &stream = activeStreams[streamID]; - if (stream.reply()) + if (stream.reply()) { stream.reply()->disconnect(this); - if (stream.data()) + streamIDs.remove(stream.reply()); + } + if (stream.data()) { stream.data()->disconnect(this); + streamIDs.remove(stream.data()); + } activeStreams.remove(streamID); } diff --git a/src/network/access/qhttp2protocolhandler_p.h b/src/network/access/qhttp2protocolhandler_p.h index 9165808302d..b582123961e 100644 --- a/src/network/access/qhttp2protocolhandler_p.h +++ b/src/network/access/qhttp2protocolhandler_p.h @@ -93,6 +93,7 @@ public: private slots: void _q_uploadDataReadyRead(); void _q_replyDestroyed(QObject* reply); + void _q_uploadDataDestroyed(QObject* uploadData); private: using Stream = Http2::Stream; @@ -156,6 +157,7 @@ private: HPack::Decoder decoder; HPack::Encoder encoder; + QHash streamIDs; QHash activeStreams; std::deque suspendedStreams[3]; // 3 for priorities: High, Normal, Low. static const std::deque::size_type maxRecycledStreams; From 7ffb5b2c8c1d374d8181ebcd288b869c43fe5b3a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 22 May 2019 12:25:51 -0700 Subject: [PATCH 070/172] Fix Clang warning about applying operator|| to non-boolean qmetatype_p.h:111:412: error: use of logical '||' with constant operand [-Werror,-Wconstant-logical-operand] Change-Id: Iac6ae11e29bd4169bae9fffd15a117d576a95adb Reviewed-by: Ville Voutilainen --- src/corelib/kernel/qmetatype_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index 94e92287782..eba0207ea7e 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -74,7 +74,7 @@ template class QTypeModuleInfo { public: - enum Module { + enum Module : bool { IsCore = false, IsWidget = false, IsGui = false, @@ -87,7 +87,7 @@ template<> \ class QTypeModuleInfo \ { \ public: \ - enum Module { \ + enum Module : bool { \ IsCore = (((MODULE) == (QModulesPrivate::Core))), \ IsWidget = (((MODULE) == (QModulesPrivate::Widgets))), \ IsGui = (((MODULE) == (QModulesPrivate::Gui))), \ From 89d28ebe86e3e3912b4811f344c728e053bab122 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 27 Jun 2019 19:20:04 -0700 Subject: [PATCH 071/172] QTransposeProxyModel: include the moc in the .cpp All the other QtCore files do. Change-Id: Ie7ae7616eadf4035bec6fffd15ac3b5479716ff3 Reviewed-by: Marc Mutz --- src/corelib/itemmodels/qtransposeproxymodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/itemmodels/qtransposeproxymodel.cpp b/src/corelib/itemmodels/qtransposeproxymodel.cpp index d4f379bc64d..4853f906323 100644 --- a/src/corelib/itemmodels/qtransposeproxymodel.cpp +++ b/src/corelib/itemmodels/qtransposeproxymodel.cpp @@ -445,3 +445,5 @@ void QTransposeProxyModel::sort(int column, Qt::SortOrder order) } QT_END_NAMESPACE + +#include "moc_qtransposeproxymodel.cpp" From d62ee142839ff78134d6d4a48acfdd11040ceeae Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 May 2019 07:48:49 -0700 Subject: [PATCH 072/172] Work around Apple Clang's -Wshadow warning Well, yeah, it technically does... qcborstream.h:245:15: warning: declaration shadows a typedef in the global namespace [-Wshadow] /usr/include/libkern/OSTypes.h:36:26: note: previous declaration is here Fixes: QTBUG-75825 Change-Id: Idce141629dd34287808bfffd159ee2a75428bf12 Reviewed-by: Marc Mutz --- src/corelib/serialization/qcborstream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/serialization/qcborstream.h b/src/corelib/serialization/qcborstream.h index 3b13a309ab8..7a451e63ac9 100644 --- a/src/corelib/serialization/qcborstream.h +++ b/src/corelib/serialization/qcborstream.h @@ -242,8 +242,8 @@ private: template FP _toFloatingPoint() const noexcept { - using UInt = typename QIntegerForSizeof::Unsigned; - UInt u = UInt(value64); + using UIntFP = typename QIntegerForSizeof::Unsigned; + UIntFP u = UIntFP(value64); FP f; memcpy(static_cast(&f), &u, sizeof(f)); return f; From b321559a22a3ee6490695ecb9d95d3c9fbf7ee1c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 29 Apr 2019 11:13:04 -0700 Subject: [PATCH 073/172] Document OOM conditions in the QArrayData-based containers The other containers probably don't handle as well, so I just documented the ones that I know how they work. Fixes: QTBUG-75470 Change-Id: I95ecabe2f50e450c991afffd159a0483aac35a79 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Albert Astals Cid Reviewed-by: Thiago Macieira --- src/corelib/tools/qbytearray.cpp | 17 +++++++++++++++++ src/corelib/tools/qstring.cpp | 18 ++++++++++++++++++ src/corelib/tools/qvector.qdoc | 18 ++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 6cc41a89563..c2c2b9de285 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1043,6 +1043,23 @@ QByteArray qUncompress(const uchar* data, int nbytes) and QByteArray() compares equal to QByteArray(""). We recommend that you always use isEmpty() and avoid isNull(). + \section1 Maximum size and out-of-memory conditions + + The current version of QByteArray is limited to just under 2 GB (2^31 + bytes) in size. The exact value is architecture-dependent, since it depends + on the overhead required for managing the data block, but is no more than + 32 bytes. Raw data blocks are also limited by the use of \c int type in the + current version to 2 GB minus 1 byte. + + In case memory allocation fails, QByteArray will throw a \c std::bad_alloc + exception. Out of memory conditions in the Qt containers are the only case + where Qt will throw exceptions. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the QByteArray API. + \section1 Notes on Locale \section2 Number-String Conversions diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index ee9d486eb8b..a0e33d4e455 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1777,6 +1777,24 @@ const QString::Null QString::null = { }; and the \c{'+'} will automatically be performed as the \c{QStringBuilder} \c{'%'} everywhere. + \section1 Maximum size and out-of-memory conditions + + The current version of QString is limited to just under 2 GB (2^31 bytes) + in size. The exact value is architecture-dependent, since it depends on the + overhead required for managing the data block, but is no more than 32 + bytes. Raw data blocks are also limited by the use of \c int type in the + current version to 2 GB minus 1 byte. Since QString uses two bytes per + character, that translates to just under 2^30 characters in one QString. + + In case memory allocation fails, QString will throw a \c std::bad_alloc + exception. Out of memory conditions in the Qt containers are the only case + where Qt will throw exceptions. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the Qt API. + \sa fromRawData(), QChar, QLatin1String, QByteArray, QStringRef */ diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc index 75b17a42077..ad5821e73b8 100644 --- a/src/corelib/tools/qvector.qdoc +++ b/src/corelib/tools/qvector.qdoc @@ -173,6 +173,24 @@ For a detailed discussion comparing Qt containers with each other and with STL containers, see \l {Understand the Qt Containers}. + \section1 Maximum size and out-of-memory conditions + + The current version of QVector is limited to just under 2 GB (2^31 bytes) + in size. The exact value is architecture-dependent, since it depends on the + overhead required for managing the data block, but is no more than 32 + bytes. The number of elements that can be stored in a QVector is that size + divided by the size of each element. + + In case memory allocation fails, QVector will use the \l Q_CHECK_PTR macro, + which will throw a \c std::bad_alloc exception if the application is being + compiled with exception support. If exceptions are disabled, then running + out of memory is undefined behavior. + + Note that the operating system may impose further limits on applications + holding a lot of allocated memory, especially large, contiguous blocks. + Such considerations, the configuration of such behavior or any mitigation + are outside the scope of the Qt API. + \sa QVectorIterator, QMutableVectorIterator, QList, QLinkedList */ From 227c1a56ecb8b99cbd64bd6b8335b3cc3c8a21f1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 14 Apr 2019 08:20:31 -0700 Subject: [PATCH 074/172] Move the Item typedef to public in the associative Java iterators The documentation talks about them. They're just iterators. Fixes: QTBUG-75123 Change-Id: I194d3f37471a49788a7bfffd15956064b42383b7 Reviewed-by: Lars Knoll --- src/corelib/tools/qiterator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h index 586d26cbad7..177a4f1a4c3 100644 --- a/src/corelib/tools/qiterator.h +++ b/src/corelib/tools/qiterator.h @@ -115,11 +115,11 @@ template \ class Q##C##Iterator \ { \ typedef typename Q##C::const_iterator const_iterator; \ - typedef const_iterator Item; \ Q##C c; \ const_iterator i, n; \ inline bool item_exists() const { return n != c.constEnd(); } \ public: \ + typedef const_iterator Item; \ inline Q##C##Iterator(const Q##C &container) \ : c(container), i(c.constBegin()), n(c.constEnd()) {} \ inline Q##C##Iterator &operator=(const Q##C &container) \ @@ -148,11 +148,11 @@ class QMutable##C##Iterator \ { \ typedef typename Q##C::iterator iterator; \ typedef typename Q##C::const_iterator const_iterator; \ - typedef iterator Item; \ Q##C *c; \ iterator i, n; \ inline bool item_exists() const { return const_iterator(n) != c->constEnd(); } \ public: \ + typedef iterator Item; \ inline QMutable##C##Iterator(Q##C &container) \ : c(&container) \ { i = c->begin(); n = c->end(); } \ From a39b19b0c7419021b3c22dc4d4bced0995f3a29f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 27 Mar 2019 11:18:37 -0700 Subject: [PATCH 075/172] QTranslator: simplify QString byte-swapping code No need to check QSysInfo, just use qFromBigEndian. On big-endian systems, it does the memcpy for us. Change-Id: I1004b4b819774c4c9296fffd158fe3aa5ff0a287 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/kernel/qtranslator.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index dc0ab9f08aa..637ef84d21a 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -948,11 +948,8 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context, end: if (!tn) return QString(); - QString str = QString((const QChar *)tn, tn_length/2); - if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) { - QChar *data = str.data(); - qbswap(data, str.length(), data); - } + QString str(tn_length / 2, Qt::Uninitialized); + qFromBigEndian(tn, str.length(), str.data()); return str; } From 5d7e221bbf9e27e90448243909abc76d81733381 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 29 Mar 2019 12:49:47 -0700 Subject: [PATCH 076/172] QRandomGenerator: assert that bounded() calls have correct arguments Otherwise, the math will fail badly. Documentation improved to reflect reality. Change-Id: I9e3d261ad9bf41cfb2b6fffd159085cd38e3c388 Reviewed-by: Thiago Macieira --- src/corelib/global/qrandom.cpp | 16 ++++++++++++---- src/corelib/global/qrandom.h | 12 +++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 90df8653a73..bf01b7ae2a0 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -903,6 +903,10 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \snippet code/src_corelib_global_qrandom.cpp 12 + If the \a highest parameter is negative, the result will be negative too; + if it is infinite or NaN, the result will be infinite or NaN too (that is, + not random). + \sa generateDouble(), bounded() */ @@ -934,7 +938,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \overload Generates one random 32-bit quantity in the range between 0 (inclusive) and - \a highest (exclusive). \a highest must not be negative. + \a highest (exclusive). \a highest must be positive. Note that this function cannot be used to obtain values in the full 32-bit range of int. Instead, use generate() and cast to int. @@ -946,8 +950,11 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \fn quint32 QRandomGenerator::bounded(quint32 lowest, quint32 highest) \overload - Generates one random 32-bit quantity in the range between \a lowest (inclusive) - and \a highest (exclusive). The same result may also be obtained by using + Generates one random 32-bit quantity in the range between \a lowest + (inclusive) and \a highest (exclusive). The \a highest parameter must be + greater than \a lowest. + + The same result may also be obtained by using \l{http://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution}{\c std::uniform_int_distribution} with parameters \a lowest and \c{\a highest - 1}. That class can also be used to obtain quantities larger than 32 bits. @@ -968,7 +975,8 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel \overload Generates one random 32-bit quantity in the range between \a lowest - (inclusive) and \a highest (exclusive), both of which may be negative. + (inclusive) and \a highest (exclusive), both of which may be negative, but + \a highest must be greater than \a lowest. Note that this function cannot be used to obtain values in the full 32-bit range of int. Instead, use generate() and cast to int. diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 46d3e0e1526..260fc1501a4 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -122,16 +122,18 @@ public: return quint32(value); } - int bounded(int highest) - { - return int(bounded(quint32(highest))); - } - quint32 bounded(quint32 lowest, quint32 highest) { + Q_ASSERT(highest > lowest); return bounded(highest - lowest) + lowest; } + int bounded(int highest) + { + Q_ASSERT(highest > 0); + return int(bounded(0U, quint32(highest))); + } + int bounded(int lowest, int highest) { return bounded(highest - lowest) + lowest; From 66223727c708e48009cbf297721aa2d0134b48d2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 07:56:49 +0200 Subject: [PATCH 077/172] Port from implicit to explicit atomic pointer operations The old code used the implicit conversions from QAtomicPointer to T* and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixex some users of these APIs before we deprecate them. Change-Id: I0a88bb1c359392538bb64b511bfc62381a56a468 Reviewed-by: Thiago Macieira --- src/3rdparty/forkfd/forkfd.c | 4 ++-- src/corelib/io/qprocess_unix.cpp | 2 +- src/corelib/kernel/qcoreapplication.cpp | 18 ++++++++--------- src/corelib/kernel/qeventloop.cpp | 2 +- src/corelib/kernel/qobject.cpp | 26 ++++++++++++------------- src/corelib/kernel/qobject_p.h | 2 +- src/corelib/thread/qthread.cpp | 12 ++++++------ src/corelib/thread/qthread_unix.cpp | 8 ++++---- src/widgets/kernel/qapplication.cpp | 2 +- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index 1cbe0da771d..12537b61995 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -519,9 +519,9 @@ static void cleanup() ffd_atomic_store(&forkfd_status, 0, FFD_ATOMIC_RELAXED); /* free any arrays we might have */ - array = children.header.nextArray; + array = ffd_atomic_load(&children.header.nextArray, FFD_ATOMIC_ACQUIRE); while (array != NULL) { - BigArray *next = array->header.nextArray; + BigArray *next = ffd_atomic_load(&array->header.nextArray, FFD_ATOMIC_ACQUIRE); free(array); array = next; } diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 3a29a0d8420..1d5b76a8a49 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -517,7 +517,7 @@ void QProcessPrivate::startProcess() if (stderrChannel.pipe[0] != -1) ::fcntl(stderrChannel.pipe[0], F_SETFL, ::fcntl(stderrChannel.pipe[0], F_GETFL) | O_NONBLOCK); - if (threadData->eventDispatcher) { + if (threadData->eventDispatcher.loadAcquire()) { deathNotifier = new QSocketNotifier(forkfd, QSocketNotifier::Read, q); QObject::connect(deathNotifier, SIGNAL(activated(int)), q, SLOT(_q_processDied())); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 5d300a0488a..e5b88c3c26d 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -385,8 +385,8 @@ struct QCoreApplicationData { ~QCoreApplicationData() { #ifndef QT_NO_QOBJECT // cleanup the QAdoptedThread created for the main() thread - if (QCoreApplicationPrivate::theMainThread) { - QThreadData *data = QThreadData::get2(QCoreApplicationPrivate::theMainThread); + if (auto *t = QCoreApplicationPrivate::theMainThread.loadAcquire()) { + QThreadData *data = QThreadData::get2(t); data->deref(); // deletes the data and the adopted thread } #endif @@ -486,7 +486,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint #endif QThread *cur = QThread::currentThread(); // note: this may end up setting theMainThread! - if (cur != theMainThread) + if (cur != theMainThread.loadAcquire()) qWarning("WARNING: QApplication was not created in the main() thread."); #endif } @@ -862,7 +862,7 @@ void QCoreApplicationPrivate::init() Q_ASSERT(eventDispatcher); if (!eventDispatcher->parent()) { - eventDispatcher->moveToThread(threadData->thread); + eventDispatcher->moveToThread(threadData->thread.loadAcquire()); eventDispatcher->setParent(q); } @@ -1181,7 +1181,7 @@ static bool doNotify(QObject *receiver, QEvent *event) bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event) { // We can't access the application event filters outside of the main thread (race conditions) - Q_ASSERT(receiver->d_func()->threadData->thread == mainThread()); + Q_ASSERT(receiver->d_func()->threadData->thread.loadAcquire() == mainThread()); if (extraData) { // application event filters are only called for objects in the GUI thread @@ -1234,7 +1234,7 @@ bool QCoreApplicationPrivate::notify_helper(QObject *receiver, QEvent * event) // send to all application event filters (only does anything in the main thread) if (QCoreApplication::self - && receiver->d_func()->threadData->thread == mainThread() + && receiver->d_func()->threadData->thread.loadAcquire() == mainThread() && QCoreApplication::self->d_func()->sendThroughApplicationEventFilters(receiver, event)) { filtered = true; return filtered; @@ -2905,7 +2905,7 @@ void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filt return; } - QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(QCoreApplicationPrivate::theMainThread); + QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(QCoreApplicationPrivate::theMainThread.loadAcquire()); if (!filterObj || !eventDispatcher) return; eventDispatcher->installNativeEventFilter(filterObj); @@ -2961,7 +2961,7 @@ bool QCoreApplication::hasPendingEvents() */ QAbstractEventDispatcher *QCoreApplication::eventDispatcher() { - if (QCoreApplicationPrivate::theMainThread) + if (QCoreApplicationPrivate::theMainThread.loadAcquire()) return QCoreApplicationPrivate::theMainThread.loadRelaxed()->eventDispatcher(); return 0; } @@ -2974,7 +2974,7 @@ QAbstractEventDispatcher *QCoreApplication::eventDispatcher() */ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) { - QThread *mainThread = QCoreApplicationPrivate::theMainThread; + QThread *mainThread = QCoreApplicationPrivate::theMainThread.loadAcquire(); if (!mainThread) mainThread = QThread::currentThread(); // will also setup theMainThread mainThread->setEventDispatcher(eventDispatcher); diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index 2104b220954..eacd0c4e73e 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -165,7 +165,7 @@ int QEventLoop::exec(ProcessEventsFlags flags) { Q_D(QEventLoop); //we need to protect from race condition with QThread::exit - QMutexLocker locker(&static_cast(QObjectPrivate::get(d->threadData->thread))->mutex); + QMutexLocker locker(&static_cast(QObjectPrivate::get(d->threadData->thread.loadAcquire()))->mutex); if (d->threadData->quitNow) return -1; diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 1540ebfe122..9a2ae36177c 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -219,7 +219,7 @@ QObjectPrivate::QObjectPrivate(int version) QObjectPrivate::~QObjectPrivate() { if (extraData && !extraData->runningTimers.isEmpty()) { - if (Q_LIKELY(threadData->thread == QThread::currentThread())) { + if (Q_LIKELY(threadData->thread.loadAcquire() == QThread::currentThread())) { // unregister pending timers if (threadData->hasEventDispatcher()) threadData->eventDispatcher.loadRelaxed()->unregisterTimers(q_ptr); @@ -493,11 +493,11 @@ bool QObjectPrivate::maybeSignalConnected(uint signalIndex) const if (!signalVector) return false; - if (signalVector->at(-1).first) + if (signalVector->at(-1).first.loadAcquire()) return true; if (signalIndex < uint(cd->signalVectorCount())) { - const QObjectPrivate::Connection *c = signalVector->at(signalIndex).first; + const QObjectPrivate::Connection *c = signalVector->at(signalIndex).first.loadAcquire(); return c != nullptr; } return false; @@ -819,8 +819,8 @@ static bool check_parent_thread(QObject *parent, QThreadData *currentThreadData) { if (parent && parentThreadData != currentThreadData) { - QThread *parentThread = parentThreadData->thread; - QThread *currentThread = currentThreadData->thread; + QThread *parentThread = parentThreadData->thread.loadAcquire(); + QThread *currentThread = currentThreadData->thread.loadAcquire(); qWarning("QObject: Cannot create children for a parent that is in a different thread.\n" "(Parent is %s(%p), parent's thread is %s(%p), current thread is %s(%p)", parent->metaObject()->className(), @@ -987,11 +987,11 @@ QObject::~QObject() QObjectPrivate::ConnectionList &connectionList = cd->connectionsForSignal(signal); while (QObjectPrivate::Connection *c = connectionList.first.loadRelaxed()) { - Q_ASSERT(c->receiver); + Q_ASSERT(c->receiver.loadAcquire()); QBasicMutex *m = signalSlotLock(c->receiver.loadRelaxed()); bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); - if (c->receiver) { + if (c->receiver.loadAcquire()) { cd->removeConnection(c); Q_ASSERT(connectionList.first.loadRelaxed() != c); } @@ -1003,7 +1003,7 @@ QObject::~QObject() /* Disconnect all senders: */ while (QObjectPrivate::Connection *node = cd->senders) { - Q_ASSERT(node->receiver); + Q_ASSERT(node->receiver.loadAcquire()); QObject *sender = node->sender; // Send disconnectNotify before removing the connection from sender's connection list. // This ensures any eventual destructor of sender will block on getting receiver's lock @@ -1453,7 +1453,7 @@ bool QObject::blockSignals(bool block) noexcept */ QThread *QObject::thread() const { - return d_func()->threadData->thread; + return d_func()->threadData->thread.loadAcquire(); } /*! @@ -1500,7 +1500,7 @@ void QObject::moveToThread(QThread *targetThread) { Q_D(QObject); - if (d->threadData->thread == targetThread) { + if (d->threadData->thread.loadAcquire() == targetThread) { // object is already in this thread return; } @@ -1516,7 +1516,7 @@ void QObject::moveToThread(QThread *targetThread) QThreadData *currentData = QThreadData::current(); QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr; - if (d->threadData->thread == 0 && currentData == targetData) { + if (d->threadData->thread.loadAcquire() == 0 && currentData == targetData) { // one exception to the rule: we allow moving objects with no thread affinity to the current thread currentData = d->threadData; } else if (d->threadData != currentData) { @@ -3716,7 +3716,7 @@ void doActivate(QObject *sender, int signal_index, void **argv) bool senderDeleted = false; { - Q_ASSERT(sp->connections); + Q_ASSERT(sp->connections.loadAcquire()); QObjectPrivate::ConnectionDataPointer connections(sp->connections.loadRelaxed()); QObjectPrivate::SignalVector *signalVector = connections->signalVector.loadRelaxed(); @@ -3773,7 +3773,7 @@ void doActivate(QObject *sender, int signal_index, void **argv) QSemaphore semaphore; { QBasicMutexLocker locker(signalSlotLock(sender)); - if (!c->receiver) + if (!c->receiver.loadAcquire()) continue; QMetaCallEvent *ev = c->isSlotObject ? new QMetaCallEvent(c->slotObj, sender, signal_index, 0, 0, argv, &semaphore) : diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 247c7b15010..9cf1bfed08f 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -312,7 +312,7 @@ public: } } int signalVectorCount() const { - return signalVector ? signalVector.loadRelaxed()->count() : -1; + return signalVector.loadAcquire() ? signalVector.loadRelaxed()->count() : -1; } static void deleteOrphaned(ConnectionOrSignalVector *c); diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 1eac7db11dc..fe555afca7b 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -73,8 +73,8 @@ QThreadData::~QThreadData() // crashing during QCoreApplicationData's global static cleanup we need to // safeguard the main thread here.. This fix is a bit crude, but it solves // the problem... - if (this->thread == QCoreApplicationPrivate::theMainThread) { - QCoreApplicationPrivate::theMainThread = 0; + if (this->thread.loadAcquire() == QCoreApplicationPrivate::theMainThread.loadAcquire()) { + QCoreApplicationPrivate::theMainThread.storeRelease(nullptr); QThreadData::clearCurrentThreadData(); } @@ -85,8 +85,8 @@ QThreadData::~QThreadData() // because this destructor is still running (the _ref sub-object has not // been destroyed) and there's no reentrancy. The refcount will become // negative, but that's acceptable. - QThread *t = thread; - thread = 0; + QThread *t = thread.loadAcquire(); + thread.storeRelease(nullptr); delete t; for (int i = 0; i < postEventList.size(); ++i) { @@ -393,7 +393,7 @@ QThread *QThread::currentThread() { QThreadData *data = QThreadData::current(); Q_ASSERT(data != 0); - return data->thread; + return data->thread.loadAcquire(); } /*! @@ -980,7 +980,7 @@ bool QThread::event(QEvent *event) void QThread::requestInterruption() { - if (this == QCoreApplicationPrivate::theMainThread) { + if (this == QCoreApplicationPrivate::theMainThread.loadAcquire()) { qWarning("QThread::requestInterruption has no effect on the main thread"); return; } diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 89efbff6aa9..38e9c1c3ec2 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -141,7 +141,7 @@ static void destroy_current_thread_data(void *p) pthread_setspecific(current_thread_data_key, p); QThreadData *data = static_cast(p); if (data->isAdopted) { - QThread *thread = data->thread; + QThread *thread = data->thread.loadAcquire(); Q_ASSERT(thread); QThreadPrivate *thread_p = static_cast(QObjectPrivate::get(thread)); Q_ASSERT(!thread_p->finished); @@ -253,8 +253,8 @@ QThreadData *QThreadData::current(bool createIfNecessary) data->deref(); data->isAdopted = true; data->threadId.storeRelaxed(to_HANDLE(pthread_self())); - if (!QCoreApplicationPrivate::theMainThread) - QCoreApplicationPrivate::theMainThread = data->thread.loadRelaxed(); + if (!QCoreApplicationPrivate::theMainThread.loadAcquire()) + QCoreApplicationPrivate::theMainThread.storeRelease(data->thread.loadRelaxed()); } return data; } @@ -285,7 +285,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat else return new QEventDispatcherUNIX; #elif !defined(QT_NO_GLIB) - const bool isQtMainThread = data->thread == QCoreApplicationPrivate::mainThread(); + const bool isQtMainThread = data->thread.loadAcquire() == QCoreApplicationPrivate::mainThread(); if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && (isQtMainThread || qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")) && QEventDispatcherGlib::versionSupported()) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 22ebeaae51b..58f63c0feda 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3666,7 +3666,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) // send to all application event filters if (threadRequiresCoreApplication() - && receiver->d_func()->threadData->thread == mainThread() + && receiver->d_func()->threadData->thread.loadAcquire() == mainThread() && sendThroughApplicationEventFilters(receiver, e)) { filtered = true; return filtered; From 56962604254a31d5d54ea41044a5c251ff27fa0c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 17:41:59 +0200 Subject: [PATCH 078/172] QObject: fix allocation of IDs for the undocumented userData() feature This appears to have come to some fame on the internet, so better fix the implementation before we remove it in Qt 6. Change-Id: Ia37ca89105b13bea1ffcdce8b2e8cd957b7bd108 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 9a2ae36177c..69556ba9e31 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4187,13 +4187,14 @@ void QObject::dumpObjectInfo() const } #ifndef QT_NO_USERDATA +static QBasicAtomicInteger user_data_registration = Q_BASIC_ATOMIC_INITIALIZER(0); + /*! \internal */ uint QObject::registerUserData() { - static int user_data_registration = 0; - return user_data_registration++; + return user_data_registration.fetchAndAddRelaxed(1); } /*! From a27e7e815175bc9417aaf7377b349109afd235e4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 17:41:59 +0200 Subject: [PATCH 079/172] QObject: deprecate the undocumented userData() feature ... and schedule it for removal in Qt 6. This appears to have come to some fame on the internet, so better add a deprecation warning before we remove it in Qt 6. Change-Id: I42d91d933f47dfd2d8d54c92358e9e46ced6bf21 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/kernel/qobject.h | 6 ++++++ tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 7f72b69c1a9..240ace1e27b 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -77,6 +77,9 @@ class QRegExp; #if QT_CONFIG(regularexpression) class QRegularExpression; #endif +#if !QT_DEPRECATED_SINCE(5, 14) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +# define QT_NO_USERDATA +#endif #ifndef QT_NO_USERDATA class QObjectUserData; #endif @@ -405,8 +408,11 @@ public: #endif // QT_NO_PROPERTIES #ifndef QT_NO_USERDATA + QT_DEPRECATED_VERSION_5_14 static uint registerUserData(); + QT_DEPRECATED_VERSION_X_5_14("Use setProperty()") void setUserData(uint id, QObjectUserData* data); + QT_DEPRECATED_VERSION_X_5_14("Use property()") QObjectUserData* userData(uint id) const; #endif // QT_NO_USERDATA diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 7c9d8a476aa..1778bf24bcf 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -81,7 +81,9 @@ private slots: void senderTest(); void declareInterface(); void qpointerResetBeforeDestroyedSignal(); +#ifndef QT_NO_USERDATA void testUserData(); +#endif void childDeletesItsSibling(); void dynamicProperties(); void floatProperty(); @@ -2338,6 +2340,7 @@ void tst_QObject::declareInterface() } +#ifndef QT_NO_USERDATA class CustomData : public QObjectUserData { public: @@ -2380,6 +2383,7 @@ void tst_QObject::testUserData() QCOMPARE(data->id, id); } } +#endif // QT_NO_USERDATA class DestroyedListener : public QObject { From 840f55f0ae9f0911e963c492d12944c5b4c12c60 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 29 Jun 2019 09:08:34 +0200 Subject: [PATCH 080/172] Remove unused qmutexpool_p.h includes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic5f56b12953f2e42d94f6e6c14fac166c0c75539 Reviewed-by: Mårten Nordheim --- src/corelib/kernel/qeventdispatcher_win.cpp | 1 - src/network/kernel/qauthenticator.cpp | 1 - src/network/kernel/qdnslookup_win.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index c2e57a7924d..dea6cf6389c 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -52,7 +52,6 @@ #include "qelapsedtimer.h" #include "qcoreapplication_p.h" #include -#include #include QT_BEGIN_NAMESPACE diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 3ca8806c2ba..4100dfd7843 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -52,7 +52,6 @@ #ifdef Q_OS_WIN #include -#include #include #endif diff --git a/src/network/kernel/qdnslookup_win.cpp b/src/network/kernel/qdnslookup_win.cpp index cfdb9ca6339..262893179cc 100644 --- a/src/network/kernel/qdnslookup_win.cpp +++ b/src/network/kernel/qdnslookup_win.cpp @@ -41,7 +41,6 @@ #include "qdnslookup_p.h" #include -#include #include #include From 65b8f59e045bb41fef99b1a44f462115de65064a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 24 Jun 2019 09:41:07 +0200 Subject: [PATCH 081/172] QMutexPool: fix memory order of atomic operations The array of QAtomicPointer can be initialized using relaxed stores of nullptr, since nullptr is the whole data. But once we store an actual QMutex pointer in the array, we need to publish the indirect data thus created. We did this, with testAndSetRelease(); what was missing was a corresponding acquire fence on load, without which there is no happens-before relationship between the writes performed by the QMutex ctor and the reads performed by a subsequent mutex.lock(), say, on the same data. Fix by adding acquire fences to all loads. That includes the dtor, since mutexes may have been created in different threads, and never been imported into this_thread before the dtor is running. As a drive-by, return a new'ed QMutex that was successfully installed directly to the caller, without again going through a load-acquire. Change-Id: Ia25d205b1127c8c4de0979cef997d1a88123c5c3 Reviewed-by: David Faure Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira --- src/corelib/thread/qmutexpool.cpp | 9 ++++++--- src/corelib/thread/qmutexpool_p.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp index 2a021978598..3ece30c01c7 100644 --- a/src/corelib/thread/qmutexpool.cpp +++ b/src/corelib/thread/qmutexpool.cpp @@ -104,7 +104,7 @@ QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size) QMutexPool::~QMutexPool() { for (int index = 0; index < mutexes.count(); ++index) - delete mutexes[index].loadRelaxed(); + delete mutexes[index].loadAcquire(); } /*! @@ -129,9 +129,12 @@ QMutex *QMutexPool::createMutex(int index) { // mutex not created, create one QMutex *newMutex = new QMutex(recursionMode); - if (!mutexes[index].testAndSetRelease(0, newMutex)) + if (!mutexes[index].testAndSetRelease(nullptr, newMutex)) { delete newMutex; - return mutexes[index].loadRelaxed(); + return mutexes[index].loadAcquire(); + } else { + return newMutex; + } } /*! diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h index 1a47231abcb..00710199b88 100644 --- a/src/corelib/thread/qmutexpool_p.h +++ b/src/corelib/thread/qmutexpool_p.h @@ -68,7 +68,7 @@ public: inline QMutex *get(const void *address) { int index = uint(quintptr(address)) % mutexes.count(); - QMutex *m = mutexes[index].loadRelaxed(); + QMutex *m = mutexes[index].loadAcquire(); if (m) return m; else From e7b1c500d45c8a96fb09b0b425472eb1cdb10943 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 27 May 2019 17:32:37 +0200 Subject: [PATCH 082/172] Mark qHash(QOcspResponse) as noexcept MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because it is. Change-Id: I8d5204c30884b2c8656615a7d82428c539672d28 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Mårten Nordheim Reviewed-by: Ville Voutilainen --- src/network/ssl/qocspresponse.cpp | 2 +- src/network/ssl/qocspresponse.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/ssl/qocspresponse.cpp b/src/network/ssl/qocspresponse.cpp index 79f0cfd1d4d..bf27bb768b0 100644 --- a/src/network/ssl/qocspresponse.cpp +++ b/src/network/ssl/qocspresponse.cpp @@ -239,7 +239,7 @@ Q_NETWORK_EXPORT bool operator==(const QOcspResponse &lhs, const QOcspResponse & \since 5.13 \relates QHash */ -uint qHash(const QOcspResponse &response, uint seed) +uint qHash(const QOcspResponse &response, uint seed) noexcept { const QOcspResponsePrivate *d = response.d.data(); Q_ASSERT(d); diff --git a/src/network/ssl/qocspresponse.h b/src/network/ssl/qocspresponse.h index 0e134d236bb..cf6be5a3695 100644 --- a/src/network/ssl/qocspresponse.h +++ b/src/network/ssl/qocspresponse.h @@ -73,7 +73,7 @@ enum class QOcspRevocationReason }; class QOcspResponse; -Q_NETWORK_EXPORT uint qHash(const QOcspResponse &response, uint seed = 0); +Q_NETWORK_EXPORT uint qHash(const QOcspResponse &response, uint seed = 0) noexcept; class QOcspResponsePrivate; class Q_NETWORK_EXPORT QOcspResponse @@ -100,7 +100,7 @@ private: friend class QSslSocketBackendPrivate; friend Q_NETWORK_EXPORT bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs); - friend Q_NETWORK_EXPORT uint qHash(const QOcspResponse &response, uint seed); + friend Q_NETWORK_EXPORT uint qHash(const QOcspResponse &response, uint seed) noexcept; QSharedDataPointer d; }; From fabf9239e0e6231f09d4a324bfe85ffcc529da3d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 13 Jun 2019 11:54:29 +0200 Subject: [PATCH 083/172] QTestLib: Replace typedef by 'using' Apply Fixits by Qt Creator with some amendments. Task-number: QTBUG-69413 Change-Id: I366cca6e5755719e8241e76774af6be2b5312627 Reviewed-by: Lars Knoll --- src/testlib/qtestaccessible.h | 2 +- src/testlib/qtestcase.cpp | 2 +- src/testlib/qtestcase.h | 2 +- src/testlib/qtesttable.cpp | 10 ++++------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index d14dcec0311..bd77ee77a19 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE class QObject; // Use pointers since we subclass QAccessibleEvent -typedef QList EventList; +using EventList = QList; bool operator==(const QAccessibleEvent &l, const QAccessibleEvent &r) { diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index ac309374e3c..10477238cb4 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -301,7 +301,7 @@ class TestMethods { public: Q_DISABLE_COPY_MOVE(TestMethods) - typedef std::vector MetaMethods; + using MetaMethods = std::vector; explicit TestMethods(const QObject *o, const MetaMethods &m = MetaMethods()); diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 794283ff782..af7c0f43b95 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -336,7 +336,7 @@ namespace QTest template inline void addColumn(const char *name, T * = nullptr) { - typedef std::is_same QIsSameTConstChar; + using QIsSameTConstChar = std::is_same; Q_STATIC_ASSERT_X(!QIsSameTConstChar::value, "const char* is not allowed as a test data format."); addColumnInternal(qMetaTypeId(), name); } diff --git a/src/testlib/qtesttable.cpp b/src/testlib/qtesttable.cpp index 8d42668a5b8..20e0702d443 100644 --- a/src/testlib/qtesttable.cpp +++ b/src/testlib/qtesttable.cpp @@ -65,10 +65,10 @@ public: int type; }; - typedef std::vector ElementList; + using ElementList = std::vector; ElementList elementList; - typedef std::vector DataList; + using DataList = std::vector; DataList dataList; void addColumn(int elemType, const char *elemName) { elementList.push_back(Element(elemName, elemType)); } @@ -152,14 +152,12 @@ private: int QTestTable::indexOf(const char *elementName) const { - typedef QTestTablePrivate::ElementList::const_iterator It; - QTEST_ASSERT(elementName); const QTestTablePrivate::ElementList &elementList = d->elementList; - const It it = std::find_if(elementList.begin(), elementList.end(), - NamePredicate(elementName)); + const auto it = std::find_if(elementList.begin(), elementList.end(), + NamePredicate(elementName)); return it != elementList.end() ? int(it - elementList.begin()) : -1; } From ff2b2032a089d74975da4a3fac7c7c90989e6dc5 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 20 Jun 2019 17:40:45 +0200 Subject: [PATCH 084/172] Remove usages of deprecated APIs from QtAlgorithms Task-number: QTBUG-76491 Change-Id: I9dab736a0cbd2e86588919640c26e8ce6b3674d0 Reviewed-by: Alex Blasche Reviewed-by: Leena Miettinen --- .../doc/snippets/code/doc_src_qset.cpp | 6 ++--- .../code/src_corelib_tools_qlinkedlist.cpp | 8 +++---- .../code/src_corelib_tools_qlistdata.cpp | 2 +- src/corelib/doc/src/containers.qdoc | 2 +- src/corelib/tools/qlinkedlist.cpp | 6 ++--- .../doc/src/model-view-programming.qdoc | 2 +- .../corelib/io/largefile/tst_largefile.cpp | 1 - .../tools/collections/tst_collections.cpp | 23 ++----------------- .../tst_qtextboundaryfinder.cpp | 2 +- .../gui/kernel/qkeyevent/tst_qkeyevent.cpp | 2 +- .../kernel/qkeysequence/tst_qkeysequence.cpp | 2 +- .../network/ssl/qsslsocket/tst_qsslsocket.cpp | 6 ++--- .../corelib/tools/qvector/qrawvector.h | 7 +++--- .../qnetworkreply/tst_qnetworkreply.cpp | 2 +- tests/manual/socketengine/main.cpp | 2 +- util/glgen/codegenerator.cpp | 2 +- util/glgen/legacyspecparser.cpp | 2 +- util/lexgen/generator.cpp | 6 ++--- util/lexgen/nfa.cpp | 2 +- util/unicode/codecs/big5/main.cpp | 4 ++-- util/unicode/main.cpp | 4 ++-- 21 files changed, 35 insertions(+), 58 deletions(-) diff --git a/src/corelib/doc/snippets/code/doc_src_qset.cpp b/src/corelib/doc/snippets/code/doc_src_qset.cpp index 7f7cec8b458..4248c496422 100644 --- a/src/corelib/doc/snippets/code/doc_src_qset.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qset.cpp @@ -131,7 +131,7 @@ while (i != set.end()) { //! [10] QSet set; ... -QSet::iterator it = qFind(set.begin(), set.end(), "Jeanette"); +QSet::iterator it = std::find(set.begin(), set.end(), "Jeanette"); if (it != set.end()) cout << "Found Jeanette" << Qt::endl; //! [10] @@ -150,7 +150,7 @@ for (i = set.begin(); i != set.end(); ++i) //! [12] QSet set; ... -QSet::iterator it = qFind(set.begin(), set.end(), "Jeanette"); +QSet::iterator it = std::find(set.begin(), set.end(), "Jeanette"); if (it != set.constEnd()) cout << "Found Jeanette" << Qt::endl; //! [12] @@ -161,7 +161,7 @@ QSet set; set << "red" << "green" << "blue" << ... << "black"; QList list = set.toList(); -qSort(list); +std::sort(list.begin(), list.end()); //! [13] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp index e0d3c71dc5a..e8754a5f34b 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp @@ -119,8 +119,8 @@ for (i = list.begin(); i != list.end(); ++i) //! [8] QLinkedList list; ... -QLinkedList::iterator it = qFind(list.begin(), - list.end(), "Joel"); +QLinkedList::iterator it = std::find(list.begin(), + list.end(), "Joel"); if (it != list.end()) cout << "Found Joel" << Qt::endl; //! [8] @@ -189,8 +189,8 @@ for (i = list.constBegin(); i != list.constEnd(); ++i) //! [15] QLinkedList list; ... -QLinkedList::iterator it = qFind(list.constBegin(), - list.constEnd(), "Joel"); +QLinkedList::const_iterator it = std::find(list.constBegin(), + list.constEnd(), "Joel"); if (it != list.constEnd()) cout << "Found Joel" << Qt::endl; //! [15] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp index a24e599f2fe..38fa526ef4a 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp @@ -247,7 +247,7 @@ QSet set; set << 20 << 30 << 40 << ... << 70; QList list = QList::fromSet(set); -qSort(list); +std::sort(list.begin(), list.end()); //! [23] diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index e6c95129dbc..919533f651b 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -666,7 +666,7 @@ \li \b{Logarithmic time:} O(log \e n). A function that runs in logarithmic time is a function whose running time is proportional to the logarithm of the number of items in the - container. One example is qBinaryFind(). + container. One example is the binary search algorithm. \li \b{Linear time:} O(\e n). A function that runs in linear time will execute in a time directly proportional to the number of diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp index c0450f5cd86..d239fe0ef4d 100644 --- a/src/corelib/tools/qlinkedlist.cpp +++ b/src/corelib/tools/qlinkedlist.cpp @@ -742,8 +742,7 @@ const QLinkedListData QLinkedListData::shared_null = { \snippet code/src_corelib_tools_qlinkedlist.cpp 7 STL-style iterators can be used as arguments to \l{generic - algorithms}. For example, here's how to find an item in the list - using the qFind() algorithm: + algorithms}. For example, here's how to find an item in the list: \snippet code/src_corelib_tools_qlinkedlist.cpp 8 @@ -987,8 +986,7 @@ const QLinkedListData QLinkedListData::shared_null = { \snippet code/src_corelib_tools_qlinkedlist.cpp 14 STL-style iterators can be used as arguments to \l{generic - algorithms}. For example, here's how to find an item in the list - using the qFind() algorithm: + algorithms}. For example, here's how to find an item in the list: \snippet code/src_corelib_tools_qlinkedlist.cpp 15 diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index 9335ff78c9c..236582ef3fc 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -1912,7 +1912,7 @@ \section3 Custom sorting models - QSortFilterProxyModel instances use Qt's built-in qStableSort() function to set up + QSortFilterProxyModel instances use std::stable_sort() function to set up mappings between items in the source model and those in the proxy model, allowing a sorted hierarchy of items to be exposed to views without modifying the structure of the source model. To provide custom sorting behavior, reimplement the diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index f459f62c91e..e6d2f10c166 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -28,7 +28,6 @@ #include -#include #include #include #include diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 2a8b2649981..e2ce5cb9f97 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -67,7 +67,6 @@ void foo() #include -#include "qalgorithms.h" #include "qbitarray.h" #include "qbytearray.h" #include "qcache.h" @@ -191,16 +190,6 @@ void tst_Collections::list() QVERIFY(list.size() == 6); QVERIFY(list.end() - list.begin() == list.size()); -#if !defined(Q_CC_MSVC) && !defined(Q_CC_SUN) - QVERIFY(std::binary_search(list.begin(), list.end(), 2) == true); - QVERIFY(std::binary_search(list.begin(), list.end(), 9) == false); -#endif - QVERIFY(qBinaryFind(list.begin(), list.end(), 2) == list.begin() + 1); - QVERIFY(qLowerBound(list.begin(), list.end(), 2) == list.begin() + 1); - QVERIFY(qUpperBound(list.begin(), list.end(), 2) == list.begin() + 2); - QVERIFY(qBinaryFind(list.begin(), list.end(), 9) == list.end()); - QVERIFY(qLowerBound(list.begin(), list.end(), 9) == list.end()); - QVERIFY(qUpperBound(list.begin(), list.end(), 9) == list.end()); { int sum = 0; QListIterator i(list); @@ -996,16 +985,8 @@ void tst_Collections::vector() v.append(2); QVERIFY(*v.begin() == 2); v.prepend(1); - - v << 3 << 4 << 5 << 6; - QVERIFY(std::binary_search(v.begin(), v.end(), 2) == true); - QVERIFY(std::binary_search(v.begin(), v.end(), 9) == false); - QVERIFY(qBinaryFind(v.begin(), v.end(), 2) == v.begin() + 1); - QVERIFY(qLowerBound(v.begin(), v.end(), 2) == v.begin() + 1); - QVERIFY(qUpperBound(v.begin(), v.end(), 2) == v.begin() + 2); - QVERIFY(qBinaryFind(v.begin(), v.end(), 9) == v.end()); - QVERIFY(qLowerBound(v.begin(), v.end(), 9) == v.end()); - QVERIFY(qUpperBound(v.begin(), v.end(), 9) == v.end()); + QVERIFY(*v.begin() == 1); + QVERIFY(*(v.begin() + 1) == 2); v.clear(); v << 1 << 2 << 3; diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 5701335b4ac..a46011ff6cd 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -192,7 +192,7 @@ static void doTestData(const QString &testString, const QList &expectedBrea // test toPreviousBoundary() { QList expectedBreakPositionsRev = expectedBreakPositions; - std::sort(expectedBreakPositionsRev.begin(), expectedBreakPositionsRev.end(), qGreater()); + std::sort(expectedBreakPositionsRev.begin(), expectedBreakPositionsRev.end(), std::greater()); QList actualBreakPositions; boundaryFinder.toEnd(); diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp index 9a4c560a087..87a47bd93b2 100644 --- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -155,7 +155,7 @@ void tst_QKeyEvent::modifiers_data() modifierCombinations.append(modifierCombination); } - qSort(modifierCombinations.begin(), modifierCombinations.end(), orderByModifier); + std::sort(modifierCombinations.begin(), modifierCombinations.end(), orderByModifier); QTest::addColumn("modifiers"); foreach (const QVector combination, modifierCombinations) { diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index f8b6bf064a0..874468c9546 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -86,7 +86,7 @@ static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntrie static QChar macSymbolForQtKey(int key) { - const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key); + const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key); if (i == MacSpecialKeyEntriesEnd) return QChar(); return QChar(i->macSymbol); diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index b05f989b5c2..4035dfbf5f1 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -711,7 +711,7 @@ void tst_QSslSocket::sslErrors() const auto socketSslErrors = socket->sslErrors(); for (const QSslError &err : socketSslErrors) sslErrors << err.error(); - qSort(sslErrors); + std::sort(sslErrors.begin(), sslErrors.end()); QVERIFY(sslErrors.contains(QSslError::HostNameMismatch)); QVERIFY(sslErrors.contains(FLUKE_CERTIFICATE_ERROR)); @@ -721,7 +721,7 @@ void tst_QSslSocket::sslErrors() const auto sslErrorsSpyErrors = qvariant_cast >(qAsConst(sslErrorsSpy).first().first()); for (const QSslError &err : sslErrorsSpyErrors) emittedErrors << err.error(); - qSort(emittedErrors); + std::sort(emittedErrors.begin(), emittedErrors.end()); QCOMPARE(sslErrors, emittedErrors); // check the same errors were emitted by peerVerifyError @@ -730,7 +730,7 @@ void tst_QSslSocket::sslErrors() const QList &peerVerifyList = peerVerifyErrorSpy; for (const QVariantList &args : peerVerifyList) peerErrors << qvariant_cast(args.first()).error(); - qSort(peerErrors); + std::sort(peerErrors.begin(), peerErrors.end()); QCOMPARE(sslErrors, peerErrors); } diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h index c7173b5b8d5..16a911c63a8 100644 --- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h +++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -263,9 +262,9 @@ public: //static QRawVector fromList(const QList &list); static inline QRawVector fromStdVector(const std::vector &vector) - { QRawVector tmp; qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } + { QRawVector tmp; std::copy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } inline std::vector toStdVector() const - { std::vector tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } + { std::vector tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } private: T *allocate(int alloc); @@ -568,7 +567,7 @@ typename QRawVector::iterator QRawVector::erase(iterator abegin, iterator int l = int(aend - m_begin); int n = l - f; if (QTypeInfo::isComplex) { - qCopy(m_begin + l, m_begin + m_size, m_begin + f); + std::copy(m_begin + l, m_begin + m_size, m_begin + f); T *i = m_begin + m_size; T *b = m_begin + m_size - n; while (i != b) { diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index b2f4cbd7ba4..c182ef7ebf6 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -908,7 +908,7 @@ void tst_qnetworkreply::httpsRequestChain() qint64 average = (elapsed / count); - qSort(helper.timeList); + std::sort(helper.timeList.begin(), helper.timeList.end()); qint64 median = helper.timeList.at(5); qDebug() << "Total:" << elapsed << " Average:" << average << " Median:" << median; diff --git a/tests/manual/socketengine/main.cpp b/tests/manual/socketengine/main.cpp index 0d491e73503..3e3e7e53e55 100644 --- a/tests/manual/socketengine/main.cpp +++ b/tests/manual/socketengine/main.cpp @@ -83,7 +83,7 @@ int main(int argc, char**argv) // disconnected exit(0); } - qFill(buf, buf + bufsize, 0); + std::fill(buf, buf + bufsize, 0); ret = socketEngine->read(buf, available); if (ret > 0) { printf("%s", buf); diff --git a/util/glgen/codegenerator.cpp b/util/glgen/codegenerator.cpp index 4627daa48b8..08327a62f56 100644 --- a/util/glgen/codegenerator.cpp +++ b/util/glgen/codegenerator.cpp @@ -184,7 +184,7 @@ void CodeGenerator::writeCoreFactoryImplementation(const QString &fileName) cons // Get the set of version functions classes we need to create QList versions = m_parser->versions(); - qSort(versions.begin(), versions.end(), qGreater()); + std::sort(m_versions.begin(), m_versions.end(), std::greater()); // Outout the #include statements stream << QStringLiteral("#if !defined(QT_OPENGL_ES_2)") << endl; diff --git a/util/glgen/legacyspecparser.cpp b/util/glgen/legacyspecparser.cpp index 0f4d085bbac..ab2c9495e75 100644 --- a/util/glgen/legacyspecparser.cpp +++ b/util/glgen/legacyspecparser.cpp @@ -291,7 +291,7 @@ void LegacySpecParser::parseFunctions(QTextStream &stream) } m_versions = versions.toList(); - qSort(m_versions); + std::sort(m_versions.begin(), m_versions.end()); } bool LegacySpecParser::inDeprecationException(const QString &functionName) const diff --git a/util/lexgen/generator.cpp b/util/lexgen/generator.cpp index 481d586e730..3b966e025b5 100644 --- a/util/lexgen/generator.cpp +++ b/util/lexgen/generator.cpp @@ -183,7 +183,7 @@ Generator::Generator(const DFA &_dfa, const Config &config) : dfa(_dfa), cfg(config) { QList lst = cfg.maxInputSet.toList(); - qSort(lst); + std::sort(lst.begin(), lst.end()); minInput = lst.first(); maxInput = lst.last(); @@ -230,7 +230,7 @@ static QVector convertToSequences(const Transitio return sequences; QList keys = transitions.keys(); - qSort(keys); + std::sort(keys.begin(), keys.end()); int i = 0; Generator::TransitionSequence sequence; sequence.first = keys.at(0); @@ -359,7 +359,7 @@ void Generator::generateTransitions(CodeBlock &body, const TransitionMap &transi } } else { QList keys = transitions.keys(); - qSort(keys); + std::sort(keys.begin(), keys.end()); body << "switch (ch.unicode()) {"; body.indent(); diff --git a/util/lexgen/nfa.cpp b/util/lexgen/nfa.cpp index 9047a17fde8..f6e3a5c355c 100644 --- a/util/lexgen/nfa.cpp +++ b/util/lexgen/nfa.cpp @@ -384,7 +384,7 @@ QSet NFA::epsilonClosure(const QSet &initialClosure) const QStack stateStack; stateStack.resize(closure.count()); - qCopy(closure.constBegin(), closure.constEnd(), stateStack.begin()); + std::copy(closure.constBegin(), closure.constEnd(), stateStack.begin()); while (!stateStack.isEmpty()) { int t = stateStack.pop(); diff --git a/util/unicode/codecs/big5/main.cpp b/util/unicode/codecs/big5/main.cpp index 142db74ffd3..54d38397556 100644 --- a/util/unicode/codecs/big5/main.cpp +++ b/util/unicode/codecs/big5/main.cpp @@ -128,7 +128,7 @@ int main(int argc, char **argv) list += QByteArray(" { 0x" + QByteArray::number(m.b5, 16) + ", 0x" + QByteArray::number(m.uc, 16) + " }\n");; } QByteArray ba; - qSort(list); + std::sort(list.begin(), list.end()); foreach(QByteArray a, list) ba += a; qDebug() << "struct B5Map b5_to_uc_map = {\n" << ba + "\n};"; @@ -138,7 +138,7 @@ int main(int argc, char **argv) if (!b5_ok.contains(m.uc)) list += QByteArray(" { 0x" + QByteArray::number(m.uc, 16) + ", 0x" + QByteArray::number(m.b5, 16) + " }\n");; ba = QByteArray(); - qSort(list); + std::sort(list.begin(), list.end());; foreach(QByteArray a, list) ba += a; qDebug() << "struct B5Map uc_to_b5_map = {\n" << ba + "\n};"; diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 8576f00e35f..ec84667ee5f 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -2832,7 +2832,7 @@ static QByteArray createLigatureInfo() QList l = ligatureHashes.value(uc); if (!l.isEmpty()) { Q_ASSERT(!QChar::requiresSurrogates(uc)); - qSort(l); // needed for bsearch in ligatureHelper code + std::sort(l.begin(), l.end()); // needed for bsearch in ligatureHelper code ligatures.append(l.size()); for (int j = 0; j < l.size(); ++j) { @@ -2864,7 +2864,7 @@ static QByteArray createLigatureInfo() QList l = ligatureHashes.value(uc); if (!l.isEmpty()) { Q_ASSERT(QChar::requiresSurrogates(uc)); - qSort(l); // needed for bsearch in ligatureHelper code + std::sort(l.begin(), l.end()); // needed for bsearch in ligatureHelper code ligatures.append(l.size()); for (int j = 0; j < l.size(); ++j) { From e85d1963b58da8b17fb740a2a9c4b4bef7ee69cd Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Tue, 28 May 2019 01:53:06 +0900 Subject: [PATCH 085/172] Fix build without feature.stringlistmodel Change-Id: Ia7a24ef1b0beea7519403000ba20dc78a3c20a21 Reviewed-by: Mikhail Svetkin --- src/sql/models/qsqltablemodel.cpp | 1 - src/widgets/util/qcompleter.cpp | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 11d30ab2e8c..4bc9a8c2f84 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -50,7 +50,6 @@ #include "qsqltablemodel_p.h" #include -#include QT_BEGIN_NAMESPACE diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 04407cdb1d9..ee0418b5b87 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -145,7 +145,9 @@ #include "QtWidgets/qscrollbar.h" #include "QtCore/qdir.h" +#if QT_CONFIG(stringlistmodel) #include "QtCore/qstringlistmodel.h" +#endif #if QT_CONFIG(dirmodel) #include "QtWidgets/qdirmodel.h" #endif From 98f7df211464c79266e643a552d17067dd2b6c56 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Fri, 14 Jun 2019 15:27:02 +0200 Subject: [PATCH 086/172] rtems: Fix build qdatetime.cpp RTEMS does not have "timezone" global variable. Change-Id: Ifa4c6f8939270a83fb7b5ba623daafa1e9f81003 Reviewed-by: Volker Hilsheimer --- src/corelib/time/qdatetime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 3c7484dca5c..b3e747c5880 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2464,7 +2464,7 @@ static int qt_timezone() // - It also takes DST into account, so we need to adjust it to always // get the Standard Time offset. return -t.tm_gmtoff + (t.tm_isdst ? (long)SECS_PER_HOUR : 0L); -#elif defined(Q_OS_INTEGRITY) +#elif defined(Q_OS_INTEGRITY) || defined(Q_OS_RTEMS) return 0; #else return timezone; From 889b44043ee92f77c6bb21abff556688354193d2 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Tue, 11 Jun 2019 15:06:26 +0200 Subject: [PATCH 087/172] rtems: Fix build 3rdparty/sha3 RTEMS does not have byteswap.h Change-Id: I37222ba4edb7338600f7c902819440feadc03a63 Reviewed-by: Ryan Chu --- src/3rdparty/sha3/brg_endian.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/sha3/brg_endian.h b/src/3rdparty/sha3/brg_endian.h index 09d2a8b6a96..9bb306e6785 100644 --- a/src/3rdparty/sha3/brg_endian.h +++ b/src/3rdparty/sha3/brg_endian.h @@ -42,7 +42,7 @@ Changes for ARM 9/9/2010 [Downstream relative to Gladman's GitHub, upstream to Q #elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ ) # if !defined( __MINGW32__ ) && !defined( _AIX ) && !defined(Q_OS_QNX) # include -# if !defined( __BEOS__ ) +# if !defined( __BEOS__ ) && !defined(Q_OS_RTEMS) # include # endif # endif From 57055ffafd9c32168e2ee94ba73655126fbaac38 Mon Sep 17 00:00:00 2001 From: Ryan Chu Date: Thu, 11 Apr 2019 16:04:06 +0200 Subject: [PATCH 088/172] Share the common configurations among different modules This change is used to generalize a template docker-compose file for all modules. Ideally, the leaf module only need to keep a docker compose file for all platforms (docker-compose.yml). NOTE: The version of docker-compose file downgrades from 3.4 to 2.1 because the 'extends' keyword is not supported in Compose version 3.x. Change-Id: I2e36fd9236eda86cb5fcf940d787ccefe9200696 Reviewed-by: Maurice Kalinowski --- mkspecs/features/data/testserver/Dockerfile | 2 + .../data/testserver/docker-compose-common.yml | 38 ++++++ mkspecs/features/unsupported/testserver.prf | 16 ++- ....yml => docker-compose-bridge-network.yml} | 68 +++++------ .../testserver/docker-compose-for-windows.yml | 113 ------------------ ...OS.yml => docker-compose-host-network.yml} | 53 ++++---- 6 files changed, 108 insertions(+), 182 deletions(-) create mode 100644 mkspecs/features/data/testserver/docker-compose-common.yml rename tests/testserver/{docker-compose.yml => docker-compose-bridge-network.yml} (75%) delete mode 100644 tests/testserver/docker-compose-for-windows.yml rename tests/testserver/{docker-compose-for-macOS.yml => docker-compose-host-network.yml} (70%) diff --git a/mkspecs/features/data/testserver/Dockerfile b/mkspecs/features/data/testserver/Dockerfile index 8fb664a1d2f..a20d289d3f8 100644 --- a/mkspecs/features/data/testserver/Dockerfile +++ b/mkspecs/features/data/testserver/Dockerfile @@ -21,7 +21,9 @@ RUN echo "#!/usr/bin/env bash\n" \ RUN chmod +x startup.sh # rewrite the default configurations of avahi-daemon +# Disable IPv6 of avahi-daemon to resolve the unstable connections on Windows ARG test_domain RUN sed -i -e "s,#domain-name=local,domain-name=${test_domain:-test-net.qt.local}," \ -e "s,#publish-aaaa-on-ipv4=yes,publish-aaaa-on-ipv4=no," \ + -e "s,use-ipv6=yes,use-ipv6=no," \ /etc/avahi/avahi-daemon.conf diff --git a/mkspecs/features/data/testserver/docker-compose-common.yml b/mkspecs/features/data/testserver/docker-compose-common.yml new file mode 100644 index 00000000000..58282c12734 --- /dev/null +++ b/mkspecs/features/data/testserver/docker-compose-common.yml @@ -0,0 +1,38 @@ +version: '2.1' + +# This is a template docker-compose file shared with all modules. It is based +# on 'extending services' feature of compose file version 2.1. +# See https://docs.docker.com/compose/extends/#extending-services for details. +# +# Example: testserver/docker-compose.yml +# services: +# foo: +# extends: +# file: ${SHARED_DATA}/docker-compose-common.yml +# service: ${SHARED_SERVICE} +# container_name: qt-test-server-foo +# hostname: ${HOST_NAME:-foo} +# build: +# context: . +# args: +# provisioningImage: qt-test-server-foo:537fe302f61851d1663... +# serviceDir: ./foo +# command: service/foo.sh + +x-services: + &default-service + domainname: ${TEST_DOMAIN} + build: + context: . + dockerfile: ${SHARED_DATA}/Dockerfile + args: + test_domain: ${TEST_DOMAIN} + entrypoint: ./startup.sh + +services: + bridge-network: *default-service + host-network: + << : *default-service + network_mode: "host" + extra_hosts: + - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" diff --git a/mkspecs/features/unsupported/testserver.prf b/mkspecs/features/unsupported/testserver.prf index 6507a360c5a..32bd4df30ca 100644 --- a/mkspecs/features/unsupported/testserver.prf +++ b/mkspecs/features/unsupported/testserver.prf @@ -94,29 +94,33 @@ isEmpty(TESTSERVER_VERSION) { # binds the same port on the host. An alternative solution is to deploy # the docker environment into VirtualBox using docker-machine. isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ - $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-macOS.yml + $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-host-network.yml # The connection configuration for the target machine MACHINE_CONFIG = $(shell docker-machine config qt-test-server) # The environment variables passed to the docker-compose file TEST_ENV = 'MACHINE_IP=$(shell docker-machine ip qt-test-server)' + TEST_ENV += 'HOST_NAME=qt-test-server' TEST_ENV += 'TEST_DOMAIN=$$DNSDOMAIN' TEST_ENV += 'SHARED_DATA=$$PWD/../data/testserver' + TEST_ENV += 'SHARED_SERVICE=host-network' TEST_CMD = env } else:equals(QMAKE_HOST.os, Windows) { # There is no docker bridge on Windows. It is impossible to ping a container. # Use docker-machine to deploy the docker environment into VirtualBox. isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ - $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-windows.yml + $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-host-network.yml # The connection configuration for the target machine MACHINE_CONFIG = (docker-machine config qt-test-server) # The environment variables passed to the docker-compose file TEST_ENV = '\$\$env:MACHINE_IP = docker-machine ip qt-test-server;' + TEST_ENV += '\$\$env:HOST_NAME = $$shell_quote(\"qt-test-server\");' TEST_ENV += '\$\$env:TEST_DOMAIN = $$shell_quote(\"$$DNSDOMAIN\");' TEST_ENV += '\$\$env:SHARED_DATA = $$shell_quote(\"$$PWD/../data/testserver\");' + TEST_ENV += '\$\$env:SHARED_SERVICE = $$shell_quote(\"host-network\");' # Docker-compose CLI environment variables: # Enable path conversion from Windows-style to Unix-style in volume definitions. @@ -126,12 +130,18 @@ isEmpty(TESTSERVER_VERSION) { CONFIG += PowerShell } else { isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ - $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml + $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-bridge-network.yml # The environment variables passed to the docker-compose file TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN' TEST_ENV += 'SHARED_DATA=$$PWD/../data/testserver' + TEST_ENV += 'SHARED_SERVICE=bridge-network' TEST_CMD = env } + + # If $$TESTSERVER_COMPOSE_FILE defined by platform doesn't exist, the default + # docker-compose.yml is used as a fallback. + !exists($$TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ + $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml !exists($$TESTSERVER_COMPOSE_FILE): error("Invalid TESTSERVER_COMPOSE_FILE specified") diff --git a/tests/testserver/docker-compose.yml b/tests/testserver/docker-compose-bridge-network.yml similarity index 75% rename from tests/testserver/docker-compose.yml rename to tests/testserver/docker-compose-bridge-network.yml index 75e8a0fea2d..2cabeee1dcf 100644 --- a/tests/testserver/docker-compose.yml +++ b/tests/testserver/docker-compose-bridge-network.yml @@ -1,35 +1,37 @@ -version: '3.4' +version: '2.1' # The tag of images is used by docker compose file to launch the corresponding # docker containers. The value of tag comes from the provisioning script # (coin/provisioning/.../testserver/docker_testserver.sh). The script gets SHA-1 # of each server context as the tag of docker images. If one of the server # contexts gets changes, please make sure to update this compose file as well. -# You can run command 'docker images' to list all the tag of test server images. +# You can run command 'docker images' to list all the tags of test server images. # For example: # REPOSITORY TAG # qt-test-server-apache2 537fe302f61851d1663f41495230d8e3554a4a13 services: apache2: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-apache2 - domainname: ${TEST_DOMAIN} - hostname: apache2 + hostname: ${HOST_NAME:-apache2} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 shareDir: ./common serviceDir: ./apache2 - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: [service/ssl.sh, service/apache2.sh] squid: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-squid - domainname: ${TEST_DOMAIN} - hostname: squid + hostname: ${HOST_NAME:-squid} depends_on: - apache2 external_links: @@ -40,53 +42,53 @@ services: - echo:echo.${TEST_DOMAIN} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c shareDir: ./common serviceDir: ./squid - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/squid.sh vsftpd: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-vsftpd - domainname: ${TEST_DOMAIN} - hostname: vsftpd + hostname: ${HOST_NAME:-vsftpd} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e shareDir: ./common serviceDir: ./vsftpd - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/vsftpd.sh ftp-proxy: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-ftp-proxy - domainname: ${TEST_DOMAIN} - hostname: ftp-proxy + hostname: ${HOST_NAME:-ftp-proxy} depends_on: - vsftpd external_links: - vsftpd:vsftpd.${TEST_DOMAIN} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae shareDir: ./common serviceDir: ./ftp-proxy - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/ftp-proxy.sh danted: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-danted - domainname: ${TEST_DOMAIN} - hostname: danted + hostname: ${HOST_NAME:-danted} depends_on: - apache2 - vsftpd @@ -99,42 +101,40 @@ services: - echo:echo.${TEST_DOMAIN} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 shareDir: ./common serviceDir: ./danted - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/danted.sh cyrus: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-cyrus - domainname: ${TEST_DOMAIN} - hostname: cyrus + hostname: ${HOST_NAME:-cyrus} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-cyrus:c8d72754abc0e501afd624ce838e4df35505abc9 shareDir: ./common serviceDir: ./cyrus - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: [service/ssl.sh, service/cyrus.sh] iptables: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-iptables - domainname: ${TEST_DOMAIN} - hostname: iptables + hostname: ${HOST_NAME:-iptables} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-iptables:cb7a8bd6d28602085a88c8ced7d67e28e75781e2 shareDir: ./common serviceDir: ./iptables - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/iptables.sh cap_add: @@ -142,16 +142,16 @@ services: - NET_RAW echo: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-echo - domainname: ${TEST_DOMAIN} - hostname: echo + hostname: ${HOST_NAME:-echo} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-echo:b29ad409e746a834c1055fd0f7a55fd5056da6ea shareDir: ./common serviceDir: ./echo - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/echo.sh diff --git a/tests/testserver/docker-compose-for-windows.yml b/tests/testserver/docker-compose-for-windows.yml deleted file mode 100644 index c5348e27b6f..00000000000 --- a/tests/testserver/docker-compose-for-windows.yml +++ /dev/null @@ -1,113 +0,0 @@ -version: '3.4' - -# The tag of images is used by docker compose file to launch the corresponding -# docker containers. The value of tag comes from the provisioning script -# (coin/provisioning/.../testserver/docker_testserver.sh). The script gets SHA-1 -# of each server context as the tag of docker images. If one of the server -# contexts gets changes, please make sure to update this compose file as well. -# You can run command 'docker images' to list all the tags of test server images. -# For example: -# REPOSITORY TAG -# qt-test-server-apache2 537fe302f61851d1663f41495230d8e3554a4a13 - -services: - apache2: - container_name: qt-test-server-apache2 - domainname: ${TEST_DOMAIN} - build: - context: . - dockerfile: ${SHARED_DATA}/Dockerfile - args: - provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 - shareDir: ./common - serviceDir: ./apache2 - test_domain: ${TEST_DOMAIN} - entrypoint: service/startup.sh - command: [service/ssl.sh, service/apache2.sh] - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - environment: - - test_cert="qt-test-server-host-network-cacert.pem" - - squid: - container_name: qt-test-server-squid - domainname: ${TEST_DOMAIN} - depends_on: - - apache2 - build: - context: . - dockerfile: ${SHARED_DATA}/Dockerfile - args: - provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c - shareDir: ./common - serviceDir: ./squid - test_domain: ${TEST_DOMAIN} - entrypoint: service/startup.sh - command: service/squid.sh - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - - vsftpd: - container_name: qt-test-server-vsftpd - domainname: ${TEST_DOMAIN} - build: - context: . - dockerfile: ${SHARED_DATA}/Dockerfile - args: - provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e - shareDir: ./common - serviceDir: ./vsftpd - test_domain: ${TEST_DOMAIN} - entrypoint: service/startup.sh - command: service/vsftpd.sh - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - - ftp-proxy: - container_name: qt-test-server-ftp-proxy - domainname: ${TEST_DOMAIN} - depends_on: - - vsftpd - build: - context: . - dockerfile: ${SHARED_DATA}/Dockerfile - args: - provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae - shareDir: ./common - serviceDir: ./ftp-proxy - test_domain: ${TEST_DOMAIN} - entrypoint: service/startup.sh - command: service/ftp-proxy.sh - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - - danted: - container_name: qt-test-server-danted - domainname: ${TEST_DOMAIN} - depends_on: - - apache2 - - vsftpd - - ftp-proxy - build: - context: . - dockerfile: ${SHARED_DATA}/Dockerfile - args: - provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 - shareDir: ./common - serviceDir: ./danted - test_domain: ${TEST_DOMAIN} - entrypoint: service/startup.sh - command: service/danted.sh - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" - environment: - - danted_internal=${MACHINE_IP} - - danted_external=${MACHINE_IP} - - danted_auth_internal=${MACHINE_IP} - - danted_auth_external=${MACHINE_IP} - diff --git a/tests/testserver/docker-compose-for-macOS.yml b/tests/testserver/docker-compose-host-network.yml similarity index 70% rename from tests/testserver/docker-compose-for-macOS.yml rename to tests/testserver/docker-compose-host-network.yml index c5348e27b6f..4b2e1ebdabd 100644 --- a/tests/testserver/docker-compose-for-macOS.yml +++ b/tests/testserver/docker-compose-host-network.yml @@ -1,4 +1,4 @@ -version: '3.4' +version: '2.1' # The tag of images is used by docker compose file to launch the corresponding # docker containers. The value of tag comes from the provisioning script @@ -12,102 +12,91 @@ version: '3.4' services: apache2: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-apache2 - domainname: ${TEST_DOMAIN} + hostname: ${HOST_NAME:-apache2} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13 shareDir: ./common serviceDir: ./apache2 - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: [service/ssl.sh, service/apache2.sh] - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" environment: - test_cert="qt-test-server-host-network-cacert.pem" squid: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-squid - domainname: ${TEST_DOMAIN} + hostname: ${HOST_NAME:-squid} depends_on: - apache2 build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c shareDir: ./common serviceDir: ./squid - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/squid.sh - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" vsftpd: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-vsftpd - domainname: ${TEST_DOMAIN} + hostname: ${HOST_NAME:-vsftpd} build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e shareDir: ./common serviceDir: ./vsftpd - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/vsftpd.sh - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" ftp-proxy: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-ftp-proxy - domainname: ${TEST_DOMAIN} + hostname: ${HOST_NAME:-ftp-proxy} depends_on: - vsftpd build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae shareDir: ./common serviceDir: ./ftp-proxy - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/ftp-proxy.sh - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" danted: + extends: + file: ${SHARED_DATA}/docker-compose-common.yml + service: ${SHARED_SERVICE} container_name: qt-test-server-danted - domainname: ${TEST_DOMAIN} + hostname: ${HOST_NAME:-danted} depends_on: - apache2 - vsftpd - ftp-proxy build: context: . - dockerfile: ${SHARED_DATA}/Dockerfile args: provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5 shareDir: ./common serviceDir: ./danted - test_domain: ${TEST_DOMAIN} entrypoint: service/startup.sh command: service/danted.sh - network_mode: "host" - extra_hosts: - - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}" environment: - danted_internal=${MACHINE_IP} - danted_external=${MACHINE_IP} - danted_auth_internal=${MACHINE_IP} - danted_auth_external=${MACHINE_IP} - From 2a99f60cfbe8a10c8b64b2178573dc8da3d27abe Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Sun, 23 Jun 2019 23:24:32 +0100 Subject: [PATCH 089/172] QStringList: add QStringView overloads of join, filter, replaceInStrings [ChangeLog][QtCore][QStringList] Added QStringView overloads of join(), filter(), and replaceInStrings(). Change-Id: I9636e21e2e43ed46cce0aa7fa23ab0710aa641ba Reviewed-by: Marc Mutz --- src/corelib/tools/qstringlist.cpp | 64 +++++++++++++++++++ src/corelib/tools/qstringlist.h | 52 +++++++++++++++ .../tools/qstringlist/tst_qstringlist.cpp | 17 +++++ 3 files changed, 133 insertions(+) diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index f6da7b14285..3bb0e3c886c 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -283,6 +283,7 @@ void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs) } +#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QStringList QStringList::filter(const QString &str, Qt::CaseSensitivity cs) const @@ -302,6 +303,26 @@ void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs) \sa contains() */ +#endif + +/*! + \fn QStringList QStringList::filter(QStringView str, Qt::CaseSensitivity cs) const + \overload + \since 5.14 +*/ +QStringList QtPrivate::QStringList_filter(const QStringList *that, QStringView str, + Qt::CaseSensitivity cs) +{ + QStringMatcher matcher(str.data(), str.length(), cs); + QStringList res; + for (int i = 0; i < that->size(); ++i) + if (matcher.indexIn(that->at(i)) != -1) + res << that->at(i); + return res; +} + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/// Not really needed anymore, but kept for binary compatibility QStringList QtPrivate::QStringList_filter(const QStringList *that, const QString &str, Qt::CaseSensitivity cs) { @@ -312,6 +333,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QString res << that->at(i); return res; } +#endif template static bool stringList_contains(const QStringList &stringList, const T &str, Qt::CaseSensitivity cs) @@ -466,6 +488,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula } #endif // QT_CONFIG(regularexpression) +#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QStringList &QStringList::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs) @@ -481,12 +504,41 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula \sa QString::replace() */ + +/*! + \fn QStringList &QStringList::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs) + \overload + \since 5.14 +*/ + +/*! + \fn QStringList &QStringList::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs) + \overload + \since 5.14 +*/ +#endif + +/*! + \fn QStringList &QStringList::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs) + \overload + \since 5.14 +*/ +void QtPrivate::QStringList_replaceInStrings(QStringList *that, QStringView before, + QStringView after, Qt::CaseSensitivity cs) +{ + for (int i = 0; i < that->size(); ++i) + (*that)[i].replace(before.data(), before.length(), after.data(), after.length(), cs); +} + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/// Not really needed anymore, but kept for binary compatibility void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &before, const QString &after, Qt::CaseSensitivity cs) { for (int i = 0; i < that->size(); ++i) (*that)[i].replace(before, after, cs); } +#endif #ifndef QT_NO_REGEXP @@ -561,6 +613,7 @@ static int accumulatedSize(const QStringList &list, int seplen) return result; } +#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QString QStringList::join(const QString &separator) const @@ -570,6 +623,7 @@ static int accumulatedSize(const QStringList &list, int seplen) \sa QString::split() */ +#endif /*! \fn QString QStringList::join(QChar separator) const @@ -614,6 +668,16 @@ QString QtPrivate::QStringList_join(const QStringList &list, QLatin1String sep) return result; } +/*! + \fn QString QStringList::join(QStringView separator) const + \overload + \since 5.14 +*/ +QString QtPrivate::QStringList_join(const QStringList *that, QStringView sep) +{ + return QStringList_join(that, sep.data(), sep.length()); +} + /*! \fn QStringList QStringList::operator+(const QStringList &other) const diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index 3bb657069b0..45f51bfcc6d 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -73,12 +73,21 @@ public: inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive); inline int removeDuplicates(); +#if QT_STRINGVIEW_LEVEL < 2 inline QString join(const QString &sep) const; +#endif + inline QString join(QStringView sep) const; inline QString join(QLatin1String sep) const; inline QString join(QChar sep) const; + inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive); +#if QT_STRINGVIEW_LEVEL < 2 inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); + inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive); + inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); +#endif #ifndef QT_NO_REGEXP inline QStringList filter(const QRegExp &rx) const; @@ -163,18 +172,27 @@ inline const QStringList *QListSpecialMethods::self() const namespace QtPrivate { void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs); int Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that); + QString Q_CORE_EXPORT QStringList_join(const QStringList *that, QStringView sep); QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, int seplen); Q_CORE_EXPORT QString QStringList_join(const QStringList &list, QLatin1String sep); + QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, QStringView str, + Qt::CaseSensitivity cs); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QString &str, Qt::CaseSensitivity cs); +#endif #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, const QString &str, Qt::CaseSensitivity cs); #endif bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QStringView str, Qt::CaseSensitivity cs); bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QLatin1String str, Qt::CaseSensitivity cs); + void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, QStringView before, QStringView after, + Qt::CaseSensitivity cs); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QString &before, const QString &after, Qt::CaseSensitivity cs); +#endif #ifndef QT_NO_REGEXP void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegExp &rx, const QString &after); @@ -203,10 +221,17 @@ inline int QListSpecialMethods::removeDuplicates() return QtPrivate::QStringList_removeDuplicates(self()); } +#if QT_STRINGVIEW_LEVEL < 2 inline QString QListSpecialMethods::join(const QString &sep) const { return QtPrivate::QStringList_join(self(), sep.constData(), sep.length()); } +#endif + +inline QString QListSpecialMethods::join(QStringView sep) const +{ + return QtPrivate::QStringList_join(self(), sep); +} QString QListSpecialMethods::join(QLatin1String sep) const { @@ -218,10 +243,17 @@ inline QString QListSpecialMethods::join(QChar sep) const return QtPrivate::QStringList_join(self(), &sep, 1); } +inline QStringList QListSpecialMethods::filter(QStringView str, Qt::CaseSensitivity cs) const +{ + return QtPrivate::QStringList_filter(self(), str, cs); +} + +#if QT_STRINGVIEW_LEVEL < 2 inline QStringList QListSpecialMethods::filter(const QString &str, Qt::CaseSensitivity cs) const { return QtPrivate::QStringList_filter(self(), str, cs); } +#endif #if QT_STRINGVIEW_LEVEL < 2 inline bool QStringList::contains(const QString &str, Qt::CaseSensitivity cs) const @@ -240,12 +272,32 @@ inline bool QStringList::contains(QStringView str, Qt::CaseSensitivity cs) const return QtPrivate::QStringList_contains(this, str, cs); } +inline QStringList &QListSpecialMethods::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs) +{ + QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); + return *self(); +} + +#if QT_STRINGVIEW_LEVEL < 2 inline QStringList &QListSpecialMethods::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs) { QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); return *self(); } +inline QStringList &QListSpecialMethods::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs) +{ + QtPrivate::QStringList_replaceInStrings(self(), before, qToStringViewIgnoringNull(after), cs); + return *self(); +} + +inline QStringList &QListSpecialMethods::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs) +{ + QtPrivate::QStringList_replaceInStrings(self(), QStringView(before), after, cs); + return *self(); +} +#endif + inline QStringList operator+(const QList &one, const QStringList &other) { QStringList n = one; diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index 2b5aa8e98b0..66d47444545 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -259,6 +259,12 @@ void tst_QStringList::filter() list5 = list5.filter( QRegularExpression("[i]ll") ); list6 << "Bill Gates" << "Bill Clinton"; QCOMPARE( list5, list6 ); + + QStringList list7, list8; + list7 << "Bill Gates" << "Joe Blow" << "Bill Clinton"; + list7 = list7.filter( QStringView(QString("Bill")) ); + list8 << "Bill Gates" << "Bill Clinton"; + QCOMPARE( list7, list8 ); } void tst_QStringList::sort() @@ -316,6 +322,16 @@ void tst_QStringList::replaceInStrings() list10 << "Bill Clinton" << "Bill Gates"; list9.replaceInStrings( QRegularExpression("^(.*), (.*)$"), "\\2 \\1" ); QCOMPARE( list9, list10 ); + + QStringList list11, list12, list13, list14; + list11 << "alpha" << "beta" << "gamma" << "epsilon"; + list12 << "alpha" << "beta" << "gamma" << "epsilon"; + list13 << "alpha" << "beta" << "gamma" << "epsilon"; + list11.replaceInStrings( QStringView(QString("a")), QStringView(QString("o")) ); + list12.replaceInStrings( QStringView(QString("a")), QString("o") ); + list13.replaceInStrings( QString("a"), QStringView(QString("o")) ); + list14 << "olpho" << "beto" << "gommo" << "epsilon"; + QCOMPARE( list11, list12 ); } void tst_QStringList::contains() @@ -427,6 +443,7 @@ void tst_QStringList::join() const QCOMPARE(input.join(separator), expectedResult); QCOMPARE(input.join(QLatin1String(separator.toLatin1())), expectedResult); + QCOMPARE(input.join(QStringView(separator)), expectedResult); } void tst_QStringList::join_data() const From 248e81a28028b1b0570ffe0ed2e0edbf63a0a21c Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Thu, 6 Jun 2019 10:42:22 +0200 Subject: [PATCH 090/172] rtems: Add environment variable for configure default thread stack size The default stack size is too small on RTEMS. Qt uses threads internally and there is no way to change their stack size. Change-Id: I94a42c7a70c745f0b50d7051d9320edfabd1e09e Reviewed-by: Volker Hilsheimer --- src/corelib/thread/qthread.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index fe555afca7b..280c785049b 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -171,6 +171,11 @@ QThreadPrivate::QThreadPrivate(QThreadData *d) // to 128K. #ifdef Q_OS_INTEGRITY stackSize = 128 * 1024; +#elif defined(Q_OS_RTEMS) + static bool envStackSizeOk = false; + static const int envStackSize = qEnvironmentVariableIntValue("QT_DEFAULT_THREAD_STACK_SIZE", &envStackSizeOk); + if (envStackSizeOk) + stackSize = envStackSize; #endif #if defined (Q_OS_WIN) From 222b81f5dac2a5d32027b15d3a784819291431f6 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Tue, 20 Mar 2018 14:32:54 +0100 Subject: [PATCH 091/172] rtems: Fix missing some ernno defines By default RTEMS does not support linux extensions for errno. Enable it for build. Change-Id: I43b346794b99ac0ed339bfbe6e39684071615503 Reviewed-by: Volker Hilsheimer Reviewed-by: Thiago Macieira Reviewed-by: Ryan Chu --- mkspecs/common/rtems/qplatformdefs.h | 4 +++- src/corelib/kernel/qcore_unix_p.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mkspecs/common/rtems/qplatformdefs.h b/mkspecs/common/rtems/qplatformdefs.h index 1baa7c7d74f..b4ec1de87fa 100644 --- a/mkspecs/common/rtems/qplatformdefs.h +++ b/mkspecs/common/rtems/qplatformdefs.h @@ -57,8 +57,10 @@ #include #include -#include "../posix/qplatformdefs.h" +#define __LINUX_ERRNO_EXTENSIONS__ +#include +#include "../posix/qplatformdefs.h" #ifdef __STRICT_ANSI__ #undef __STRICT_ANSI__ diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index b56c2b97323..6ec7d283180 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -52,8 +52,8 @@ // We mean it. // -#include #include "qplatformdefs.h" +#include #include "qatomic.h" #include "qbytearray.h" From 56fb2266f2d224ba58d262640f318a0439a9fa32 Mon Sep 17 00:00:00 2001 From: Yulong Bai Date: Mon, 24 Jun 2019 15:22:01 +0200 Subject: [PATCH 092/172] QTypeModuleInfo: fix clang '-wconstant-logical-operand' warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia73e4ffbabd5db67063584a7e53966da53133689 Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qmetatype_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index 97d60019373..fa7208369a3 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -74,7 +74,7 @@ template class QTypeModuleInfo { public: - enum Module { + enum Module : bool { IsCore = false, IsWidget = false, IsGui = false, From cafcab52638ed1f6f70db32345fff838eac67cae Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 1 Jul 2019 16:01:19 +0200 Subject: [PATCH 093/172] Bump version Change-Id: Ic4a8c031d1de3dd887fb6f135035ccb2ec9a37b3 --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 888bd8f66e0..4db9fecac82 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ CONFIG += warning_clean QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.12.4 +MODULE_VERSION = 5.12.5 From 1df2cdda6c9559cd20af245b41731e287f6214c7 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 1 Jul 2019 16:34:58 +0200 Subject: [PATCH 094/172] Bump version Change-Id: Ieb9a694d44503789664a6098c4fb14eb940337fe --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index c92e38c48fb..a4cd16555dc 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ CONFIG += warning_clean QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.13.0 +MODULE_VERSION = 5.13.1 From 854ddb0301ae677a31286da4476318f4e6b74e3f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 24 Jun 2019 10:22:50 +0200 Subject: [PATCH 095/172] rhi: Enhance line width and point size support ...but this will vary between backends, or in some cases even between implementations of the same API. Point size is settable only via the vertex shader (gl_PointSize). It is silently ignored with D3D and HLSL. Line widths other than 1 are supported only on OpenGL and Vulkan. (but this is in fact deprecated with GL and optional with Vulkan) Add QRhi::Feature values for both. The line width is now settable on QRhiGraphicsPipeline. It is not a dynamic state since the static, per-pipeline width is good enough for most cases. (and the feature is not supported on half of the backends anyways so it will get limited use in practice). Change-Id: I6d3a32269527c452b794b2cb8b0f03101eab40b2 Reviewed-by: Lars Knoll --- src/gui/rhi/qrhi.cpp | 18 +++++++++++++++++- src/gui/rhi/qrhi_p.h | 8 +++++++- src/gui/rhi/qrhid3d11.cpp | 4 ++++ src/gui/rhi/qrhigles2.cpp | 7 +++++++ src/gui/rhi/qrhimetal.mm | 4 ++++ src/gui/rhi/qrhivulkan.cpp | 18 +++++++++++------- src/gui/rhi/qrhivulkan_p_p.h | 2 ++ .../manual/rhi/computebuffer/computebuffer.cpp | 3 +++ tests/manual/rhi/triquadcube/triquadcube.cpp | 2 ++ 9 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 334fa1064a6..681a6ddfb81 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -494,7 +494,23 @@ QT_BEGIN_NAMESPACE extension. When false, only 16-bit unsigned elements are supported in the index buffer. - \value Compute Indicates that compute shaders are supported. + \value Compute Indicates that compute shaders, image load/store, and + storage buffers are supported. + + \value WideLines Indicates that lines with a width other than 1 are + supported. When reported as not supported, the line width set on the + graphics pipeline state is ignored. This can always be false with some + backends (D3D11, Metal). With Vulkan, the value depends on the + implementation. + + \value VertexShaderPointSize Indicates that the size of rasterized points + set via \c{gl_PointSize} in the vertex shader is taken into account. When + reported as not supported, drawing points with a size other than 1 is not + supported. Setting \c{gl_PointSize} in the shader is still valid then, but + is ignored. (for example, when generating HLSL, the assignment is silently + dropped from the generated code) Note that some APIs (Metal, Vulkan) + require the point size to be set in the shader explicitly whenever drawing + points, even when the size is 1, as they do not automatically default to 1. */ /*! diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 0d296d370c1..fb8727b2653 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -1068,6 +1068,9 @@ public: int sampleCount() const { return m_sampleCount; } void setSampleCount(int s) { m_sampleCount = s; } + float lineWidth() const { return m_lineWidth; } + void setLineWidth(float width) { m_lineWidth = width; } + QVector shaderStages() const { return m_shaderStages; } void setShaderStages(const QVector &stages) { m_shaderStages = stages; } @@ -1098,6 +1101,7 @@ protected: quint32 m_stencilReadMask = 0xFF; quint32 m_stencilWriteMask = 0xFF; int m_sampleCount = 1; + float m_lineWidth = 1.0f; QVector m_shaderStages; QRhiVertexInputLayout m_vertexInputLayout; QRhiShaderResourceBindings *m_shaderResourceBindings = nullptr; @@ -1312,7 +1316,9 @@ public: NPOTTextureRepeat, RedOrAlpha8IsRed, ElementIndexUint, - Compute + Compute, + WideLines, + VertexShaderPointSize }; enum BeginFrameFlag { diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 6b05d68fb53..dc69f50cc8c 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -378,6 +378,10 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const return true; case QRhi::Compute: return true; + case QRhi::WideLines: + return false; + case QRhi::VertexShaderPointSize: + return false; default: Q_UNREACHABLE(); return false; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 7c40a36701c..51862cad861 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -618,6 +618,10 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const return caps.elementIndexUint; case QRhi::Compute: return false; + case QRhi::WideLines: + return true; + case QRhi::VertexShaderPointSize: + return true; default: Q_UNREACHABLE(); return false; @@ -1849,6 +1853,9 @@ void QRhiGles2::executeBindGraphicsPipeline(QRhiGraphicsPipeline *ps) f->glDisable(GL_STENCIL_TEST); } + if (psD->topology() == QRhiGraphicsPipeline::Lines || psD->topology() == QRhiGraphicsPipeline::LineStrip) + f->glLineWidth(psD->m_lineWidth); + f->glUseProgram(psD->program); } diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 214374e0c63..09b80c831da 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -523,6 +523,10 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const return true; case QRhi::Compute: return true; + case QRhi::WideLines: + return false; + case QRhi::VertexShaderPointSize: + return true; default: Q_UNREACHABLE(); return false; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index f6ecd7c00e5..8598e5869ad 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -489,6 +489,9 @@ bool QRhiVulkan::create(QRhi::Flags flags) // elsewhere states that the minimum bufferOffset is 4... texbufAlign = qMax(4, physDevProperties.limits.optimalBufferCopyOffsetAlignment); + f->vkGetPhysicalDeviceFeatures(physDev, &physDevFeatures); + hasWideLines = physDevFeatures.wideLines; + if (!importedAllocator) { VmaVulkanFunctions afuncs; afuncs.vkGetPhysicalDeviceProperties = wrap_vkGetPhysicalDeviceProperties; @@ -3489,24 +3492,21 @@ QMatrix4x4 QRhiVulkan::clipSpaceCorrMatrix() const bool QRhiVulkan::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const { - VkPhysicalDeviceFeatures features; - f->vkGetPhysicalDeviceFeatures(physDev, &features); - // Note that with some SDKs the validation layer gives an odd warning about // BC not being supported, even when our check here succeeds. Not much we // can do about that. if (format >= QRhiTexture::BC1 && format <= QRhiTexture::BC7) { - if (!features.textureCompressionBC) + if (!physDevFeatures.textureCompressionBC) return false; } if (format >= QRhiTexture::ETC2_RGB8 && format <= QRhiTexture::ETC2_RGBA8) { - if (!features.textureCompressionETC2) + if (!physDevFeatures.textureCompressionETC2) return false; } if (format >= QRhiTexture::ASTC_4x4 && format <= QRhiTexture::ASTC_12x12) { - if (!features.textureCompressionASTC_LDR) + if (!physDevFeatures.textureCompressionASTC_LDR) return false; } @@ -3545,6 +3545,10 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const return true; case QRhi::Compute: return hasCompute; + case QRhi::WideLines: + return hasWideLines; + case QRhi::VertexShaderPointSize: + return true; default: Q_UNREACHABLE(); return false; @@ -5612,7 +5616,7 @@ bool QVkGraphicsPipeline::build() rastInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rastInfo.cullMode = toVkCullMode(m_cullMode); rastInfo.frontFace = toVkFrontFace(m_frontFace); - rastInfo.lineWidth = 1.0f; + rastInfo.lineWidth = rhiD->hasWideLines ? m_lineWidth : 1.0f; pipelineInfo.pRasterizationState = &rastInfo; VkPipelineMultisampleStateCreateInfo msInfo; diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index cec90166031..31e0eaa585e 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -783,9 +783,11 @@ public: QVkAllocator allocator = nullptr; QVulkanFunctions *f = nullptr; QVulkanDeviceFunctions *df = nullptr; + VkPhysicalDeviceFeatures physDevFeatures; VkPhysicalDeviceProperties physDevProperties; VkDeviceSize ubufAlign; VkDeviceSize texbufAlign; + bool hasWideLines = false; bool debugMarkersAvailable = false; bool vertexAttribDivisorAvailable = false; diff --git a/tests/manual/rhi/computebuffer/computebuffer.cpp b/tests/manual/rhi/computebuffer/computebuffer.cpp index d6c576cf3b8..2a3e0b92b5a 100644 --- a/tests/manual/rhi/computebuffer/computebuffer.cpp +++ b/tests/manual/rhi/computebuffer/computebuffer.cpp @@ -91,6 +91,9 @@ void Window::customInit() if (!m_r->isFeatureSupported(QRhi::Compute)) qFatal("Compute is not supported"); + if (!m_r->isFeatureSupported(QRhi::VertexShaderPointSize)) + qWarning("Point sizes other than 1 not supported"); + // compute pass d.sbuf = m_r->newBuffer(QRhiBuffer::Immutable, diff --git a/tests/manual/rhi/triquadcube/triquadcube.cpp b/tests/manual/rhi/triquadcube/triquadcube.cpp index 8c7f5db042f..1b390c34ed9 100644 --- a/tests/manual/rhi/triquadcube/triquadcube.cpp +++ b/tests/manual/rhi/triquadcube/triquadcube.cpp @@ -172,6 +172,8 @@ void Window::customInit() qDebug("isFeatureSupported(RedOrAlpha8IsRed): %d", m_r->isFeatureSupported(QRhi::RedOrAlpha8IsRed)); qDebug("isFeatureSupported(ElementIndexUint): %d", m_r->isFeatureSupported(QRhi::ElementIndexUint)); qDebug("isFeatureSupported(Compute): %d", m_r->isFeatureSupported(QRhi::Compute)); + qDebug("isFeatureSupported(WideLines): %d", m_r->isFeatureSupported(QRhi::WideLines)); + qDebug("isFeatureSupported(VertexShaderPointSize): %d", m_r->isFeatureSupported(QRhi::VertexShaderPointSize)); qDebug("Min 2D texture width/height: %d", m_r->resourceLimit(QRhi::TextureSizeMin)); qDebug("Max 2D texture width/height: %d", m_r->resourceLimit(QRhi::TextureSizeMax)); qDebug("Max color attachment count: %d", m_r->resourceLimit(QRhi::MaxColorAttachments)); From 13a7777bbf99ef18cf17727d69ec1f63763c85cc Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 27 Jun 2019 10:34:33 +0200 Subject: [PATCH 096/172] rhi: gl: Make fb attachment logic ES 2.0 and WebGL compatible So that we can now operate on plain ES 2.0 implementations like the Broadcom stack on the Raspberry Pi (which does not even have packed depth stencil). Also add the WebGL-specific combined attach logic to enable WebAssembly. This has not been tested in practice. Change-Id: I21219319062f295c1e88e3057c0c2ede724ac664 Reviewed-by: Lars Knoll --- src/gui/rhi/qrhigles2.cpp | 80 ++++++++++++++++++++++++++++--------- src/gui/rhi/qrhigles2_p_p.h | 7 +++- 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 51862cad861..fff3ff737cd 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -175,14 +175,34 @@ QT_BEGIN_NAMESPACE #define GL_DEPTH_COMPONENT16 0x81A5 #endif +#ifndef GL_DEPTH_COMPONENT24 +#define GL_DEPTH_COMPONENT24 0x81A6 +#endif + #ifndef GL_DEPTH_COMPONENT32F #define GL_DEPTH_COMPONENT32F 0x8CAC #endif +#ifndef GL_STENCIL_INDEX +#define GL_STENCIL_INDEX 0x1901 +#endif + +#ifndef GL_STENCIL_INDEX8 +#define GL_STENCIL_INDEX8 0x8D48 +#endif + #ifndef GL_DEPTH24_STENCIL8 #define GL_DEPTH24_STENCIL8 0x88F0 #endif +#ifndef GL_DEPTH_STENCIL_ATTACHMENT +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#endif + +#ifndef GL_DEPTH_STENCIL +#define GL_DEPTH_STENCIL 0x84F9 +#endif + #ifndef GL_PRIMITIVE_RESTART_FIXED_INDEX #define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 #endif @@ -394,10 +414,17 @@ bool QRhiGles2::create(QRhi::Flags flags) caps.floatFormats = caps.ctxMajor >= 3; caps.depthTexture = caps.ctxMajor >= 3; caps.packedDepthStencil = f->hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil); +#ifdef Q_OS_WASM + caps.needsDepthStencilCombinedAttach = true; +#else + caps.needsDepthStencilCombinedAttach = false; +#endif caps.srgbCapableDefaultFramebuffer = f->hasOpenGLExtension(QOpenGLExtensions::SRGBFrameBuffer); caps.coreProfile = actualFormat.profile() == QSurfaceFormat::CoreProfile; caps.uniformBuffers = caps.ctxMajor >= 3 && (caps.gles || caps.ctxMinor >= 1); caps.elementIndexUint = f->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint); + caps.depth24 = f->hasOpenGLExtension(QOpenGLExtensions::Depth24); + caps.rgba8Format = f->hasOpenGLExtension(QOpenGLExtensions::Sized8Formats); nativeHandlesStruct.context = ctx; @@ -2261,21 +2288,30 @@ bool QGles2RenderBuffer::build() switch (m_type) { case QRhiRenderBuffer::DepthStencil: if (rhiD->caps.msaaRenderBuffer && samples > 1) { - rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, + const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8; + rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, storage, m_pixelSize.width(), m_pixelSize.height()); + stencilRenderbuffer = 0; + } else if (rhiD->caps.packedDepthStencil || rhiD->caps.needsDepthStencilCombinedAttach) { + const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8; + rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, storage, + m_pixelSize.width(), m_pixelSize.height()); + stencilRenderbuffer = 0; } else { - if (rhiD->caps.packedDepthStencil) { - rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, - m_pixelSize.width(), m_pixelSize.height()); - stencilRenderbuffer = 0; - } else { - rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_ATTACHMENT, - m_pixelSize.width(), m_pixelSize.height()); - rhiD->f->glGenRenderbuffers(1, &stencilRenderbuffer); - rhiD->f->glBindRenderbuffer(GL_RENDERBUFFER, stencilRenderbuffer); - rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_ATTACHMENT, - m_pixelSize.width(), m_pixelSize.height()); + GLenum depthStorage = GL_DEPTH_COMPONENT; + if (rhiD->caps.gles) { + if (rhiD->caps.depth24) + depthStorage = GL_DEPTH_COMPONENT24; + else + depthStorage = GL_DEPTH_COMPONENT16; // plain ES 2.0 only has this } + const GLenum stencilStorage = rhiD->caps.gles ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX; + rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, depthStorage, + m_pixelSize.width(), m_pixelSize.height()); + rhiD->f->glGenRenderbuffers(1, &stencilRenderbuffer); + rhiD->f->glBindRenderbuffer(GL_RENDERBUFFER, stencilRenderbuffer); + rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, stencilStorage, + m_pixelSize.width(), m_pixelSize.height()); } QRHI_PROF_F(newRenderBuffer(this, false, false, samples)); break; @@ -2284,7 +2320,7 @@ bool QGles2RenderBuffer::build() rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_RGBA8, m_pixelSize.width(), m_pixelSize.height()); else - rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, + rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, rhiD->caps.rgba8Format ? GL_RGBA8 : GL_RGBA4, m_pixelSize.width(), m_pixelSize.height()); QRHI_PROF_F(newRenderBuffer(this, false, false, samples)); break; @@ -2667,11 +2703,19 @@ bool QGles2TextureRenderTarget::build() if (hasDepthStencil) { if (m_desc.depthStencilBuffer()) { QGles2RenderBuffer *depthRbD = QRHI_RES(QGles2RenderBuffer, m_desc.depthStencilBuffer()); - rhiD->f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRbD->renderbuffer); - if (depthRbD->stencilRenderbuffer) - rhiD->f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthRbD->stencilRenderbuffer); - else // packed - rhiD->f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthRbD->renderbuffer); + if (rhiD->caps.needsDepthStencilCombinedAttach) { + rhiD->f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, + depthRbD->renderbuffer); + } else { + rhiD->f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, + depthRbD->renderbuffer); + if (depthRbD->stencilRenderbuffer) + rhiD->f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, + depthRbD->stencilRenderbuffer); + else // packed + rhiD->f->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, + depthRbD->renderbuffer); + } if (d.colorAttCount == 0) { d.pixelSize = depthRbD->pixelSize(); d.sampleCount = depthRbD->samples; diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index fe74e2e75b4..e02c8831907 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -638,10 +638,12 @@ public: floatFormats(false), depthTexture(false), packedDepthStencil(false), + needsDepthStencilCombinedAttach(false), srgbCapableDefaultFramebuffer(false), coreProfile(false), uniformBuffers(false), - elementIndexUint(false) + elementIndexUint(false), + depth24(false) { } int ctxMajor; int ctxMinor; @@ -662,10 +664,13 @@ public: uint floatFormats : 1; uint depthTexture : 1; uint packedDepthStencil : 1; + uint needsDepthStencilCombinedAttach : 1; uint srgbCapableDefaultFramebuffer : 1; uint coreProfile : 1; uint uniformBuffers : 1; uint elementIndexUint : 1; + uint depth24 : 1; + uint rgba8Format : 1; } caps; QGles2SwapChain *currentSwapChain = nullptr; QVector supportedCompressedFormats; From 03ebad7bfdd0d359a9d46540f7e4035bd72fc9db Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 27 Jun 2019 15:23:20 +0200 Subject: [PATCH 097/172] rhi: gl: Adjust texture and renderbuffer sizes automatically Enforce the maximum texture size limit both for textures and renderbuffers, showing warnings and adjusting the size automatically. On the low end ES 2.0 devices we can easily hit a maximum size of 2048x2048. For example a Raspberry Pi running in full HD with the Controls 2 Material style breaks right away as it tries to create slightly wider than 2048 texture for its ShaderEffect. Instead of breaking with an obscure framebuffer incomplete warning at best, show something more informative and adjust the sizes so that something shows up on the screen still. (naturally applications not taking the maximum sizes returned from QRhi into account are technically incorrect and may well end up with incorrect rendering, but we should still try handling this as gracefully as possible) Change-Id: Ib75eb893ab4774e1a3c49ed2d14c6bf9be8c807a Reviewed-by: Lars Knoll --- src/gui/rhi/qrhigles2.cpp | 64 ++++++++++++++++++++++++++----------- src/gui/rhi/qrhigles2_p_p.h | 1 + 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index fff3ff737cd..34052c5a9c6 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -497,6 +497,43 @@ int QRhiGles2::effectiveSampleCount(int sampleCount) const return s; } +static inline bool isPowerOfTwo(int x) +{ + // Assumption: x >= 1 + return x == (x & -x); +} + +QSize QRhiGles2::safeTextureSize(const QSize &pixelSize) const +{ + QSize size = pixelSize.isEmpty() ? QSize(1, 1) : pixelSize; + + if (!caps.npotTexture) { + if (!isPowerOfTwo(size.width())) { + qWarning("Texture width %d is not a power of two, adjusting", + size.width()); + size.setWidth(qNextPowerOfTwo(size.width())); + } + if (!isPowerOfTwo(size.height())) { + qWarning("Texture height %d is not a power of two, adjusting", + size.height()); + size.setHeight(qNextPowerOfTwo(size.height())); + } + } + + if (size.width() > caps.maxTextureSize) { + qWarning("Texture width %d exceeds maximum width %d, adjusting", + size.width(), caps.maxTextureSize); + size.setWidth(caps.maxTextureSize); + } + if (size.height() > caps.maxTextureSize) { + qWarning("Texture height %d exceeds maximum height %d, adjusting", + size.height(), caps.maxTextureSize); + size.setHeight(caps.maxTextureSize); + } + + return size; +} + QRhiSwapChain *QRhiGles2::createSwapChain() { return new QGles2SwapChain(this); @@ -2276,26 +2313,25 @@ bool QGles2RenderBuffer::build() qWarning("RenderBuffer: UsedWithSwapChainOnly is meaningless in combination with Color"); } - if (m_pixelSize.isEmpty()) - return false; - if (!rhiD->ensureContext()) return false; rhiD->f->glGenRenderbuffers(1, &renderbuffer); rhiD->f->glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); + const QSize size = rhiD->safeTextureSize(m_pixelSize); + switch (m_type) { case QRhiRenderBuffer::DepthStencil: if (rhiD->caps.msaaRenderBuffer && samples > 1) { const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8; rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, storage, - m_pixelSize.width(), m_pixelSize.height()); + size.width(), size.height()); stencilRenderbuffer = 0; } else if (rhiD->caps.packedDepthStencil || rhiD->caps.needsDepthStencilCombinedAttach) { const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8; rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, storage, - m_pixelSize.width(), m_pixelSize.height()); + size.width(), size.height()); stencilRenderbuffer = 0; } else { GLenum depthStorage = GL_DEPTH_COMPONENT; @@ -2307,21 +2343,21 @@ bool QGles2RenderBuffer::build() } const GLenum stencilStorage = rhiD->caps.gles ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX; rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, depthStorage, - m_pixelSize.width(), m_pixelSize.height()); + size.width(), size.height()); rhiD->f->glGenRenderbuffers(1, &stencilRenderbuffer); rhiD->f->glBindRenderbuffer(GL_RENDERBUFFER, stencilRenderbuffer); rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, stencilStorage, - m_pixelSize.width(), m_pixelSize.height()); + size.width(), size.height()); } QRHI_PROF_F(newRenderBuffer(this, false, false, samples)); break; case QRhiRenderBuffer::Color: if (rhiD->caps.msaaRenderBuffer && samples > 1) rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_RGBA8, - m_pixelSize.width(), m_pixelSize.height()); + size.width(), size.height()); else rhiD->f->glRenderbufferStorage(GL_RENDERBUFFER, rhiD->caps.rgba8Format ? GL_RGBA8 : GL_RGBA4, - m_pixelSize.width(), m_pixelSize.height()); + size.width(), size.height()); QRHI_PROF_F(newRenderBuffer(this, false, false, samples)); break; default: @@ -2371,12 +2407,6 @@ void QGles2Texture::release() rhiD->unregisterResource(this); } -static inline bool isPowerOfTwo(int x) -{ - // Assumption: x >= 1 - return x == (x & -x); -} - bool QGles2Texture::prepareBuild(QSize *adjustedSize) { if (texture) @@ -2386,9 +2416,7 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize) if (!rhiD->ensureContext()) return false; - QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize; - if (!rhiD->caps.npotTexture && (!isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height()))) - size = QSize(qNextPowerOfTwo(size.width()), qNextPowerOfTwo(size.height())); + const QSize size = rhiD->safeTextureSize(m_pixelSize); const bool isCube = m_flags.testFlag(CubeMap); const bool hasMipMaps = m_flags.testFlag(MipMapped); diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index e02c8831907..dff12d626bb 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -611,6 +611,7 @@ public: QGles2RenderTargetData *enqueueBindFramebuffer(QRhiRenderTarget *rt, QGles2CommandBuffer *cbD, bool *wantsColorClear = nullptr, bool *wantsDsClear = nullptr); int effectiveSampleCount(int sampleCount) const; + QSize safeTextureSize(const QSize &size) const; QOpenGLContext *ctx = nullptr; bool importedContext = false; From 9452c963c8ab732946f835e5b5a0510c6fed49ee Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 28 Jun 2019 10:56:04 +0200 Subject: [PATCH 098/172] rhi: Add a test for instancing Draws 1024 cubes at random x,y positions with varying color with a single instanced draw call. Change-Id: I8737503acf23866ad4734b1d88753415a3b93445 Reviewed-by: Lars Knoll --- tests/manual/rhi/instancing/buildshaders.bat | 2 + tests/manual/rhi/instancing/inst.frag | 9 + tests/manual/rhi/instancing/inst.frag.qsb | Bin 0 -> 936 bytes tests/manual/rhi/instancing/inst.vert | 25 +++ tests/manual/rhi/instancing/inst.vert.qsb | Bin 0 -> 1792 bytes tests/manual/rhi/instancing/instancing.cpp | 175 +++++++++++++++++++ tests/manual/rhi/instancing/instancing.pro | 8 + tests/manual/rhi/instancing/instancing.qrc | 6 + tests/manual/rhi/rhi.pro | 3 +- 9 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 tests/manual/rhi/instancing/buildshaders.bat create mode 100644 tests/manual/rhi/instancing/inst.frag create mode 100644 tests/manual/rhi/instancing/inst.frag.qsb create mode 100644 tests/manual/rhi/instancing/inst.vert create mode 100644 tests/manual/rhi/instancing/inst.vert.qsb create mode 100644 tests/manual/rhi/instancing/instancing.cpp create mode 100644 tests/manual/rhi/instancing/instancing.pro create mode 100644 tests/manual/rhi/instancing/instancing.qrc diff --git a/tests/manual/rhi/instancing/buildshaders.bat b/tests/manual/rhi/instancing/buildshaders.bat new file mode 100644 index 00000000000..9053a1c54ac --- /dev/null +++ b/tests/manual/rhi/instancing/buildshaders.bat @@ -0,0 +1,2 @@ +qsb --glsl "330,300 es" --hlsl 50 --msl 12 inst.vert -o inst.vert.qsb +qsb --glsl "330,300 es" --hlsl 50 --msl 12 inst.frag -o inst.frag.qsb diff --git a/tests/manual/rhi/instancing/inst.frag b/tests/manual/rhi/instancing/inst.frag new file mode 100644 index 00000000000..719fd79ff5e --- /dev/null +++ b/tests/manual/rhi/instancing/inst.frag @@ -0,0 +1,9 @@ +#version 440 + +layout(location = 0) in vec3 vColor; +layout(location = 0) out vec4 fragColor; + +void main() +{ + fragColor = vec4(vColor, 1.0); +} diff --git a/tests/manual/rhi/instancing/inst.frag.qsb b/tests/manual/rhi/instancing/inst.frag.qsb new file mode 100644 index 0000000000000000000000000000000000000000..f19a2f0a7130c49a350e927e2242778199b2b9af GIT binary patch literal 936 zcmV;Z16TY200_@`oW)gJPa8)R9%BRXkfh|IRti!zk@H|w( zxhV{+y`IDvgY_tk;=e8-mcH*xoCnfhWb887-huHD#%IiVow2Hk7w)PLk~s|ht<6Q( zG58$=xntmR^A>W8vJ^?fUP!!={~yGA`#X78Sv&SRhB}+8p5eYU?$i;Zx}y-XT|m&%X5IjM#5RJ zt5B)R@Wb-`T|zx8BleTVao{^ zKY{%;wP3|y6*w_7wum=rT_p_dIoX%VeumD>$$o~;iP$f&o-*3tb@b=~oM3`-F^cgo zAlOT*6#EMK{|@Ms(b8h9fXxzCDqzP4~&pZ*J1{0;M}{=;==8b)>s=&*^*q8(x#|QmKvCH%!H{ zh~?W%#S)x!pxS3s$i5eQsWbs(>_&&LrJp9}WjNn*Ji-6>oK>i_xwfsE(tel)Qmpi3 z>V+;mPN6zn<3l`Az2H~;YjoE*&l1p3;Oi>^@uV5nylF-QWiKTo%OX}XlqnNMk_q5MWLvp0Y05R KKVJcZKlC&I1lUjj literal 0 HcmV?d00001 diff --git a/tests/manual/rhi/instancing/inst.vert b/tests/manual/rhi/instancing/inst.vert new file mode 100644 index 00000000000..3e1b117d588 --- /dev/null +++ b/tests/manual/rhi/instancing/inst.vert @@ -0,0 +1,25 @@ +#version 440 + +layout(location = 0) in vec4 position; + +// Instanced attributes to variate the translation and color of the cube +layout(location = 1) in vec3 instTranslate; +layout(location = 2) in vec3 instColor; + +layout(location = 0) out vec3 vColor; + +out gl_PerVertex { vec4 gl_Position; }; + +layout(std140, binding = 0) uniform buf { + mat4 mvp; +} ubuf; + +void main() +{ + vColor = instColor; + mat4 t = mat4(1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + instTranslate.x, instTranslate.y, instTranslate.z, 1); + gl_Position = ubuf.mvp * t * position; +} diff --git a/tests/manual/rhi/instancing/inst.vert.qsb b/tests/manual/rhi/instancing/inst.vert.qsb new file mode 100644 index 0000000000000000000000000000000000000000..de05eae80fa14a16a1cd23080a0727d931d7e99d GIT binary patch literal 1792 zcmV+b2mkm002LH?ob4D*Zxcs!{F!7SkPto!Nz;L(=^9*PJAtBv&_Y^Ks;ERHLZ~US z*7iCq*z2&nb^|n0h19BtUW&N!NBRTW|ImA{J@m+>Qs0|-G(GsoTT1wK#V9B}a6fbS5D&tZH8W0H1cBgK8=+jT+(~mH|g>i`dJd;MdI#%F0JL~Xjg1xV_oM%|4zYToHhS9ff ztL58)TKkOf(Z`Up$-}z8ppWv!sm8EgH^}c7Q>a%{6xVf@F@yPm*J}jmRF?IGQ+ob? zhw&$j*Q66^7`q)9f630uk?Ll+O77Q8dS(b)ZwNB^5n;z6GAR+0y!hT+U0*HvL9?`Q z2}_9`0c-I=+EK6!pDc`y<%lX6p?FTfn1fMe=wC*}`xmTJ;MVyOMj2Tt2})XZO!)X+FoGqp#D7J8PQZzq0TuK37A9Mh-%4$Jq5yJw$Z)| zFqcu6_MuNH>SF0B3TV+9{0`<4C)(tiTr<77J{`QrjF zAJl)6c=HEcPSO-pM)=o&$&oC^c#Pt_OgTPGdAbJNBLrUu ziIXC4GR7x}KQD48@rvgR@toFpCJC>2-X)$Xjc1zhYhVT1{vPG~m^KuR6FiI*h_(m%}f;k<)AiqFrNjTxua zv|Ie6A?*z6hq~5^F7rAFY?m3hfKk~#M-V90Zj!(MDWGdMhWxN_L1myF#d!=UQ}(m8I} zfP$M0#~TNi2h5Vuww?gaR5usC%&P_NxRPmb>Ll@1qI`qXCyBSLco(=jDZrS1*J*Oh zmRTVCrBxuHtvv8606b1i)MHjk9*U<$ahFC{`&l!ynVonq9b(vvvisZdcU zNb|Il6l^px)+NXSKhJ{#yh4|E4MVHYENv#LLjRa?+(x_CwE5MJ9a!xeTr}EF{hATt zeW%mBh_BLvYmi_cDv{%D%!d-RxsX~)sEby+3xV6wYJ*tNl5!2Qr8BDP;G3I0-}W$( zZn<#({*tCE;`8RFauJ#KsCV3m8H0F$oE5;uvfc}9Gqymis3NSDBvxf{$W|>VYx?5; z6FMtrrm_xeb92)Vu$vulp~xFu&}g|Lgma>IfC1huhz1&381$Rch+~;Q+m&_!RMKj> z6f5UJI#5Odrko@fHqjDGTc^c~n`mT0tinqPMP53n&e5$m)H-Mg%N=DrJLq{XimLL@ ziKsDoh*!h<&sG{T#A3t3-EPbA1BiINtm5r;zo~VshY;352+@EV8nDQ58Nb?0tv#q0Wh?H2xY-=`%O`Nn7W zR&L+E^J)2jZV0(5`!qtxQH^w@ZpUr$vo^8wlg)^B{UTq#t3`8H?daHTwYS>V-_!>! zQO1#Xq~2SiIuE4Bx%8g+H(P!ydC%|k+NR23Q9wa)P?{(LrN1}y^6=YJ8eDBfFjpZA zGrO#l<2y^VO!l&B6^rcKp$9r=w1c&LN<@MqQd<5`BAIkdY}1G|;U3;WvGg^+Xcvht ivunhzdqp<*>n!zKc- + +// Instanced draw example. When running with OpenGL, at least 3.3 or ES 3.0 is +// needed. + +const int INSTANCE_COUNT = 1024; + +struct { + QVector releasePool; + + QRhiBuffer *vbuf = nullptr; + QRhiBuffer *instBuf = nullptr; + QRhiBuffer *ubuf = nullptr; + QRhiShaderResourceBindings *srb = nullptr; + QRhiGraphicsPipeline *ps = nullptr; + + QRhiResourceUpdateBatch *initialUpdates = nullptr; + QMatrix4x4 winProj; +} d; + +void Window::customInit() +{ + if (!m_r->isFeatureSupported(QRhi::Instancing)) + qFatal("Instanced drawing is not supported"); + + d.initialUpdates = m_r->nextResourceUpdateBatch(); + + d.vbuf = m_r->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(cube)); + d.vbuf->build(); + d.releasePool << d.vbuf; + + d.initialUpdates->uploadStaticBuffer(d.vbuf, cube); + + // translation + color (vec3 + vec3), interleaved, for each instance + d.instBuf = m_r->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, INSTANCE_COUNT * 6 * sizeof(float)); + d.instBuf->build(); + d.releasePool << d.instBuf; + + d.ubuf = m_r->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, 64 + 12); + d.ubuf->build(); + d.releasePool << d.ubuf; + + d.srb = m_r->newShaderResourceBindings(); + d.releasePool << d.srb; + d.srb->setBindings({ + QRhiShaderResourceBinding::uniformBuffer(0, QRhiShaderResourceBinding::VertexStage, d.ubuf) + }); + d.srb->build(); + + d.ps = m_r->newGraphicsPipeline(); + d.releasePool << d.ps; + d.ps->setShaderStages({ + { QRhiShaderStage::Vertex, getShader(QLatin1String(":/inst.vert.qsb")) }, + { QRhiShaderStage::Fragment, getShader(QLatin1String(":/inst.frag.qsb")) } + }); + QRhiVertexInputLayout inputLayout; + inputLayout.setBindings({ + { 3 * sizeof(float) }, // cube vertices + { 6 * sizeof(float), QRhiVertexInputBinding::PerInstance } // per-instance translation and color + }); + inputLayout.setAttributes({ + { 0, 0, QRhiVertexInputAttribute::Float3, 0 }, // position + { 1, 1, QRhiVertexInputAttribute::Float3, 0 }, // instTranslate + { 1, 2, QRhiVertexInputAttribute::Float3, 3 * sizeof(float) } // instColor + }); + d.ps->setVertexInputLayout(inputLayout); + d.ps->setShaderResourceBindings(d.srb); + d.ps->setRenderPassDescriptor(m_rp); + d.ps->build(); + + QByteArray instData; + instData.resize(INSTANCE_COUNT * 6 * sizeof(float)); + float *p = reinterpret_cast(instData.data()); + QRandomGenerator *rgen = QRandomGenerator::global(); + for (int i = 0; i < INSTANCE_COUNT; ++i) { + // translation + *p++ = rgen->bounded(8000) / 100.0f - 40.0f; + *p++ = rgen->bounded(8000) / 100.0f - 40.0f; + *p++ = 0.0f; + // color + *p++ = i / float(INSTANCE_COUNT); + *p++ = 0.0f; + *p++ = 0.0f; + } + d.initialUpdates->uploadStaticBuffer(d.instBuf, instData.constData()); +} + +void Window::customRelease() +{ + qDeleteAll(d.releasePool); + d.releasePool.clear(); +} + +void Window::customRender() +{ + const QSize outputSizeInPixels = m_sc->currentPixelSize(); + QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer(); + QRhiResourceUpdateBatch *u = m_r->nextResourceUpdateBatch(); + if (d.initialUpdates) { + u->merge(d.initialUpdates); + d.initialUpdates->release(); + d.initialUpdates = nullptr; + } + + if (d.winProj != m_proj) { + d.winProj = m_proj; + QMatrix4x4 mvp = m_proj; + mvp.scale(0.05f); + u->updateDynamicBuffer(d.ubuf, 0, 64, mvp.constData()); + } + + cb->beginPass(m_sc->currentFrameRenderTarget(), QColor::fromRgbF(0.4f, 0.7f, 0.0f, 1.0f), { 1.0f, 0 }, u); + cb->setGraphicsPipeline(d.ps); + cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) }); + cb->setShaderResources(); + const QRhiCommandBuffer::VertexInput vbufBinding[] = { + { d.vbuf, 0 }, + { d.instBuf, 0 } + }; + cb->setVertexInput(0, 2, vbufBinding); + cb->draw(36, INSTANCE_COUNT); + cb->endPass(); +} diff --git a/tests/manual/rhi/instancing/instancing.pro b/tests/manual/rhi/instancing/instancing.pro new file mode 100644 index 00000000000..416c79f28a6 --- /dev/null +++ b/tests/manual/rhi/instancing/instancing.pro @@ -0,0 +1,8 @@ +TEMPLATE = app + +QT += gui-private + +SOURCES = \ + instancing.cpp + +RESOURCES = instancing.qrc diff --git a/tests/manual/rhi/instancing/instancing.qrc b/tests/manual/rhi/instancing/instancing.qrc new file mode 100644 index 00000000000..db21a9d8aab --- /dev/null +++ b/tests/manual/rhi/instancing/instancing.qrc @@ -0,0 +1,6 @@ + + + inst.vert.qsb + inst.frag.qsb + + diff --git a/tests/manual/rhi/rhi.pro b/tests/manual/rhi/rhi.pro index a06d973efee..d3661ff169d 100644 --- a/tests/manual/rhi/rhi.pro +++ b/tests/manual/rhi/rhi.pro @@ -16,7 +16,8 @@ SUBDIRS += \ mrt \ shadowmap \ computebuffer \ - computeimage + computeimage \ + instancing qtConfig(widgets) { SUBDIRS += \ From 201a22a4d2a3906a2f6cbba1e50d5b83a21a10f6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 28 Jun 2019 12:36:35 +0200 Subject: [PATCH 099/172] rhi: gl: Add support for instanced drawing ...when having a 3.3+ or ES 3.0+ context. Change-Id: Ie92815263e190912d8f0b7b92ae6da55e062af05 Reviewed-by: Lars Knoll --- src/gui/rhi/qrhigles2.cpp | 54 ++++++++++++++++++++++++++----------- src/gui/rhi/qrhigles2_p_p.h | 7 ++++- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 34052c5a9c6..60bbda2d600 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -425,6 +425,7 @@ bool QRhiGles2::create(QRhi::Flags flags) caps.elementIndexUint = f->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint); caps.depth24 = f->hasOpenGLExtension(QOpenGLExtensions::Depth24); caps.rgba8Format = f->hasOpenGLExtension(QOpenGLExtensions::Sized8Formats); + caps.instancing = caps.ctxMajor >= 3 && (caps.gles || caps.ctxMinor >= 3); nativeHandlesStruct.context = ctx; @@ -665,7 +666,7 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const case QRhi::Timestamps: return false; case QRhi::Instancing: - return false; + return caps.instancing; case QRhi::CustomInstanceStepRate: return false; case QRhi::PrimitiveRestart: @@ -933,7 +934,6 @@ void QRhiGles2::setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) void QRhiGles2::draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) { - Q_UNUSED(instanceCount); // no instancing Q_UNUSED(firstInstance); QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QGles2CommandBuffer::RenderPass); @@ -943,13 +943,13 @@ void QRhiGles2::draw(QRhiCommandBuffer *cb, quint32 vertexCount, cmd.args.draw.ps = cbD->currentPipeline; cmd.args.draw.vertexCount = vertexCount; cmd.args.draw.firstVertex = firstVertex; + cmd.args.draw.instanceCount = instanceCount; cbD->commands.append(cmd); } void QRhiGles2::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) { - Q_UNUSED(instanceCount); // no instancing Q_UNUSED(firstInstance); Q_UNUSED(vertexOffset); // no glDrawElementsBaseVertex QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb); @@ -960,6 +960,7 @@ void QRhiGles2::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, cmd.args.drawIndexed.ps = cbD->currentPipeline; cmd.args.drawIndexed.indexCount = indexCount; cmd.args.drawIndexed.firstIndex = firstIndex; + cmd.args.drawIndexed.instanceCount = instanceCount; cbD->commands.append(cmd); } @@ -1613,13 +1614,14 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) const QVector bindings = psD->m_vertexInputLayout.bindings(); const QVector attributes = psD->m_vertexInputLayout.attributes(); for (const QRhiVertexInputAttribute &a : attributes) { - if (a.binding() != cmd.args.bindVertexBuffer.binding) + const int bindingIdx = a.binding(); + if (bindingIdx != cmd.args.bindVertexBuffer.binding) continue; // we do not support more than one vertex buffer f->glBindBuffer(GL_ARRAY_BUFFER, cmd.args.bindVertexBuffer.buffer); - const int stride = bindings[a.binding()].stride(); + const int stride = bindings[bindingIdx].stride(); int size = 1; GLenum type = GL_FLOAT; bool normalize = false; @@ -1658,10 +1660,17 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) default: break; } + + const int locationIdx = a.location(); quint32 ofs = a.offset() + cmd.args.bindVertexBuffer.offset; - f->glVertexAttribPointer(a.location(), size, type, normalize, stride, + f->glVertexAttribPointer(locationIdx, size, type, normalize, stride, reinterpret_cast(quintptr(ofs))); - f->glEnableVertexAttribArray(a.location()); + f->glEnableVertexAttribArray(locationIdx); + if (bindings[bindingIdx].classification() == QRhiVertexInputBinding::PerInstance + && caps.instancing) + { + f->glVertexAttribDivisor(locationIdx, bindings[bindingIdx].instanceStepRate()); + } } } else { qWarning("No graphics pipeline active for setVertexInput; ignored"); @@ -1677,21 +1686,36 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) case QGles2CommandBuffer::Command::Draw: { QGles2GraphicsPipeline *psD = QRHI_RES(QGles2GraphicsPipeline, cmd.args.draw.ps); - if (psD) - f->glDrawArrays(psD->drawMode, cmd.args.draw.firstVertex, cmd.args.draw.vertexCount); - else + if (psD) { + if (cmd.args.draw.instanceCount == 1 || !caps.instancing) { + f->glDrawArrays(psD->drawMode, cmd.args.draw.firstVertex, cmd.args.draw.vertexCount); + } else { + f->glDrawArraysInstanced(psD->drawMode, cmd.args.draw.firstVertex, cmd.args.draw.vertexCount, + cmd.args.draw.instanceCount); + } + } else { qWarning("No graphics pipeline active for draw; ignored"); + } } break; case QGles2CommandBuffer::Command::DrawIndexed: { QGles2GraphicsPipeline *psD = QRHI_RES(QGles2GraphicsPipeline, cmd.args.drawIndexed.ps); if (psD) { - quint32 ofs = cmd.args.drawIndexed.firstIndex * indexStride + indexOffset; - f->glDrawElements(psD->drawMode, - cmd.args.drawIndexed.indexCount, - indexType, - reinterpret_cast(quintptr(ofs))); + const GLvoid *ofs = reinterpret_cast( + quintptr(cmd.args.drawIndexed.firstIndex * indexStride + indexOffset)); + if (cmd.args.drawIndexed.instanceCount == 1 || !caps.instancing) { + f->glDrawElements(psD->drawMode, + cmd.args.drawIndexed.indexCount, + indexType, + ofs); + } else { + f->glDrawElementsInstanced(psD->drawMode, + cmd.args.drawIndexed.indexCount, + indexType, + ofs, + cmd.args.drawIndexed.instanceCount); + } } else { qWarning("No graphics pipeline active for drawIndexed; ignored"); } diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index dff12d626bb..b758ec40b82 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -324,11 +324,13 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer QRhiGraphicsPipeline *ps; quint32 vertexCount; quint32 firstVertex; + quint32 instanceCount; } draw; struct { QRhiGraphicsPipeline *ps; quint32 indexCount; quint32 firstIndex; + quint32 instanceCount; } drawIndexed; struct { QRhiGraphicsPipeline *ps; @@ -644,7 +646,9 @@ public: coreProfile(false), uniformBuffers(false), elementIndexUint(false), - depth24(false) + depth24(false), + rgba8Format(false), + instancing(false) { } int ctxMajor; int ctxMinor; @@ -672,6 +676,7 @@ public: uint elementIndexUint : 1; uint depth24 : 1; uint rgba8Format : 1; + uint instancing : 1; } caps; QGles2SwapChain *currentSwapChain = nullptr; QVector supportedCompressedFormats; From 058c52fc2a6476f688d4b07d6f24516e26d0a8f5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 28 Jun 2019 15:06:06 +0200 Subject: [PATCH 100/172] rhi: Improve base vertex/instance support Have feature flags as appropriate. OpenGL is causing a mess here but let's support what we can since some of this will become relevant in more sophisticated mesh drawing cases with 3D in particular. Change-Id: Idfa7b4642ec87147978e03d78d6233efbd151491 Reviewed-by: Lars Knoll --- src/gui/rhi/qrhi.cpp | 42 ++++++++++++++---- src/gui/rhi/qrhi_p.h | 4 +- src/gui/rhi/qrhid3d11.cpp | 4 ++ src/gui/rhi/qrhigles2.cpp | 46 +++++++++++++++----- src/gui/rhi/qrhigles2_p_p.h | 7 ++- src/gui/rhi/qrhimetal.mm | 4 ++ src/gui/rhi/qrhivulkan.cpp | 8 +++- tests/manual/rhi/triquadcube/triquadcube.cpp | 2 + 8 files changed, 92 insertions(+), 25 deletions(-) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 681a6ddfb81..646f0aef136 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -511,6 +511,14 @@ QT_BEGIN_NAMESPACE dropped from the generated code) Note that some APIs (Metal, Vulkan) require the point size to be set in the shader explicitly whenever drawing points, even when the size is 1, as they do not automatically default to 1. + + \value BaseVertex Indicates that \l{QRhiCommandBuffer::drawIndexed()}{drawIndexed()} + supports the \c vertexOffset argument. When reported as not supported, the + vertexOffset value in an indexed draw is ignored. + + \value BaseInstance Indicates that instanced draw commands support the \c + firstInstance argument. When reported as not supported, the firstInstance + value is ignored and the instance ID starts from 0. */ /*! @@ -4483,15 +4491,21 @@ void QRhiCommandBuffer::setStencilRef(quint32 refValue) Records a non-indexed draw. The number of vertices is specified in \a vertexCount. For instanced - drawing set \a instanceCount to a value other than 1. \a firstVertex is - the index of the first vertex to draw. \a firstInstance is the instance ID - of the first instance to draw. + drawing set \a instanceCount to a value other than 1. \a firstVertex is the + index of the first vertex to draw. When drawing multiple instances, the + first instance ID is specified by \a firstInstance. + + \note \a firstInstance may not be supported, and is ignored when the + QRhi::BaseInstance feature is reported as not supported. The first ID is + always 0 in that case. \note This function can only be called inside a render pass, meaning between a beginPass() and endPass() call. */ void QRhiCommandBuffer::draw(quint32 vertexCount, - quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) + quint32 instanceCount, + quint32 firstVertex, + quint32 firstInstance) { m_rhi->draw(this, vertexCount, instanceCount, firstVertex, firstInstance); } @@ -4509,17 +4523,27 @@ void QRhiCommandBuffer::draw(quint32 vertexCount, \l{QRhi::NonFourAlignedEffectiveIndexBufferOffset}{NonFourAlignedEffectiveIndexBufferOffset} feature will be reported as not-supported. - For instanced drawing set \a instanceCount to a value other than 1. \a - firstInstance is the instance ID of the first instance to draw. + For instanced drawing set \a instanceCount to a value other than 1. When + drawing multiple instances, the first instance ID is specified by \a + firstInstance. - \a vertexOffset is added to the vertex index. + \note \a firstInstance may not be supported, and is ignored when the + QRhi::BaseInstance feature is reported as not supported. The first ID is + always 0 in that case. + + \a vertexOffset (also called \c{base vertex}) is a signed value that is + added to the element index before indexing into the vertex buffer. Support + for this is not always available, and the value is ignored when the feature + QRhi::BaseVertex is reported as unsupported. \note This function can only be called inside a render pass, meaning between a beginPass() and endPass() call. */ void QRhiCommandBuffer::drawIndexed(quint32 indexCount, - quint32 instanceCount, quint32 firstIndex, - qint32 vertexOffset, quint32 firstInstance) + quint32 instanceCount, + quint32 firstIndex, + qint32 vertexOffset, + quint32 firstInstance) { m_rhi->drawIndexed(this, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); } diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index fb8727b2653..df30817ef42 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -1318,7 +1318,9 @@ public: ElementIndexUint, Compute, WideLines, - VertexShaderPointSize + VertexShaderPointSize, + BaseVertex, + BaseInstance }; enum BeginFrameFlag { diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index dc69f50cc8c..49e90693be8 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -382,6 +382,10 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const return false; case QRhi::VertexShaderPointSize: return false; + case QRhi::BaseVertex: + return true; + case QRhi::BaseInstance: + return true; default: Q_UNREACHABLE(); return false; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 60bbda2d600..22cb030c275 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -426,6 +426,7 @@ bool QRhiGles2::create(QRhi::Flags flags) caps.depth24 = f->hasOpenGLExtension(QOpenGLExtensions::Depth24); caps.rgba8Format = f->hasOpenGLExtension(QOpenGLExtensions::Sized8Formats); caps.instancing = caps.ctxMajor >= 3 && (caps.gles || caps.ctxMinor >= 3); + caps.baseVertex = caps.ctxMajor >= 3 && caps.ctxMinor >= 2; nativeHandlesStruct.context = ctx; @@ -687,6 +688,10 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const return true; case QRhi::VertexShaderPointSize: return true; + case QRhi::BaseVertex: + return caps.baseVertex; + case QRhi::BaseInstance: + return false; // not in ES 3.2, so won't bother default: Q_UNREACHABLE(); return false; @@ -934,7 +939,6 @@ void QRhiGles2::setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) void QRhiGles2::draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) { - Q_UNUSED(firstInstance); QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QGles2CommandBuffer::RenderPass); @@ -944,14 +948,13 @@ void QRhiGles2::draw(QRhiCommandBuffer *cb, quint32 vertexCount, cmd.args.draw.vertexCount = vertexCount; cmd.args.draw.firstVertex = firstVertex; cmd.args.draw.instanceCount = instanceCount; + cmd.args.draw.baseInstance = firstInstance; cbD->commands.append(cmd); } void QRhiGles2::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) { - Q_UNUSED(firstInstance); - Q_UNUSED(vertexOffset); // no glDrawElementsBaseVertex QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QGles2CommandBuffer::RenderPass); @@ -961,6 +964,8 @@ void QRhiGles2::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, cmd.args.drawIndexed.indexCount = indexCount; cmd.args.drawIndexed.firstIndex = firstIndex; cmd.args.drawIndexed.instanceCount = instanceCount; + cmd.args.drawIndexed.baseInstance = firstInstance; + cmd.args.drawIndexed.baseVertex = vertexOffset; cbD->commands.append(cmd); } @@ -1705,16 +1710,33 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) const GLvoid *ofs = reinterpret_cast( quintptr(cmd.args.drawIndexed.firstIndex * indexStride + indexOffset)); if (cmd.args.drawIndexed.instanceCount == 1 || !caps.instancing) { - f->glDrawElements(psD->drawMode, - cmd.args.drawIndexed.indexCount, - indexType, - ofs); + if (cmd.args.drawIndexed.baseVertex != 0 && caps.baseVertex) { + f->glDrawElementsBaseVertex(psD->drawMode, + cmd.args.drawIndexed.indexCount, + indexType, + ofs, + cmd.args.drawIndexed.baseVertex); + } else { + f->glDrawElements(psD->drawMode, + cmd.args.drawIndexed.indexCount, + indexType, + ofs); + } } else { - f->glDrawElementsInstanced(psD->drawMode, - cmd.args.drawIndexed.indexCount, - indexType, - ofs, - cmd.args.drawIndexed.instanceCount); + if (cmd.args.drawIndexed.baseVertex != 0 && caps.baseVertex) { + f->glDrawElementsInstancedBaseVertex(psD->drawMode, + cmd.args.drawIndexed.indexCount, + indexType, + ofs, + cmd.args.drawIndexed.instanceCount, + cmd.args.drawIndexed.baseVertex); + } else { + f->glDrawElementsInstanced(psD->drawMode, + cmd.args.drawIndexed.indexCount, + indexType, + ofs, + cmd.args.drawIndexed.instanceCount); + } } } else { qWarning("No graphics pipeline active for drawIndexed; ignored"); diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index b758ec40b82..d6682977ff2 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -325,12 +325,15 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer quint32 vertexCount; quint32 firstVertex; quint32 instanceCount; + quint32 baseInstance; } draw; struct { QRhiGraphicsPipeline *ps; quint32 indexCount; quint32 firstIndex; quint32 instanceCount; + quint32 baseInstance; + qint32 baseVertex; } drawIndexed; struct { QRhiGraphicsPipeline *ps; @@ -648,7 +651,8 @@ public: elementIndexUint(false), depth24(false), rgba8Format(false), - instancing(false) + instancing(false), + baseVertex(false) { } int ctxMajor; int ctxMinor; @@ -677,6 +681,7 @@ public: uint depth24 : 1; uint rgba8Format : 1; uint instancing : 1; + uint baseVertex : 1; } caps; QGles2SwapChain *currentSwapChain = nullptr; QVector supportedCompressedFormats; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 09b80c831da..fa537a504b3 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -527,6 +527,10 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const return false; case QRhi::VertexShaderPointSize: return true; + case QRhi::BaseVertex: + return true; + case QRhi::BaseInstance: + return true; default: Q_UNREACHABLE(); return false; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 8598e5869ad..7c4eeaf226a 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -3549,6 +3549,10 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const return hasWideLines; case QRhi::VertexShaderPointSize: return true; + case QRhi::BaseVertex: + return true; + case QRhi::BaseInstance: + return true; default: Q_UNREACHABLE(); return false; @@ -4063,7 +4067,7 @@ void QRhiVulkan::setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) } void QRhiVulkan::draw(QRhiCommandBuffer *cb, quint32 vertexCount, - quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) + quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) { QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QVkCommandBuffer::RenderPass); @@ -4078,7 +4082,7 @@ void QRhiVulkan::draw(QRhiCommandBuffer *cb, quint32 vertexCount, } void QRhiVulkan::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, - quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) + quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) { QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QVkCommandBuffer::RenderPass); diff --git a/tests/manual/rhi/triquadcube/triquadcube.cpp b/tests/manual/rhi/triquadcube/triquadcube.cpp index 1b390c34ed9..4165e961277 100644 --- a/tests/manual/rhi/triquadcube/triquadcube.cpp +++ b/tests/manual/rhi/triquadcube/triquadcube.cpp @@ -174,6 +174,8 @@ void Window::customInit() qDebug("isFeatureSupported(Compute): %d", m_r->isFeatureSupported(QRhi::Compute)); qDebug("isFeatureSupported(WideLines): %d", m_r->isFeatureSupported(QRhi::WideLines)); qDebug("isFeatureSupported(VertexShaderPointSize): %d", m_r->isFeatureSupported(QRhi::VertexShaderPointSize)); + qDebug("isFeatureSupported(BaseVertex): %d", m_r->isFeatureSupported(QRhi::BaseVertex)); + qDebug("isFeatureSupported(BaseInstance): %d", m_r->isFeatureSupported(QRhi::BaseInstance)); qDebug("Min 2D texture width/height: %d", m_r->resourceLimit(QRhi::TextureSizeMin)); qDebug("Max 2D texture width/height: %d", m_r->resourceLimit(QRhi::TextureSizeMax)); qDebug("Max color attachment count: %d", m_r->resourceLimit(QRhi::MaxColorAttachments)); From 2c289c6c1e04c419eefb890f19872a5bddc2fe78 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 28 Jun 2019 15:55:52 +0200 Subject: [PATCH 101/172] rhi: d3d: Fix resource binding mismatch with multiple passes The resetShaderResources() done when starting a render or compute pass purges all vertex, index, SRV, and UAV bindings. This will be optimized at a later point, but until then the command buffer's state should be updated accordingly, otherwise certain use cases end up with incorrect rendering results due to not binding vertex/index/shader resources as appropriate. This fixes the shadowmap example on d3d. Change-Id: I4d07929b8664b64bc608c6c8df474b0ee7c2ddbb Reviewed-by: Lars Knoll --- src/gui/rhi/qrhid3d11.cpp | 4 ++++ src/gui/rhi/qrhid3d11_p_p.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 49e90693be8..eea2a13d8c5 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1480,6 +1480,8 @@ void QRhiD3D11::beginPass(QRhiCommandBuffer *cb, cbD->recordingPass = QD3D11CommandBuffer::RenderPass; cbD->currentTarget = rt; + + cbD->resetCachedShaderResourceState(); } void QRhiD3D11::endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) @@ -1556,6 +1558,8 @@ void QRhiD3D11::beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch cbD->commands.append(cmd); cbD->recordingPass = QD3D11CommandBuffer::ComputePass; + + cbD->resetCachedShaderResourceState(); } void QRhiD3D11::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index 688f79b3b74..34c9ff70f87 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -482,6 +482,9 @@ struct QD3D11CommandBuffer : public QRhiCommandBuffer currentGraphicsPipeline = nullptr; currentComputePipeline = nullptr; currentPipelineGeneration = 0; + resetCachedShaderResourceState(); + } + void resetCachedShaderResourceState() { currentGraphicsSrb = nullptr; currentComputeSrb = nullptr; currentSrbGeneration = 0; From da0f40f9acc1afc3d640ca03062356ca4d9b1272 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 19 May 2019 16:25:52 +0200 Subject: [PATCH 102/172] QCharRef/QByteRef: schedule for Qt 7 removal With all of their special behavior deprecated, QCharRef and QByteRef can simply be removed. Add a comment. Change-Id: I8bad95424207ae281b5edf348b9ad81c6807dc12 Reviewed-by: Marc Mutz --- src/corelib/tools/qbytearray.h | 2 +- src/corelib/tools/qstring.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index a81051d309c..7c571706d8a 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -548,7 +548,7 @@ class #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_CORE_EXPORT #endif -QByteRef { +QByteRef { // ### Qt 7: remove QByteArray &a; int i; inline QByteRef(QByteArray &array, int idx) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 37bc8d91c94..6788e530574 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1103,7 +1103,7 @@ class #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) Q_CORE_EXPORT #endif -QCharRef { +QCharRef { // ### Qt 7: remove QString &s; int i; inline QCharRef(QString &str, int idx) From 2f672b223900e056ffa642d3186e6cdcac9152aa Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 24 Jun 2019 17:49:55 +0200 Subject: [PATCH 103/172] Do not ignore exit codes when installing meta files Since commit 20e9422e we don't ignore exit codes when installing files anymore. This patch does the same for meta file installation. We really should be notified properly if something goes wrong here. Task-number: QTBUG-18870 Change-Id: Ib6a20293380f400379b10ec767bf38dc74d5beeb Reviewed-by: Oliver Wolff Reviewed-by: Christian Kandeler --- qmake/generators/makefile.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index aa1b50f2ef1..5ae1cf0bffb 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -3441,7 +3441,7 @@ QString MakefileGenerator::installMetaFile(const ProKey &replace_rule, const QSt QString ret; if (project->isEmpty(replace_rule) || project->isActiveConfig("no_sed_meta_install")) { - ret += "-$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + escapeFilePath(dst); + ret += "$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + escapeFilePath(dst); } else { QString sedargs; const ProStringList &replace_rules = project->values(replace_rule); @@ -3456,9 +3456,9 @@ QString MakefileGenerator::installMetaFile(const ProKey &replace_rule, const QSt } } if (sedargs.isEmpty()) { - ret += "-$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + escapeFilePath(dst); + ret += "$(INSTALL_FILE) " + escapeFilePath(src) + ' ' + escapeFilePath(dst); } else { - ret += "-$(SED) " + sedargs + ' ' + escapeFilePath(src) + " > " + escapeFilePath(dst); + ret += "$(SED) " + sedargs + ' ' + escapeFilePath(src) + " > " + escapeFilePath(dst); } } return ret; From 7993cada3961cca417431a392fc047a3d7909657 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 21:40:27 +0200 Subject: [PATCH 104/172] QAccessibleWidget: fix UB (invalid cast) Casting an object to a subclass that is not the dynamic type of the object constitutes undefined behavior. Fix by befriending QObject. Change-Id: Ib70dbef9095df31a6d89449d82a02cef9fccd348 Reviewed-by: Frederik Gladhorn --- src/corelib/kernel/qobject.h | 2 ++ src/widgets/accessible/qaccessiblewidget.cpp | 20 ++------------------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 240ace1e27b..540b8b32c1d 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -71,6 +71,7 @@ class QObjectPrivate; class QObject; class QThread; class QWidget; +class QAccessibleWidget; #ifndef QT_NO_REGEXP class QRegExp; #endif @@ -459,6 +460,7 @@ protected: friend class QCoreApplication; friend class QCoreApplicationPrivate; friend class QWidget; + friend class QAccessibleWidget; friend class QThreadData; private: diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index c96d213e7be..27e6b09dc73 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -273,22 +273,6 @@ QRect QAccessibleWidget::rect() const return QRect(wpos.x(), wpos.y(), w->width(), w->height()); } -QT_BEGIN_INCLUDE_NAMESPACE -#include -QT_END_INCLUDE_NAMESPACE - -class QACConnectionObject : public QObject -{ - Q_DECLARE_PRIVATE(QObject) -public: - inline bool isSender(const QObject *receiver, const char *signal) const - { return d_func()->isSender(receiver, signal); } - inline QObjectList receiverList(const char *signal) const - { return d_func()->receiverList(signal); } - inline QObjectList senderList() const - { return d_func()->senderList(); } -}; - /*! Registers \a signal as a controlling signal. @@ -347,9 +331,9 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel if (match & QAccessible::Controlled) { QObjectList allReceivers; - QACConnectionObject *connectionObject = (QACConnectionObject*)object(); + QObject *connectionObject = object(); for (int sig = 0; sig < d->primarySignals.count(); ++sig) { - const QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toLatin1()); + const QObjectList receivers = connectionObject->d_func()->receiverList(d->primarySignals.at(sig).toLatin1()); allReceivers += receivers; } From 2f19a3053ea0216050a8eb76e6e062df9df1538d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 28 May 2019 16:21:15 +0200 Subject: [PATCH 105/172] Use simpler data structures in cldr2qtimezone.py Use tuples for the fixed data. The numbering of rows in the data tables isn't part of any public API, so we can change it freely; it is thus unnecessary, as we can just enumerate a tuple of the data values to generate sequential indices on the fly. (Updates to the data shall no longer need to renumber in order to insert entries.) Restore ordering of the data tables, and remove wanton spacing from inside parens, in the process. Change-Id: I59956cfb6191fe729300b57070671b7e66bd0379 Reviewed-by: Konstantin Ritt Reviewed-by: Thiago Macieira --- util/locale_database/cldr2qtimezone.py | 334 ++++++++++++------------- 1 file changed, 165 insertions(+), 169 deletions(-) diff --git a/util/locale_database/cldr2qtimezone.py b/util/locale_database/cldr2qtimezone.py index 0817435d402..1c82e1d58fd 100755 --- a/util/locale_database/cldr2qtimezone.py +++ b/util/locale_database/cldr2qtimezone.py @@ -89,169 +89,171 @@ class ByteArrayData: self.data += lst return index -# List of currently known Windows IDs. If script fails on missing ID plase add it here -# Not public so may be safely changed. -# Windows Key : [ Windows Id, Offset Seconds ] -windowsIdList = { - 1 : [ u'Afghanistan Standard Time', 16200 ], - 2 : [ u'Alaskan Standard Time', -32400 ], - 3 : [ u'Arab Standard Time', 10800 ], - 4 : [ u'Arabian Standard Time', 14400 ], - 5 : [ u'Arabic Standard Time', 10800 ], - 6 : [ u'Argentina Standard Time', -10800 ], - 7 : [ u'Atlantic Standard Time', -14400 ], - 8 : [ u'AUS Central Standard Time', 34200 ], - 9 : [ u'AUS Eastern Standard Time', 36000 ], - 10 : [ u'Azerbaijan Standard Time', 14400 ], - 11 : [ u'Azores Standard Time', -3600 ], - 12 : [ u'Bahia Standard Time', -10800 ], - 13 : [ u'Bangladesh Standard Time', 21600 ], - 14 : [ u'Belarus Standard Time', 10800 ], - 15 : [ u'Canada Central Standard Time', -21600 ], - 16 : [ u'Cape Verde Standard Time', -3600 ], - 17 : [ u'Caucasus Standard Time', 14400 ], - 18 : [ u'Cen. Australia Standard Time', 34200 ], - 19 : [ u'Central America Standard Time', -21600 ], - 20 : [ u'Central Asia Standard Time', 21600 ], - 21 : [ u'Central Brazilian Standard Time', -14400 ], - 22 : [ u'Central Europe Standard Time', 3600 ], - 23 : [ u'Central European Standard Time', 3600 ], - 24 : [ u'Central Pacific Standard Time', 39600 ], - 25 : [ u'Central Standard Time (Mexico)', -21600 ], - 26 : [ u'Central Standard Time', -21600 ], - 27 : [ u'China Standard Time', 28800 ], - 28 : [ u'Dateline Standard Time', -43200 ], - 29 : [ u'E. Africa Standard Time', 10800 ], - 30 : [ u'E. Australia Standard Time', 36000 ], - 31 : [ u'E. South America Standard Time', -10800 ], - 32 : [ u'Eastern Standard Time', -18000 ], - 33 : [ u'Eastern Standard Time (Mexico)', -18000 ], - 34 : [ u'Egypt Standard Time', 7200 ], - 35 : [ u'Ekaterinburg Standard Time', 18000 ], - 36 : [ u'Fiji Standard Time', 43200 ], - 37 : [ u'FLE Standard Time', 7200 ], - 38 : [ u'Georgian Standard Time', 14400 ], - 39 : [ u'GMT Standard Time', 0 ], - 40 : [ u'Greenland Standard Time', -10800 ], - 41 : [ u'Greenwich Standard Time', 0 ], - 42 : [ u'GTB Standard Time', 7200 ], - 43 : [ u'Hawaiian Standard Time', -36000 ], - 44 : [ u'India Standard Time', 19800 ], - 45 : [ u'Iran Standard Time', 12600 ], - 46 : [ u'Israel Standard Time', 7200 ], - 47 : [ u'Jordan Standard Time', 7200 ], - 48 : [ u'Kaliningrad Standard Time', 7200 ], - 49 : [ u'Korea Standard Time', 32400 ], - 50 : [ u'Libya Standard Time', 7200 ], - 51 : [ u'Line Islands Standard Time', 50400 ], - 52 : [ u'Magadan Standard Time', 36000 ], - 53 : [ u'Mauritius Standard Time', 14400 ], - 54 : [ u'Middle East Standard Time', 7200 ], - 55 : [ u'Montevideo Standard Time', -10800 ], - 56 : [ u'Morocco Standard Time', 0 ], - 57 : [ u'Mountain Standard Time (Mexico)', -25200 ], - 58 : [ u'Mountain Standard Time', -25200 ], - 59 : [ u'Myanmar Standard Time', 23400 ], - 60 : [ u'N. Central Asia Standard Time', 21600 ], - 61 : [ u'Namibia Standard Time', 3600 ], - 62 : [ u'Nepal Standard Time', 20700 ], - 63 : [ u'New Zealand Standard Time', 43200 ], - 64 : [ u'Newfoundland Standard Time', -12600 ], - 65 : [ u'North Asia East Standard Time', 28800 ], - 66 : [ u'North Asia Standard Time', 25200 ], - 67 : [ u'Pacific SA Standard Time', -10800 ], - 68 : [ u'E. Europe Standard Time', 7200 ], - 69 : [ u'Pacific Standard Time', -28800 ], - 70 : [ u'Pakistan Standard Time', 18000 ], - 71 : [ u'Paraguay Standard Time', -14400 ], - 72 : [ u'Romance Standard Time', 3600 ], - 73 : [ u'Russia Time Zone 3', 14400 ], - 74 : [ u'Russia Time Zone 10', 39600 ], - 75 : [ u'Russia Time Zone 11', 43200 ], - 76 : [ u'Russian Standard Time', 10800 ], - 77 : [ u'SA Eastern Standard Time', -10800 ], - 78 : [ u'SA Pacific Standard Time', -18000 ], - 79 : [ u'SA Western Standard Time', -14400 ], - 80 : [ u'Samoa Standard Time', 46800 ], - 81 : [ u'SE Asia Standard Time', 25200 ], - 82 : [ u'Singapore Standard Time', 28800 ], - 83 : [ u'South Africa Standard Time', 7200 ], - 84 : [ u'Sri Lanka Standard Time', 19800 ], - 85 : [ u'Syria Standard Time', 7200 ], - 86 : [ u'Taipei Standard Time', 28800 ], - 87 : [ u'Tasmania Standard Time', 36000 ], - 88 : [ u'Tokyo Standard Time', 32400 ], - 89 : [ u'Tonga Standard Time', 46800 ], - 90 : [ u'Turkey Standard Time', 7200 ], - 91 : [ u'Ulaanbaatar Standard Time', 28800 ], - 92 : [ u'US Eastern Standard Time', -18000 ], - 93 : [ u'US Mountain Standard Time', -25200 ], - 94 : [ u'UTC-02', -7200 ], - 95 : [ u'UTC-11', -39600 ], - 96 : [ u'UTC', 0 ], - 97 : [ u'UTC+12', 43200 ], - 98 : [ u'Venezuela Standard Time', -16200 ], - 99 : [ u'Vladivostok Standard Time', 36000 ], - 100: [ u'W. Australia Standard Time', 28800 ], - 101: [ u'W. Central Africa Standard Time', 3600 ], - 102: [ u'W. Europe Standard Time', 3600 ], - 103: [ u'West Asia Standard Time', 18000 ], - 104: [ u'West Pacific Standard Time', 36000 ], - 105: [ u'Yakutsk Standard Time', 32400 ], - 106: [ u'North Korea Standard Time', 30600 ] -} +# List of currently known Windows IDs. +# If this script reports missing IDs, please add them here. +# Look up the offset using (google and) timeanddate.com. +# Not public so may safely be changed. Please keep in alphabetic order by ID. +# ( Windows Id, Offset Seconds ) +windowsIdList = ( + (u'Afghanistan Standard Time', 16200), + (u'Alaskan Standard Time', -32400), + (u'Arab Standard Time', 10800), + (u'Arabian Standard Time', 14400), + (u'Arabic Standard Time', 10800), + (u'Argentina Standard Time', -10800), + (u'Atlantic Standard Time', -14400), + (u'AUS Central Standard Time', 34200), + (u'AUS Eastern Standard Time', 36000), + (u'Azerbaijan Standard Time', 14400), + (u'Azores Standard Time', -3600), + (u'Bahia Standard Time', -10800), + (u'Bangladesh Standard Time', 21600), + (u'Belarus Standard Time', 10800), + (u'Canada Central Standard Time', -21600), + (u'Cape Verde Standard Time', -3600), + (u'Caucasus Standard Time', 14400), + (u'Cen. Australia Standard Time', 34200), + (u'Central America Standard Time', -21600), + (u'Central Asia Standard Time', 21600), + (u'Central Brazilian Standard Time', -14400), + (u'Central Europe Standard Time', 3600), + (u'Central European Standard Time', 3600), + (u'Central Pacific Standard Time', 39600), + (u'Central Standard Time (Mexico)', -21600), + (u'Central Standard Time', -21600), + (u'China Standard Time', 28800), + (u'Dateline Standard Time', -43200), + (u'E. Africa Standard Time', 10800), + (u'E. Australia Standard Time', 36000), + (u'E. Europe Standard Time', 7200), + (u'E. South America Standard Time', -10800), + (u'Eastern Standard Time', -18000), + (u'Eastern Standard Time (Mexico)', -18000), + (u'Egypt Standard Time', 7200), + (u'Ekaterinburg Standard Time', 18000), + (u'Fiji Standard Time', 43200), + (u'FLE Standard Time', 7200), + (u'Georgian Standard Time', 14400), + (u'GMT Standard Time', 0), + (u'Greenland Standard Time', -10800), + (u'Greenwich Standard Time', 0), + (u'GTB Standard Time', 7200), + (u'Hawaiian Standard Time', -36000), + (u'India Standard Time', 19800), + (u'Iran Standard Time', 12600), + (u'Israel Standard Time', 7200), + (u'Jordan Standard Time', 7200), + (u'Kaliningrad Standard Time', 7200), + (u'Korea Standard Time', 32400), + (u'Libya Standard Time', 7200), + (u'Line Islands Standard Time', 50400), + (u'Magadan Standard Time', 36000), + (u'Mauritius Standard Time', 14400), + (u'Middle East Standard Time', 7200), + (u'Montevideo Standard Time', -10800), + (u'Morocco Standard Time', 0), + (u'Mountain Standard Time (Mexico)', -25200), + (u'Mountain Standard Time', -25200), + (u'Myanmar Standard Time', 23400), + (u'N. Central Asia Standard Time', 21600), + (u'Namibia Standard Time', 3600), + (u'Nepal Standard Time', 20700), + (u'New Zealand Standard Time', 43200), + (u'Newfoundland Standard Time', -12600), + (u'North Asia East Standard Time', 28800), + (u'North Asia Standard Time', 25200), + (u'North Korea Standard Time', 30600), + (u'Pacific SA Standard Time', -10800), + (u'Pacific Standard Time', -28800), + (u'Pakistan Standard Time', 18000), + (u'Paraguay Standard Time', -14400), + (u'Romance Standard Time', 3600), + (u'Russia Time Zone 3', 14400), + (u'Russia Time Zone 10', 39600), + (u'Russia Time Zone 11', 43200), + (u'Russian Standard Time', 10800), + (u'SA Eastern Standard Time', -10800), + (u'SA Pacific Standard Time', -18000), + (u'SA Western Standard Time', -14400), + (u'Samoa Standard Time', 46800), + (u'SE Asia Standard Time', 25200), + (u'Singapore Standard Time', 28800), + (u'South Africa Standard Time', 7200), + (u'Sri Lanka Standard Time', 19800), + (u'Syria Standard Time', 7200), + (u'Taipei Standard Time', 28800), + (u'Tasmania Standard Time', 36000), + (u'Tokyo Standard Time', 32400), + (u'Tonga Standard Time', 46800), + (u'Turkey Standard Time', 7200), + (u'Ulaanbaatar Standard Time', 28800), + (u'US Eastern Standard Time', -18000), + (u'US Mountain Standard Time', -25200), + (u'UTC-11', -39600), + (u'UTC-02', -7200), + (u'UTC', 0), + (u'UTC+12', 43200), + (u'Venezuela Standard Time', -16200), + (u'Vladivostok Standard Time', 36000), + (u'W. Australia Standard Time', 28800), + (u'W. Central Africa Standard Time', 3600), + (u'W. Europe Standard Time', 3600), + (u'West Asia Standard Time', 18000), + (u'West Pacific Standard Time', 36000), + (u'Yakutsk Standard Time', 32400), +) def windowsIdToKey(windowsId): - for windowsKey in windowsIdList: - if windowsIdList[windowsKey][0] == windowsId: - return windowsKey + for index, pair in enumerate(windowsIdList): + if pair[0] == windowsId: + return index + 1 return 0 # List of standard UTC IDs to use. Not public so may be safely changed. -# Do not remove ID's as is part of API/behavior guarantee -# Key : [ UTC Id, Offset Seconds ] -utcIdList = { - 0 : [ u'UTC', 0 ], # Goes first so is default - 1 : [ u'UTC-14:00', -50400 ], - 2 : [ u'UTC-13:00', -46800 ], - 3 : [ u'UTC-12:00', -43200 ], - 4 : [ u'UTC-11:00', -39600 ], - 5 : [ u'UTC-10:00', -36000 ], - 6 : [ u'UTC-09:00', -32400 ], - 7 : [ u'UTC-08:00', -28800 ], - 8 : [ u'UTC-07:00', -25200 ], - 9 : [ u'UTC-06:00', -21600 ], - 10 : [ u'UTC-05:00', -18000 ], - 11 : [ u'UTC-04:30', -16200 ], - 12 : [ u'UTC-04:00', -14400 ], - 13 : [ u'UTC-03:30', -12600 ], - 14 : [ u'UTC-03:00', -10800 ], - 15 : [ u'UTC-02:00', -7200 ], - 16 : [ u'UTC-01:00', -3600 ], - 17 : [ u'UTC-00:00', 0 ], - 18 : [ u'UTC+00:00', 0 ], - 19 : [ u'UTC+01:00', 3600 ], - 20 : [ u'UTC+02:00', 7200 ], - 21 : [ u'UTC+03:00', 10800 ], - 22 : [ u'UTC+03:30', 12600 ], - 23 : [ u'UTC+04:00', 14400 ], - 24 : [ u'UTC+04:30', 16200 ], - 25 : [ u'UTC+05:00', 18000 ], - 26 : [ u'UTC+05:30', 19800 ], - 27 : [ u'UTC+05:45', 20700 ], - 28 : [ u'UTC+06:00', 21600 ], - 29 : [ u'UTC+06:30', 23400 ], - 30 : [ u'UTC+07:00', 25200 ], - 31 : [ u'UTC+08:00', 28800 ], - 32 : [ u'UTC+09:00', 32400 ], - 33 : [ u'UTC+09:30', 34200 ], - 34 : [ u'UTC+10:00', 36000 ], - 35 : [ u'UTC+11:00', 39600 ], - 36 : [ u'UTC+12:00', 43200 ], - 37 : [ u'UTC+13:00', 46800 ], - 38 : [ u'UTC+14:00', 50400 ], - 39 : [ u'UTC+08:30', 30600 ] -} +# Do not remove IDs, as each entry is part of the API/behavior guarantee. +# ( UTC Id, Offset Seconds ) +utcIdList = ( + (u'UTC', 0), # Goes first so is default + (u'UTC-14:00', -50400), + (u'UTC-13:00', -46800), + (u'UTC-12:00', -43200), + (u'UTC-11:00', -39600), + (u'UTC-10:00', -36000), + (u'UTC-09:00', -32400), + (u'UTC-08:00', -28800), + (u'UTC-07:00', -25200), + (u'UTC-06:00', -21600), + (u'UTC-05:00', -18000), + (u'UTC-04:30', -16200), + (u'UTC-04:00', -14400), + (u'UTC-03:30', -12600), + (u'UTC-03:00', -10800), + (u'UTC-02:00', -7200), + (u'UTC-01:00', -3600), + (u'UTC-00:00', 0), + (u'UTC+00:00', 0), + (u'UTC+01:00', 3600), + (u'UTC+02:00', 7200), + (u'UTC+03:00', 10800), + (u'UTC+03:30', 12600), + (u'UTC+04:00', 14400), + (u'UTC+04:30', 16200), + (u'UTC+05:00', 18000), + (u'UTC+05:30', 19800), + (u'UTC+05:45', 20700), + (u'UTC+06:00', 21600), + (u'UTC+06:30', 23400), + (u'UTC+07:00', 25200), + (u'UTC+08:00', 28800), + (u'UTC+08:30', 30600), + (u'UTC+09:00', 32400), + (u'UTC+09:30', 34200), + (u'UTC+10:00', 36000), + (u'UTC+11:00', 39600), + (u'UTC+12:00', 43200), + (u'UTC+13:00', 46800), + (u'UTC+14:00', 50400), +) def usage(): print "Usage: cldr2qtimezone.py " @@ -370,13 +372,10 @@ print "Done Zone Data" # Write Windows ID key table newTempFile.write("// Windows ID Key, Windows ID Index, IANA ID Index, UTC Offset\n") newTempFile.write("static const QWindowsData windowsDataTable[] = {\n") -for windowsKey in windowsIdList: +for index, pair in enumerate(windowsIdList): newTempFile.write(" { %6d,%6d,%6d,%6d }, // %s\n" - % (windowsKey, - windowsIdData.append(windowsIdList[windowsKey][0]), - ianaIdData.append(defaultDict[windowsKey]), - windowsIdList[windowsKey][1], - windowsIdList[windowsKey][0])) + % (index + 1, windowsIdData.append(pair[0]), + ianaIdData.append(defaultDict[index + 1]), pair[1], pair[0])) newTempFile.write(" { 0, 0, 0, 0 } // Trailing zeroes\n") newTempFile.write("};\n\n") @@ -385,12 +384,9 @@ print "Done Windows Data Table" # Write UTC ID key table newTempFile.write("// IANA ID Index, UTC Offset\n") newTempFile.write("static const QUtcData utcDataTable[] = {\n") -for index in utcIdList: - data = utcIdList[index] +for pair in utcIdList: newTempFile.write(" { %6d,%6d }, // %s\n" - % (ianaIdData.append(data[0]), - data[1], - data[0])) + % (ianaIdData.append(pair[0]), pair[1], pair[0])) newTempFile.write(" { 0, 0 } // Trailing zeroes\n") newTempFile.write("};\n\n") From bbd64f64b235d04058ba5bd83886d76fa4ee7a0c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 28 May 2019 18:16:54 +0200 Subject: [PATCH 106/172] cldr2qtimezone.py: report all missing zones, rather than just the first When scanning the CLDR data, the script raised an exception if it didn't recognize a zone ID. Instead, collect up such unrecognized IDs in a list and report them all at the end, so that whoever runs this can do them all in one go, rather than doing one, running the script, doing the next, running the script, ad nauseam. Change-Id: Ia659f1d1c7e1c1b4ccb87cc23828a0588a5bf958 Reviewed-by: Lars Knoll --- util/locale_database/cldr2qtimezone.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/locale_database/cldr2qtimezone.py b/util/locale_database/cldr2qtimezone.py index 1c82e1d58fd..809a35912bd 100755 --- a/util/locale_database/cldr2qtimezone.py +++ b/util/locale_database/cldr2qtimezone.py @@ -293,6 +293,7 @@ defaultDict = {} windowsIdDict = {} if mapTimezones: + badZones = set() for mapZone in mapTimezones: # [u'mapZone', [(u'territory', u'MH'), (u'other', u'UTC+12'), (u'type', u'Pacific/Majuro Pacific/Kwajalein')]] if mapZone[0] == u'mapZone': @@ -307,7 +308,7 @@ if mapTimezones: data['windowsKey'] = windowsIdToKey(data['windowsId']) if data['windowsKey'] <= 0: - raise xpathlite.Error("Unknown Windows ID, please add \"%s\"" % data['windowsId']) + badZones.add(data['windowsId']) countryId = 0 if data['countryCode'] == u'001': @@ -318,6 +319,10 @@ if mapTimezones: raise xpathlite.Error("Unknown Country Code \"%s\"" % data['countryCode']) data['country'] = enumdata.country_list[data['countryId']][0] windowsIdDict[data['windowsKey'], data['countryId']] = data + if badZones: + sys.stderr.write('\n\t'.join(["\nUnknown Windows ID, please add:"] + sorted(badZones)) + + "\nto the windowIdList in cldr2qtimezone.py\n\n") + raise xpathlite.Error("Unknown Windows IDs") print "Input file parsed, now writing data" From 13242673cf4fdeed6f69d1209bb70b94a9e5d758 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 28 May 2019 18:19:38 +0200 Subject: [PATCH 107/172] Tidy up in cldr2qtimezone.py and document the need to run it It wasn't mentioned in cldr2qlocalexml.py's instructions, so I didn't know to run it. The data it used in an illustration was out of date. Two tests could be combined with no loss. Change-Id: I26e619e6210ea5b1258326fc4bc2b6aee9d6a999 Reviewed-by: Lars Knoll --- util/locale_database/cldr2qlocalexml.py | 3 +++ util/locale_database/cldr2qtimezone.py | 20 ++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py index d75ef282f9b..5560d8b43fa 100755 --- a/util/locale_database/cldr2qlocalexml.py +++ b/util/locale_database/cldr2qlocalexml.py @@ -45,6 +45,9 @@ append new entries to enumdata.py's lists and update documentation in src/corelib/tools/qlocale.qdoc, adding the new entries in alphabetic order. +While updating the locale data, check also for updates to MS-Win's +time zone names; see cldr2qtimezone.py for details. + .. _CLDR: ftp://unicode.org/Public/cldr/ """ diff --git a/util/locale_database/cldr2qtimezone.py b/util/locale_database/cldr2qtimezone.py index 809a35912bd..ca202f1e2eb 100755 --- a/util/locale_database/cldr2qtimezone.py +++ b/util/locale_database/cldr2qtimezone.py @@ -38,17 +38,16 @@ use. The XML structure is as follows: - - + + - + - - - - - + + + + """ @@ -272,10 +271,7 @@ windowsZonesPath = cldrPath + "/supplemental/windowsZones.xml" tempFileDir = qtPath dataFilePath = qtPath + "/src/corelib/time/qtimezoneprivate_data_p.h" -if not os.path.isfile(windowsZonesPath): - usage() - -if not os.path.isfile(dataFilePath): +if not (os.path.isfile(windowsZonesPath) and os.path.isfile(dataFilePath)): usage() cldr_version = 'unknown' From 8bfae093ed46935a5f8e67ede92ee65a6a379405 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 28 May 2019 17:35:14 +0200 Subject: [PATCH 108/172] Add data for Windows Time-Zone IDs added in the last two years We've not run util/locale_database/cldr2qtimezone.py for a while, so CLDR has had time to add several more zones. Catch up, inserting the new entries in order. Change-Id: I8625548b0f7775958230eccbd89b897d7afed9e9 Reviewed-by: Thiago Macieira --- util/locale_database/cldr2qtimezone.py | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/util/locale_database/cldr2qtimezone.py b/util/locale_database/cldr2qtimezone.py index ca202f1e2eb..c240d0d190b 100755 --- a/util/locale_database/cldr2qtimezone.py +++ b/util/locale_database/cldr2qtimezone.py @@ -96,18 +96,23 @@ class ByteArrayData: windowsIdList = ( (u'Afghanistan Standard Time', 16200), (u'Alaskan Standard Time', -32400), + (u'Aleutian Standard Time', -36000), + (u'Altai Standard Time', 25200), (u'Arab Standard Time', 10800), (u'Arabian Standard Time', 14400), (u'Arabic Standard Time', 10800), (u'Argentina Standard Time', -10800), + (u'Astrakhan Standard Time', 14400), (u'Atlantic Standard Time', -14400), (u'AUS Central Standard Time', 34200), + (u'Aus Central W. Standard Time', 31500), (u'AUS Eastern Standard Time', 36000), (u'Azerbaijan Standard Time', 14400), (u'Azores Standard Time', -3600), (u'Bahia Standard Time', -10800), (u'Bangladesh Standard Time', 21600), (u'Belarus Standard Time', 10800), + (u'Bougainville Standard Time', 39600), (u'Canada Central Standard Time', -21600), (u'Cape Verde Standard Time', -3600), (u'Caucasus Standard Time', 14400), @@ -121,11 +126,14 @@ windowsIdList = ( (u'Central Standard Time (Mexico)', -21600), (u'Central Standard Time', -21600), (u'China Standard Time', 28800), + (u'Chatham Islands Standard Time', 45900), + (u'Cuba Standard Time', -18000), (u'Dateline Standard Time', -43200), (u'E. Africa Standard Time', 10800), (u'E. Australia Standard Time', 36000), (u'E. Europe Standard Time', 7200), (u'E. South America Standard Time', -10800), + (u'Easter Island Standard Time', -21600), (u'Eastern Standard Time', -18000), (u'Eastern Standard Time (Mexico)', -18000), (u'Egypt Standard Time', 7200), @@ -137,6 +145,7 @@ windowsIdList = ( (u'Greenland Standard Time', -10800), (u'Greenwich Standard Time', 0), (u'GTB Standard Time', 7200), + (u'Haiti Standard Time', -18000), (u'Hawaiian Standard Time', -36000), (u'India Standard Time', 19800), (u'Iran Standard Time', 12600), @@ -146,7 +155,10 @@ windowsIdList = ( (u'Korea Standard Time', 32400), (u'Libya Standard Time', 7200), (u'Line Islands Standard Time', 50400), + (u'Lord Howe Standard Time', 37800), (u'Magadan Standard Time', 36000), + (u'Magallanes Standard Time', -10800), # permanent DST + (u'Marquesas Standard Time', -34200), (u'Mauritius Standard Time', 14400), (u'Middle East Standard Time', 7200), (u'Montevideo Standard Time', -10800), @@ -159,11 +171,14 @@ windowsIdList = ( (u'Nepal Standard Time', 20700), (u'New Zealand Standard Time', 43200), (u'Newfoundland Standard Time', -12600), + (u'Norfolk Standard Time', 39600), (u'North Asia East Standard Time', 28800), (u'North Asia Standard Time', 25200), (u'North Korea Standard Time', 30600), + (u'Omsk Standard Time', 21600), (u'Pacific SA Standard Time', -10800), (u'Pacific Standard Time', -28800), + (u'Pacific Standard Time (Mexico)', -28800), (u'Pakistan Standard Time', 18000), (u'Paraguay Standard Time', -14400), (u'Romance Standard Time', 3600), @@ -174,30 +189,44 @@ windowsIdList = ( (u'SA Eastern Standard Time', -10800), (u'SA Pacific Standard Time', -18000), (u'SA Western Standard Time', -14400), + (u'Saint Pierre Standard Time', -10800), # New France + (u'Sakhalin Standard Time', 39600), (u'Samoa Standard Time', 46800), + (u'Sao Tome Standard Time', 0), + (u'Saratov Standard Time', 14400), (u'SE Asia Standard Time', 25200), (u'Singapore Standard Time', 28800), (u'South Africa Standard Time', 7200), (u'Sri Lanka Standard Time', 19800), + (u'Sudan Standard Time', 7200), # unless they mean South Sudan, +03:00 (u'Syria Standard Time', 7200), (u'Taipei Standard Time', 28800), (u'Tasmania Standard Time', 36000), + (u'Tocantins Standard Time', -10800), (u'Tokyo Standard Time', 32400), + (u'Tomsk Standard Time', 25200), (u'Tonga Standard Time', 46800), + (u'Transbaikal Standard Time', 32400), # Yakutsk (u'Turkey Standard Time', 7200), + (u'Turks And Caicos Standard Time', -14400), (u'Ulaanbaatar Standard Time', 28800), (u'US Eastern Standard Time', -18000), (u'US Mountain Standard Time', -25200), (u'UTC-11', -39600), + (u'UTC-09', -32400), + (u'UTC-08', -28800), (u'UTC-02', -7200), (u'UTC', 0), (u'UTC+12', 43200), + (u'UTC+13', 46800), (u'Venezuela Standard Time', -16200), (u'Vladivostok Standard Time', 36000), (u'W. Australia Standard Time', 28800), (u'W. Central Africa Standard Time', 3600), (u'W. Europe Standard Time', 3600), + (u'W. Mongolia Standard Time', 25200), # Hovd (u'West Asia Standard Time', 18000), + (u'West Bank Standard Time', 7200), (u'West Pacific Standard Time', 36000), (u'Yakutsk Standard Time', 32400), ) From a4f5f25eb05f49474eaef665abdbcaad9203ba48 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 5 Jun 2019 10:50:28 +0200 Subject: [PATCH 109/172] Move YearRange to QDateTime from its Private As planned when adding YearRange: now that it's merged up to dev, move it to QDateTime, since we can add to the API at 5.14.0. This follows up on commit 82ad4be4a2e0c2bccb6cd8ea2440aefee4ec48ec. Change-Id: I81b6c2331121a71e2592514781c02c5756e70c52 Reviewed-by: Thiago Macieira --- src/corelib/time/qdatetime.cpp | 23 +++++++++++++++++-- src/corelib/time/qdatetime.h | 4 ++++ src/corelib/time/qdatetime_p.h | 4 ---- src/corelib/time/qtimezoneprivate_tz.cpp | 5 ++-- .../corelib/time/qdatetime/tst_qdatetime.cpp | 10 ++++++++ 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index b3e747c5880..31206f779d3 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -386,7 +386,7 @@ static constexpr int daysInUsualMonth(int month) // (February isn't usual.) for technical reasons limited to between -784350574879 and 784354017364, which means from before 2 billion BCE to after 2 billion CE. - \sa QTime, QDateTime, QDateEdit, QDateTimeEdit, QCalendarWidget + \sa QTime, QDateTime, QDateTime::YearRange, QDateEdit, QDateTimeEdit, QCalendarWidget */ /*! @@ -3387,6 +3387,25 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT \sa QDate, QTime, QDateTimeEdit, QTimeZone */ +/*! + \enum QDateTime::YearRange + + This enumerated type describes the range of years (in the Gregorian + calendar) representable by QDateTime: + + \value First The later parts of this year are representable + \value Last The earlier parts of this year are representable + + All dates strictly between these two years are also representable. + Note, however, that the Gregorian Calendar has no year zero. + + \note QDate can describe dates in a wider range of years. For most + purposes, this makes little difference, as the range of years that QDateTime + can support reaches 292 million years either side of 1970. + + \sa isValid(), QDate +*/ + /*! Constructs a null datetime (i.e. null date and null time). A null datetime is invalid, since the date is invalid. @@ -3535,7 +3554,7 @@ bool QDateTime::isNull() const hour, i.e. if the transition is at 2am and the clock goes forward to 3am then the time from 02:00:00 to 02:59:59.999 is considered to be invalid. - \sa QDate::isValid(), QTime::isValid() + \sa QDateTime::YearRange, QDate::isValid(), QTime::isValid() */ bool QDateTime::isValid() const diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index 3e3b953b52e..89ea4ee24aa 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -384,6 +384,10 @@ public: NSDate *toNSDate() const Q_DECL_NS_RETURNS_AUTORELEASED; #endif + // (1<<63) ms is 292277024.6 (average Gregorian) years, counted from the start of 1970, so + // Last is floor(1970 + 292277024.6); no year 0, so First is floor(1970 - 1 - 292277024.6) + enum class YearRange : qint32 { First = -292275056, Last = +292278994 }; + private: friend class QDateTimePrivate; diff --git a/src/corelib/time/qdatetime_p.h b/src/corelib/time/qdatetime_p.h index 6018f8f7b01..6e4120d762f 100644 --- a/src/corelib/time/qdatetime_p.h +++ b/src/corelib/time/qdatetime_p.h @@ -140,10 +140,6 @@ public: // Inlined for its one caller in qdatetime.cpp inline void setUtcOffsetByTZ(qint64 atMSecsSinceEpoch); #endif // timezone - - // ### Qt 5.14: expose publicly in QDateTime - // The first and last years of which QDateTime can represent some part: - enum class YearRange : qint32 { First = -292275056, Last = +292278994 }; }; QT_END_NAMESPACE diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index f62d7998c8a..3c2695a7892 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -39,7 +39,6 @@ #include "qtimezone.h" #include "qtimezoneprivate_p.h" -#include "qdatetime_p.h" // ### Qt 5.14: remove once YearRange is on QDateTime #include "private/qlocale_tools_p.h" #include @@ -589,8 +588,8 @@ static QVector calculatePosixTransitions(const QByteArra stdTime = QTime(2, 0, 0); // Limit year to the range QDateTime can represent: - const int minYear = int(QDateTimePrivate::YearRange::First); - const int maxYear = int(QDateTimePrivate::YearRange::Last); + const int minYear = int(QDateTime::YearRange::First); + const int maxYear = int(QDateTime::YearRange::Last); startYear = qBound(minYear, startYear, maxYear); endYear = qBound(minYear, endYear, maxYear); Q_ASSERT(startYear <= endYear); diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index c5377379ea3..609b58cf852 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -147,6 +147,7 @@ private slots: void systemTimeZoneChange() const; void invalid() const; + void range() const; void macTypes(); @@ -3475,6 +3476,15 @@ void tst_QDateTime::invalid() const QCOMPARE(tzDate.timeSpec(), Qt::TimeZone); } +void tst_QDateTime::range() const +{ + using Bounds = std::numeric_limits; + QCOMPARE(QDateTime::fromMSecsSinceEpoch(Bounds::min() + 1, Qt::UTC).date().year(), + int(QDateTime::YearRange::First)); + QCOMPARE(QDateTime::fromMSecsSinceEpoch(Bounds::max() - 1, Qt::UTC).date().year(), + int(QDateTime::YearRange::Last)); +} + void tst_QDateTime::macTypes() { #ifndef Q_OS_MAC From 8f4baa3a223ad6f12101d5c4c10756a98d340ae6 Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Mon, 1 Jul 2019 11:16:55 +0000 Subject: [PATCH 110/172] QStringList: utilize QStringMatcher's support for QStringView This opportunity was missed when adding the QStringView overload of QStringList::filter() in 2a99f60cfbe8a10c8b64b2178573dc8da3d27abe. Change-Id: I8d679b92de6cc76c4d59fd54f01a25579ab3488f Reviewed-by: Anton Kudryavtsev Reviewed-by: Marc Mutz --- src/corelib/tools/qstringlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 3bb0e3c886c..4bbe424ed23 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -313,7 +313,7 @@ void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs) QStringList QtPrivate::QStringList_filter(const QStringList *that, QStringView str, Qt::CaseSensitivity cs) { - QStringMatcher matcher(str.data(), str.length(), cs); + QStringMatcher matcher(str, cs); QStringList res; for (int i = 0; i < that->size(); ++i) if (matcher.indexIn(that->at(i)) != -1) From b727d2f0e152243c1c46e2916dcb3c8481f03ebe Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 30 May 2019 23:44:44 +0900 Subject: [PATCH 111/172] Fix build without feature.dockwidget and tabwidget Change-Id: I621664f646475c1b5cfde47b7087c0c9f5ad8e4d Reviewed-by: Richard Moe Gustavsen --- src/plugins/styles/mac/qmacstyle_mac.mm | 7 ++++++- src/widgets/widgets/qmainwindowlayout.cpp | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 6c4605b5d2d..675f37c4c73 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -233,6 +233,7 @@ static QLinearGradient titlebarGradientInactive() return qt_mac_applicationIsInDarkMode() ? darkGradient : lightGradient; } +#if QT_CONFIG(tabwidget) static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, CGContextRef ctx) { Q_ASSERT(option); @@ -252,6 +253,7 @@ static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, CGContextClipToRects(ctx, &cgRects[0], size_t(cgRects.size())); } } +#endif static const QColor titlebarSeparatorLineActive(111, 111, 111); static const QColor titlebarSeparatorLineInactive(131, 131, 131); @@ -2949,7 +2951,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai p->restore(); return; } - +#if QT_CONFIG(tabwidget) QRegion region(tbb->rect); region -= tbb->tabBarRect; p->save(); @@ -2973,6 +2975,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai } proxy()->drawPrimitive(PE_FrameTabWidget, &twf, p, w); p->restore(); +#endif } break; #endif @@ -3019,8 +3022,10 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai needTranslation = true; } d->drawNSViewInRect(box, adjustedRect, p, ^(CGContextRef ctx, const CGRect &rect) { +#if QT_CONFIG(tabwidget) if (QTabWidget *tabWidget = qobject_cast(opt->styleObject)) clipTabBarFrame(opt, this, ctx); +#endif CGContextTranslateCTM(ctx, 0, rect.origin.y + rect.size.height); CGContextScaleCTM(ctx, 1, -1); if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSMojave diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index b8f997b7823..0e67c56afd4 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2413,7 +2413,7 @@ static bool unplugGroup(QMainWindowLayout *layout, QLayoutItem **item, */ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) { -#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar) +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) auto *groupWindow = qobject_cast(widget->parentWidget()); if (!widget->isWindow() && groupWindow) { if (group && groupWindow->tabLayoutInfo()) { @@ -2525,10 +2525,10 @@ void QMainWindowLayout::updateGapIndicator() #endif // QT_CONFIG(rubberband) } +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w) { QTabBar::Shape result = QTabBar::RoundedSouth; -#if QT_CONFIG(tabwidget) if (qobject_cast(w)) { switch (static_cast(qt_widget_private(w))->tabPosition) { case QTabWidget::North: @@ -2545,9 +2545,9 @@ static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w) break; } } -#endif // tabwidget return result; } +#endif // QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) { @@ -2591,6 +2591,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) if (!w->geometry().contains(mousePos)) continue; +#if QT_CONFIG(tabwidget) if (auto dropTo = qobject_cast(w)) { // dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two // tabs @@ -2612,6 +2613,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) w = floatingTabs; widget->raise(); // raise, as our newly created drop target is now on top } +#endif Q_ASSERT(qobject_cast(w)); auto group = static_cast(w); if (group->hover(widgetItem, group->mapFromGlobal(mousePos))) { From cee5a11bdba94fbeb48de8cffa08cfa3e85423c8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 1 Jul 2019 14:36:43 +0200 Subject: [PATCH 112/172] Fix directory separator of QMAKE_INCDIR_VULKAN Like in Qt code itself we should use forward slashes consistently. This enables the vulkan test to run on Linux for MinGW cross-compilation. Task-number: QTBUG-76660 Change-Id: Ifc6dec11bac3c3769d5d06e49da529f66f7b5843 Reviewed-by: Kai Koehne --- mkspecs/features/win32/windows_vulkan_sdk.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/win32/windows_vulkan_sdk.prf b/mkspecs/features/win32/windows_vulkan_sdk.prf index 6c08e28fe91..2aebbd3b256 100644 --- a/mkspecs/features/win32/windows_vulkan_sdk.prf +++ b/mkspecs/features/win32/windows_vulkan_sdk.prf @@ -1,7 +1,7 @@ isEmpty(QMAKE_INCDIR_VULKAN) { # Pick up the VULKAN_SDK env var set by the LunarG SDK so that the Vulkan # headers are found out-of-the-box on typical Windows setups. - QMAKE_INCDIR_VULKAN = $$(VULKAN_SDK)\\include + QMAKE_INCDIR_VULKAN = $$(VULKAN_SDK)/include # Do not export the include dir but resolve it on every qmake call. QMAKE_EXPORT_INCDIR_VULKAN = - From 377ffbd21d372193c8fa0d05dc02d6f606a78a35 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 31 May 2019 00:58:50 +0900 Subject: [PATCH 113/172] Fix build without feature.tabbar Change-Id: I0891f8f6054382407f5ce2fdb3ead0203d255945 Reviewed-by: Richard Moe Gustavsen --- src/plugins/styles/mac/qmacstyle_mac.mm | 10 ++++- src/widgets/widgets/qdockarealayout.cpp | 9 ++-- src/widgets/widgets/qdockarealayout_p.h | 4 ++ src/widgets/widgets/qdockwidget.cpp | 4 ++ src/widgets/widgets/qmainwindow.cpp | 6 +-- src/widgets/widgets/qmainwindow.h | 2 + src/widgets/widgets/qmainwindowlayout.cpp | 53 +++++++++++++---------- src/widgets/widgets/qmainwindowlayout_p.h | 8 ++-- 8 files changed, 61 insertions(+), 35 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 675f37c4c73..85bf71be3f0 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -278,6 +278,7 @@ static const qreal titleBarButtonSpacing = 8; // hovered: tab is hovered bool isDarkMode() { return qt_mac_applicationIsInDarkMode(); } +#if QT_CONFIG(tabbar) static const QColor lightTabBarTabBackgroundActive(190, 190, 190); static const QColor darkTabBarTabBackgroundActive(38, 38, 38); static const QColor tabBarTabBackgroundActive() { return isDarkMode() ? darkTabBarTabBackgroundActive : lightTabBarTabBackgroundActive; } @@ -323,6 +324,7 @@ static const QColor tabBarCloseButtonCrossSelected(115, 115, 115); static const int closeButtonSize = 14; static const qreal closeButtonCornerRadius = 2.0; +#endif // QT_CONFIG(tabbar) static const int headerSectionArrowHeight = 6; static const int headerSectionSeparatorInset = 2; @@ -467,6 +469,7 @@ static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY) } +#if QT_CONFIG(tabbar) static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pressed, bool documentMode) { p->setRenderHints(QPainter::Antialiasing); @@ -504,7 +507,6 @@ static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pres p->drawLine(margin, height - margin, width - margin, margin); } -#if QT_CONFIG(tabbar) QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect) { const auto tabDirection = QMacStylePrivate::tabDirection(shape); @@ -2131,10 +2133,12 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW int ret = 0; switch (metric) { +#if QT_CONFIG(tabbar) case PM_TabCloseIndicatorWidth: case PM_TabCloseIndicatorHeight: ret = closeButtonSize; break; +#endif case PM_ToolBarIconSize: ret = proxy()->pixelMetric(PM_LargeIconSize); break; @@ -2291,10 +2295,12 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW ret = 16; break; case QStyleHelper::SizeDefault: +#if QT_CONFIG(tabbar) const QStyleOptionTab *tb = qstyleoption_cast(opt); if (tb && tb->documentMode) ret = 30; else +#endif ret = QCommonStyle::pixelMetric(metric, opt, widget); break; } @@ -3319,6 +3325,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai } break; case PE_FrameStatusBarItem: break; +#if QT_CONFIG(tabbar) case PE_IndicatorTabClose: { // Make close button visible only on the hovered tab. QTabBar *tabBar = qobject_cast(w->parentWidget()); @@ -3343,6 +3350,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai } } } break; +#endif // QT_CONFIG(tabbar) case PE_PanelStatusBar: { // Fill the status bar with the titlebar gradient. QLinearGradient linearGrad; diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 54504d124b7..55ae42db043 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -1678,12 +1678,9 @@ int QDockAreaLayoutInfo::prev(int index) const return -1; } +#if QT_CONFIG(tabbar) void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem) { -#if !QT_CONFIG(tabbar) - Q_UNUSED(index); - Q_UNUSED(dockWidgetItem); -#else if (tabbed) { item_list.append(QDockAreaLayoutItem(dockWidgetItem)); updateTabBar(); @@ -1699,8 +1696,8 @@ void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem) new_info->updateTabBar(); new_info->setCurrentTab(dockWidgetItem->widget()); } -#endif // QT_CONFIG(tabbar) } +#endif // QT_CONFIG(tabbar) void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem) @@ -3137,6 +3134,7 @@ void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *do removePlaceHolder(dockWidget->objectName()); } +#if QT_CONFIG(tabbar) void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) { const QList path = indexOf(first); @@ -3149,6 +3147,7 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) removePlaceHolder(second->objectName()); } +#endif // QT_CONFIG(tabbar) void QDockAreaLayout::resizeDocks(const QList &docks, const QList &sizes, Qt::Orientation o) diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index ab9c0c476c9..81384bd1b73 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -144,7 +144,9 @@ public: void remove(const QList &path); void unnest(int index); void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem); +#if QT_CONFIG(tabbar) void tab(int index, QLayoutItem *dockWidgetItem); +#endif QDockAreaLayoutItem &item(const QList &path); QDockAreaLayoutInfo *info(const QList &path); QDockAreaLayoutInfo *info(QWidget *widget); @@ -275,7 +277,9 @@ public: bool restoreDockWidget(QDockWidget *dockWidget); void splitDockWidget(QDockWidget *after, QDockWidget *dockWidget, Qt::Orientation orientation); +#if QT_CONFIG(tabbar) void tabifyDockWidget(QDockWidget *first, QDockWidget *second); +#endif void resizeDocks(const QList &docks, const QList &sizes, Qt::Orientation o); void apply(bool animate); diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index dc3b77b7bce..28a7cee2a07 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -267,9 +267,11 @@ QDockWidgetLayout::~QDockWidgetLayout() bool QDockWidgetLayout::nativeWindowDeco() const { bool floating = parentWidget()->isWindow(); +#if QT_CONFIG(tabbar) if (auto groupWindow = qobject_cast(parentWidget()->parentWidget())) floating = floating || groupWindow->tabLayoutInfo(); +#endif return nativeWindowDeco(floating); } @@ -1556,8 +1558,10 @@ bool QDockWidget::event(QEvent *event) const QObjectList &siblings = win->children(); onTop = siblings.count() > 0 && siblings.last() == (QObject*)this; } +#if QT_CONFIG(tabbar) if (!isFloating() && layout != 0 && onTop) layout->raise(this); +#endif break; } case QEvent::WindowActivate: diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 9c4c46f2d60..16ed6991378 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1138,6 +1138,7 @@ void QMainWindow::splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, d_func()->layout->splitDockWidget(after, dockwidget, orientation); } +#if QT_CONFIG(tabbar) /*! \fn void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) @@ -1164,9 +1165,6 @@ void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) QList QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const { QList ret; -#if !QT_CONFIG(tabbar) - Q_UNUSED(dockwidget); -#else const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget); if (info && info->tabbed && info->tabBar) { for(int i = 0; i < info->item_list.count(); ++i) { @@ -1180,9 +1178,9 @@ QList QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) co } } } -#endif return ret; } +#endif // QT_CONFIG(tabbar) /*! diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index 85e3f87d773..c69451fa3e1 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -171,8 +171,10 @@ public: Qt::Orientation orientation); void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, Qt::Orientation orientation); +#if QT_CONFIG(tabbar) void tabifyDockWidget(QDockWidget *first, QDockWidget *second); QList tabifiedDockWidgets(QDockWidget *dockwidget) const; +#endif void removeDockWidget(QDockWidget *dockwidget); bool restoreDockWidget(QDockWidget *dockwidget); diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 0e67c56afd4..0fb3a86cf83 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -292,25 +292,31 @@ bool QDockWidgetGroupWindow::event(QEvent *e) switch (e->type()) { case QEvent::Close: +#if QT_CONFIG(tabbar) // Forward the close to the QDockWidget just as if its close button was pressed if (QDockWidget *dw = activeTabbedDockWidget()) { e->ignore(); dw->close(); adjustFlags(); } +#endif return true; case QEvent::Move: +#if QT_CONFIG(tabbar) // Let QDockWidgetPrivate::moseEvent handle the dragging if (QDockWidget *dw = activeTabbedDockWidget()) static_cast(QObjectPrivate::get(dw))->moveEvent(static_cast(e)); +#endif return true; case QEvent::NonClientAreaMouseMove: case QEvent::NonClientAreaMouseButtonPress: case QEvent::NonClientAreaMouseButtonRelease: case QEvent::NonClientAreaMouseButtonDblClick: +#if QT_CONFIG(tabbar) // Let the QDockWidgetPrivate of the currently visible dock widget handle the drag and drop if (QDockWidget *dw = activeTabbedDockWidget()) static_cast(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast(e)); +#endif return true; case QEvent::ChildAdded: if (qobject_cast(static_cast(e)->child())) @@ -347,6 +353,7 @@ QDockAreaLayoutInfo *QDockWidgetGroupWindow::layoutInfo() const return static_cast(layout())->dockAreaLayoutInfo(); } +#if QT_CONFIG(tabbar) /*! \internal If this is a floating tab bar returns the currently the QDockWidgetGroupWindow that contains tab, otherwise, return nullptr; @@ -383,7 +390,6 @@ const QDockAreaLayoutInfo *QDockWidgetGroupWindow::tabLayoutInfo() const QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const { QDockWidget *dw = nullptr; -#if QT_CONFIG(tabbar) const QDockAreaLayoutInfo *info = tabLayoutInfo(); if (!info) return nullptr; @@ -405,9 +411,9 @@ QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const dw = qobject_cast(item.widgetItem->widget()); } } -#endif return dw; } +#endif // QT_CONFIG(tabbar) /*! \internal Destroy or hide this window if there is no more QDockWidget in it. @@ -461,7 +467,11 @@ void QDockWidgetGroupWindow::adjustFlags() Qt::WindowFlags oldFlags = windowFlags(); Qt::WindowFlags flags = oldFlags; +#if QT_CONFIG(tabbar) QDockWidget *top = activeTabbedDockWidget(); +#else + QDockWidget *top = nullptr; +#endif if (!top) { // nested tabs, show window decoration flags = ((oldFlags & ~Qt::FramelessWindowHint) | Qt::CustomizeWindowHint | Qt::WindowTitleHint); @@ -507,6 +517,7 @@ void QDockWidgetGroupWindow::adjustFlags() bool QDockWidgetGroupWindow::hasNativeDecos() const { +#if QT_CONFIG(tabbar) QDockWidget *dw = activeTabbedDockWidget(); if (!dw) // We have a group of nested QDockWidgets (not just floating tabs) return true; @@ -515,6 +526,9 @@ bool QDockWidgetGroupWindow::hasNativeDecos() const return false; return dw->titleBarWidget() == nullptr; +#else + return true; +#endif } /* @@ -531,16 +545,18 @@ bool QDockWidgetGroupWindow::hover(QLayoutItem *widgetItem, const QPoint &mouseP savedState = *layoutInfo(); QMainWindow::DockOptions opts = static_cast(parentWidget())->dockOptions(); + QDockAreaLayoutInfo newState = savedState; bool nestingEnabled = (opts & QMainWindow::AllowNestedDocks) && !(opts & QMainWindow::ForceTabbedDocks); QDockAreaLayoutInfo::TabMode tabMode = +#if !QT_CONFIG(tabbar) + QDockAreaLayoutInfo::NoTabs; +#else nestingEnabled ? QDockAreaLayoutInfo::AllowTabs : QDockAreaLayoutInfo::ForceTabs; if (auto group = qobject_cast(widgetItem->widget())) { if (!group->tabLayoutInfo()) tabMode = QDockAreaLayoutInfo::NoTabs; } - - QDockAreaLayoutInfo newState = savedState; if (newState.tabbed) { // insertion into a top-level tab newState.item_list = { QDockAreaLayoutItem(new QDockAreaLayoutInfo(newState)) }; @@ -548,6 +564,7 @@ bool QDockWidgetGroupWindow::hover(QLayoutItem *widgetItem, const QPoint &mouseP newState.tabbed = false; newState.tabBar = nullptr; } +#endif auto newGapPos = newState.gapIndex(mousePos, nestingEnabled, tabMode); Q_ASSERT(!newGapPos.isEmpty()); @@ -1498,14 +1515,6 @@ void QMainWindowLayout::addDockWidget(Qt::DockWidgetArea area, invalidate(); } -void QMainWindowLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) -{ - addChildWidget(second); - layoutState.dockAreaLayout.tabifyDockWidget(first, second); - emit second->dockLocationChanged(dockWidgetArea(first)); - invalidate(); -} - bool QMainWindowLayout::restoreDockWidget(QDockWidget *dockwidget) { addChildWidget(dockwidget); @@ -1517,6 +1526,14 @@ bool QMainWindowLayout::restoreDockWidget(QDockWidget *dockwidget) } #if QT_CONFIG(tabbar) +void QMainWindowLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) +{ + addChildWidget(second); + layoutState.dockAreaLayout.tabifyDockWidget(first, second); + emit second->dockLocationChanged(dockWidgetArea(first)); + invalidate(); +} + bool QMainWindowLayout::documentMode() const { return _documentMode; @@ -1535,20 +1552,15 @@ void QMainWindowLayout::setDocumentMode(bool enabled) for (QTabBar *bar : qAsConst(unusedTabBars)) bar->setDocumentMode(_documentMode); } -#endif // QT_CONFIG(tabbar) void QMainWindowLayout::setVerticalTabsEnabled(bool enabled) { -#if !QT_CONFIG(tabbar) - Q_UNUSED(enabled); -#else if (verticalTabsEnabled == enabled) return; verticalTabsEnabled = enabled; updateTabBarShapes(); -#endif // QT_CONFIG(tabbar) } #if QT_CONFIG(tabwidget) @@ -1609,7 +1621,6 @@ static inline QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWid } #endif // QT_CONFIG(tabwidget) -#if QT_CONFIG(tabbar) void QMainWindowLayout::updateTabBarShapes() { #if QT_CONFIG(tabwidget) @@ -1851,19 +1862,17 @@ void QMainWindowLayout::tabMoved(int from, int to) info->moveTab(from, to); } -#endif // QT_CONFIG(tabbar) void QMainWindowLayout::raise(QDockWidget *widget) { -#if QT_CONFIG(tabbar) QDockAreaLayoutInfo *info = dockInfo(widget); if (info == 0) return; if (!info->tabbed) return; info->setCurrentTab(widget); -#endif } +#endif // QT_CONFIG(tabbar) #endif // QT_CONFIG(dockwidget) @@ -2329,7 +2338,7 @@ void QMainWindowLayout::setDockOptions(QMainWindow::DockOptions opts) dockOptions = opts; -#if QT_CONFIG(dockwidget) +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar) setVerticalTabsEnabled(opts & QMainWindow::VerticalTabs); #endif diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 7cdb8ead2fd..967b7130968 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -337,8 +337,10 @@ public: explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr) : QWidget(parent, f) {} QDockAreaLayoutInfo *layoutInfo() const; +#if QT_CONFIG(tabbar) const QDockAreaLayoutInfo *tabLayoutInfo() const; QDockWidget *activeTabbedDockWidget() const; +#endif void destroyOrHideIfEmpty(); void adjustFlags(); bool hasNativeDecos() const; @@ -494,13 +496,13 @@ public: void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, Qt::Orientation orientation); - void tabifyDockWidget(QDockWidget *first, QDockWidget *second); Qt::DockWidgetArea dockWidgetArea(QWidget* widget) const; + bool restoreDockWidget(QDockWidget *dockwidget); +#if QT_CONFIG(tabbar) + void tabifyDockWidget(QDockWidget *first, QDockWidget *second); void raise(QDockWidget *widget); void setVerticalTabsEnabled(bool enabled); - bool restoreDockWidget(QDockWidget *dockwidget); -#if QT_CONFIG(tabbar) QDockAreaLayoutInfo *dockInfo(QWidget *w); bool _documentMode; bool documentMode() const; From fdef9c80391c23875208d8576096c0d5366fedc4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 27 Jun 2019 15:07:01 +0200 Subject: [PATCH 114/172] uic: Implement form window setting to disable QObject::connectSlotsByName() Task-number: QTBUG-76375 Change-Id: I16ad147366aa7d52b7a0e17ae240127d8ac34b3c Reviewed-by: Jarek Kobus --- src/tools/uic/cpp/cppwriteinitialization.cpp | 5 ++++- src/tools/uic/cpp/cppwriteinitialization.h | 1 + src/tools/uic/ui4.cpp | 7 +++++++ src/tools/uic/ui4.h | 8 ++++++++ tests/auto/tools/uic/baseline/dialog.ui | 2 +- tests/auto/tools/uic/baseline/dialog.ui.h | 2 -- 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 4185d3ba703..d16c859eedf 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -467,6 +467,9 @@ void WriteInitialization::acceptUI(DomUI *node) m_widgetChain.push(nullptr); m_layoutChain.push(nullptr); + if (node->hasAttributeConnectslotsbyname()) + m_connectSlotsByName = node->attributeConnectslotsbyname(); + acceptLayoutDefault(node->elementLayoutDefault()); acceptLayoutFunction(node->elementLayoutFunction()); @@ -536,7 +539,7 @@ void WriteInitialization::acceptUI(DomUI *node) if (!m_delayedInitialization.isEmpty()) m_output << "\n" << m_delayedInitialization << "\n"; - if (m_option.autoConnection) { + if (m_option.autoConnection && m_connectSlotsByName) { m_output << "\n" << m_indent << "QMetaObject" << language::qualifier << "connectSlotsByName(" << varName << ')' << language::eol; } diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index a28dfc1b25f..6f8e352f6af 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -311,6 +311,7 @@ private: bool m_layoutWidget = false; bool m_firstThemeIcon = true; + bool m_connectSlotsByName = true; }; } // namespace CPP diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 984ef36274b..334ced276db 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -76,6 +76,10 @@ void DomUI::read(QXmlStreamReader &reader) setAttributeIdbasedtr(attribute.value() == QLatin1String("true")); continue; } + if (name == QLatin1String("connectslotsbyname")) { + setAttributeConnectslotsbyname(attribute.value() == QLatin1String("true")); + continue; + } if (name == QLatin1String("stdsetdef")) { setAttributeStdsetdef(attribute.value().toInt()); continue; @@ -209,6 +213,9 @@ void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeIdbasedtr()) writer.writeAttribute(QStringLiteral("idbasedtr"), (attributeIdbasedtr() ? QLatin1String("true") : QLatin1String("false"))); + if (hasAttributeConnectslotsbyname()) + writer.writeAttribute(QStringLiteral("connectslotsbyname"), (attributeConnectslotsbyname() ? QLatin1String("true") : QLatin1String("false"))); + if (hasAttributeStdsetdef()) writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdsetdef())); diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index 17101473426..08a3abf4909 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -169,6 +169,11 @@ public: inline void setAttributeIdbasedtr(bool a) { m_attr_idbasedtr = a; m_has_attr_idbasedtr = true; } inline void clearAttributeIdbasedtr() { m_has_attr_idbasedtr = false; } + inline bool hasAttributeConnectslotsbyname() const { return m_has_attr_connectslotsbyname; } + inline bool attributeConnectslotsbyname() const { return m_attr_connectslotsbyname; } + inline void setAttributeConnectslotsbyname(bool a) { m_attr_connectslotsbyname = a; m_has_attr_connectslotsbyname = true; } + inline void clearAttributeConnectslotsbyname() { m_has_attr_connectslotsbyname = false; } + inline bool hasAttributeStdsetdef() const { return m_has_attr_stdsetdef; } inline int attributeStdsetdef() const { return m_attr_stdsetdef; } inline void setAttributeStdsetdef(int a) { m_attr_stdsetdef = a; m_has_attr_stdsetdef = true; } @@ -285,6 +290,9 @@ private: bool m_attr_idbasedtr = false; bool m_has_attr_idbasedtr = false; + bool m_attr_connectslotsbyname = false; + bool m_has_attr_connectslotsbyname = false; + int m_attr_stdsetdef = 0; bool m_has_attr_stdsetdef = false; diff --git a/tests/auto/tools/uic/baseline/dialog.ui b/tests/auto/tools/uic/baseline/dialog.ui index e99d6fb3c42..936cc2eee88 100644 --- a/tests/auto/tools/uic/baseline/dialog.ui +++ b/tests/auto/tools/uic/baseline/dialog.ui @@ -1,4 +1,4 @@ - + Dialog diff --git a/tests/auto/tools/uic/baseline/dialog.ui.h b/tests/auto/tools/uic/baseline/dialog.ui.h index aeed71d058d..cd6449873e1 100644 --- a/tests/auto/tools/uic/baseline/dialog.ui.h +++ b/tests/auto/tools/uic/baseline/dialog.ui.h @@ -52,8 +52,6 @@ public: retranslateUi(Dialog); - - QMetaObject::connectSlotsByName(Dialog); } // setupUi void retranslateUi(QDialog *Dialog) From c34242c679aaea6ee1badf6c1e5f274f925f5f50 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 1 Jul 2019 14:10:43 +0200 Subject: [PATCH 115/172] Make the default ctor of QVarLengthArray implicit Otherwise "QVarLengthArray x = {};" gives a warning. Also, some compilers get confused about "QVarLengthArray()" this way. Task-number: QTBUG-76199 Change-Id: I4296586c0181d3e6e82ca8b7b79aeb9a21645d1f Reviewed-by: Marc Mutz --- src/corelib/tools/qvarlengtharray.h | 4 +++- .../corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index a49e0af687a..ba65ae7ef2b 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -61,7 +61,9 @@ template class QVarLengthArray { public: - inline explicit QVarLengthArray(int size = 0); + QVarLengthArray() : QVarLengthArray(0) {} + + inline explicit QVarLengthArray(int size); inline QVarLengthArray(const QVarLengthArray &other) : a(Prealloc), s(0), ptr(reinterpret_cast(array)) diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index fff8c75a902..070c25368b3 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -57,6 +57,7 @@ private slots: void initializeListComplex(); void insertMove(); void nonCopyable(); + void implicitDefaultCtor(); private: template @@ -1078,5 +1079,11 @@ void tst_QVarLengthArray::nonCopyable() QVERIFY(ptr6 == vec.at(5).get()); } +void tst_QVarLengthArray::implicitDefaultCtor() +{ + QVarLengthArray def = {}; + QCOMPARE(def.size(), 0); +} + QTEST_APPLESS_MAIN(tst_QVarLengthArray) #include "tst_qvarlengtharray.moc" From 8c8eae279d57ff73b69620f5710b8290d6268051 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 26 Jun 2019 12:48:21 +0200 Subject: [PATCH 116/172] Remove usages of deprecated APIs from QDateTime - Replaced the usages of: * QDateTime::toTime_t() -> QDateTime::toSecsSinceEpoch(). * QDateTime::fromTime_t() -> QDateTime::fromSecsSinceEpoch(). * QDate::shortDayName() -> QLocale::system().dayName(). * QTime by QElapsedTimer, where the deprecated methods of QTime were used. - Modified the tests for the deprecated methods to be enabled only when the corresponding methods are enabled: when the deprecated APIs are disabled, the tests will be also disabled, and the compilation won't be broken. Task-number: QTBUG-76491 Change-Id: I4d565db2329e580c567aae511696eb1efe120843 Reviewed-by: Volker Hilsheimer --- .../textblock-fragments/mainwindow.cpp | 2 +- .../textdocument-blocks/mainwindow.cpp | 2 +- .../corelib/io/qfileinfo/tst_qfileinfo.cpp | 2 +- tests/auto/corelib/time/qdate/tst_qdate.cpp | 4 +-- .../corelib/time/qdatetime/tst_qdatetime.cpp | 36 +++++++++++++++++-- .../tools/qalgorithms/tst_qalgorithms.cpp | 2 +- .../qdatetimeedit/tst_qdatetimeedit.cpp | 2 +- 7 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/gui/doc/snippets/textblock-fragments/mainwindow.cpp b/src/gui/doc/snippets/textblock-fragments/mainwindow.cpp index bf864ce48df..236d6952e62 100644 --- a/src/gui/doc/snippets/textblock-fragments/mainwindow.cpp +++ b/src/gui/doc/snippets/textblock-fragments/mainwindow.cpp @@ -114,7 +114,7 @@ void MainWindow::insertCalendar() int year = date.year(), month = date.month(); for (int weekDay = 1; weekDay <= 7; ++weekDay) { - cursor.insertText(QString("%1 ").arg(QDate::shortDayName(weekDay), 3), + cursor.insertText(QString("%1 ").arg(QLocale::system().dayName(weekDay), 3), boldFormat); } diff --git a/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp b/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp index a5801da67e8..849f0e957f2 100644 --- a/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp +++ b/src/gui/doc/snippets/textdocument-blocks/mainwindow.cpp @@ -117,7 +117,7 @@ void MainWindow::insertCalendar() int year = date.year(), month = date.month(); for (int weekDay = 1; weekDay <= 7; ++weekDay) { - cursor.insertText(QString("%1 ").arg(QDate::shortDayName(weekDay), 3), + cursor.insertText(QString("%1 ").arg(QLocale::system().dayName(weekDay), 3), boldFormat); } diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 0944ec252e1..16e81cdd773 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1261,7 +1261,7 @@ void tst_QFileInfo::fakeFileTimes_data() QTest::newRow("early") << QDateTime(QDate(1901, 12, 14), QTime(12, 0)); // QTBUG-12006 claims XP handled this (2010-Mar-26 8:46:10) wrong due to an MS API bug: - QTest::newRow("XP-bug") << QDateTime::fromTime_t(1269593170); + QTest::newRow("XP-bug") << QDateTime::fromSecsSinceEpoch(1269593170); } void tst_QFileInfo::fakeFileTimes() diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 0ef494b229f..73384c35f46 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -91,7 +91,7 @@ private slots: void negativeYear() const; void printNegativeYear() const; void roundtripGermanLocale() const; -#if QT_CONFIG(textdate) +#if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10) void shortDayName() const; void standaloneShortDayName() const; void longDayName() const; @@ -1473,7 +1473,7 @@ void tst_QDate::roundtripGermanLocale() const theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate); } -#if QT_CONFIG(textdate) +#if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10) QT_WARNING_PUSH // the methods tested here are all deprecated QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index 609b58cf852..ac1b903aa19 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -61,6 +61,10 @@ private slots: void timeSpec(); void toSecsSinceEpoch_data(); void toSecsSinceEpoch(); +#if QT_DEPRECATED_SINCE(5, 8) + void toTime_t_data(); + void toTime_t(); +#endif void daylightSavingsTimeChange_data(); void daylightSavingsTimeChange(); void springForward_data(); @@ -1690,6 +1694,34 @@ void tst_QDateTime::toSecsSinceEpoch() QDateTime datetime = dt( dateTimeStr ); qint64 asSecsSinceEpoch = datetime.toSecsSinceEpoch(); + QCOMPARE(asSecsSinceEpoch, datetime.toMSecsSinceEpoch() / 1000); + + QDateTime datetime2 = QDateTime::fromSecsSinceEpoch(asSecsSinceEpoch); + QCOMPARE(datetime, datetime2); +} + +#if QT_DEPRECATED_SINCE(5, 8) +void tst_QDateTime::toTime_t_data() +{ + QTest::addColumn("dateTimeStr"); + QTest::addColumn("res"); + + QTest::newRow( "data1" ) << str( 1800, 1, 1, 12, 0, 0 ) << false; + QTest::newRow( "data2" ) << str( 1969, 1, 1, 12, 0, 0 ) << false; + QTest::newRow( "data3" ) << str( 2002, 1, 1, 12, 0, 0 ) << true; + QTest::newRow( "data4" ) << str( 2002, 6, 1, 12, 0, 0 ) << true; + QTest::newRow( "data5" ) << QString("INVALID") << false; + QTest::newRow( "data6" ) << str( 2038, 1, 1, 12, 0, 0 ) << true; + QTest::newRow( "data7" ) << str( 2063, 4, 5, 12, 0, 0 ) << true; // the day of First Contact + QTest::newRow( "data8" ) << str( 2107, 1, 1, 12, 0, 0 ) + << bool( sizeof(uint) > 32 && sizeof(time_t) > 32 ); +} + +void tst_QDateTime::toTime_t() +{ + QFETCH( QString, dateTimeStr ); + QDateTime datetime = dt( dateTimeStr ); + uint asTime_t = datetime.toTime_t(); QFETCH( bool, res ); if (res) { @@ -1697,15 +1729,13 @@ void tst_QDateTime::toSecsSinceEpoch() } else { QVERIFY( asTime_t == (uint)-1 ); } - QCOMPARE(asSecsSinceEpoch, datetime.toMSecsSinceEpoch() / 1000); if ( asTime_t != (uint) -1 ) { QDateTime datetime2 = QDateTime::fromTime_t( asTime_t ); QCOMPARE(datetime, datetime2); } - QDateTime datetime2 = QDateTime::fromSecsSinceEpoch(asSecsSinceEpoch); - QCOMPARE(datetime, datetime2); } +#endif void tst_QDateTime::daylightSavingsTimeChange_data() { diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 06db0e85468..d1bf63bf8af 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -172,7 +172,7 @@ ResultSet testRun(ContainerType &container, Algorithm &algorithm, int millisecs) { TestInt::lessThanRefCount = 0; int count = 0; - QTime t; + QElapsedTimer t; t.start(); while(t.elapsed() < millisecs) { ++count; diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index c6f6900def4..cd045e476cf 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -3454,7 +3454,7 @@ void tst_QDateTimeEdit::timeSpec() } QVERIFY(edit.minimumTime() != min.time()); QVERIFY(edit.minimumDateTime().timeSpec() != min.timeSpec()); - QCOMPARE(edit.minimumDateTime().toTime_t(), min.toTime_t()); + QCOMPARE(edit.minimumDateTime().toSecsSinceEpoch(), min.toSecsSinceEpoch()); } else { QSKIP("Not tested in the GMT timezone"); } From 6df8a30333e681066e25a850ca12576d523db6b3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 1 Jul 2019 14:37:58 +0200 Subject: [PATCH 117/172] tst_QShortcut: Brush up the code, preparing the extraction of a base class to QtGui - Use nullptr - Fix static method invocations - Use QString() instead of QString("") - Use override - Use member initialization - Remove unimplemented code related to status bars - Use Qt 5 connection syntax - Fix apparent oversights in ambiguousItems() and unicodeCompare(),where the 2nd shortcut was assigned to the wrong button - Use Q_ENUM for the enumerations which will output the value in QCOMPARE and automatically declare them to be a metatype - Use enums in helper function signature for clarity Task-number: QTBUG-76493 Change-Id: I0ed6ee7ee8dc2dbb48160a8383e6ed29164c3449 Reviewed-by: Frederik Gladhorn --- .../kernel/qshortcut/tst_qshortcut.cpp | 411 ++++++++---------- 1 file changed, 182 insertions(+), 229 deletions(-) diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index 2c9295d995c..d86236bea53 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -41,7 +41,6 @@ #include #include -class AccelForm; QT_BEGIN_NAMESPACE class QMainWindow; class QTextEdit; @@ -59,7 +58,8 @@ public: SetupAccel, TestAccel, ClearAll - } currentAction; + }; + Q_ENUM(Action) enum Widget { NoWidget, @@ -72,6 +72,7 @@ public: TriggerSlot7, SendKeyEvent }; + Q_ENUM(Widget) enum Result { NoResult, @@ -85,6 +86,7 @@ public: SentKeyEvent, Ambiguous } currentResult; + Q_ENUM(Result) public slots: void slotTrig1() { currentResult = Slot1Triggered; } @@ -101,7 +103,6 @@ public slots: void ambigSlot5() { currentResult = Ambiguous; ambigResult = Slot5Triggered; } void ambigSlot6() { currentResult = Ambiguous; ambigResult = Slot6Triggered; } void ambigSlot7() { currentResult = Ambiguous; ambigResult = Slot7Triggered; } - void statusMessage( const QString& message ) { sbText = message; } void shortcutDestroyed(QObject* obj); void sendKeyEvent() { sendKeyEvents(edit, Qt::CTRL + Qt::Key_B, 0); currentResult = SentKeyEvent; } @@ -129,11 +130,11 @@ protected: void defElements(); void clearAllShortcuts(); - QShortcut *setupShortcut(int testWidget, const QKeySequence &ks); - QShortcut *setupShortcut(int testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0); + QShortcut *setupShortcut(Widget testWidget, const QKeySequence &ks); + QShortcut *setupShortcut(Widget testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0); - QShortcut *setupShortcut(QWidget *parent, const char *name, int testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0); - QShortcut *setupShortcut(QWidget *parent, const char *name, int testWidget, const QKeySequence &ks, Qt::ShortcutContext context = Qt::WindowShortcut); + QShortcut *setupShortcut(QWidget *parent, const char *name, Widget testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0); + QShortcut *setupShortcut(QWidget *parent, const char *name, Widget testWidget, const QKeySequence &ks, Qt::ShortcutContext context = Qt::WindowShortcut); void sendKeyEvents(QWidget *w, int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0); void sendKeyEvents(int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0); @@ -143,14 +144,9 @@ protected: QMainWindow *mainW; QList shortcuts; QTextEdit *edit; - QString sbText; Result ambigResult; }; -Q_DECLARE_METATYPE(tst_QShortcut::Widget); -Q_DECLARE_METATYPE(tst_QShortcut::Result); -Q_DECLARE_METATYPE(tst_QShortcut::Action); - class TestEdit : public QTextEdit { Q_OBJECT @@ -162,7 +158,8 @@ public: } protected: - bool event(QEvent *e) { + bool event(QEvent *e) override + { // Make testedit allow any Ctrl+Key as shortcut if (e->type() == QEvent::ShortcutOverride) { QKeyEvent *ke = static_cast(e); @@ -195,7 +192,7 @@ protected: } }; -tst_QShortcut::tst_QShortcut(): mainW( 0 ) +tst_QShortcut::tst_QShortcut(): mainW( nullptr ) { } @@ -207,7 +204,7 @@ tst_QShortcut::~tst_QShortcut() void tst_QShortcut::initTestCase() { currentResult = NoResult; - mainW = new QMainWindow(0); + mainW = new QMainWindow(nullptr); mainW->setWindowFlags(Qt::X11BypassWindowManagerHint); edit = new TestEdit(mainW, "test_edit"); mainW->setFixedSize( 200, 200 ); @@ -215,8 +212,6 @@ void tst_QShortcut::initTestCase() mainW->show(); mainW->activateWindow(); QVERIFY(QTest::qWaitForWindowActive(mainW)); - connect( mainW->statusBar(), SIGNAL(messageChanged(QString)), - this, SLOT(statusMessage(QString)) ); } void tst_QShortcut::cleanupTestCase() @@ -276,7 +271,7 @@ void tst_QShortcut::number_data() defElements(); // Clear all - QTest::newRow("N00 - clear") << ClearAll << NoWidget <setKey(QKeySequence("Ctrl+K, Ctrl+L")); - cut4->setKey(QKeySequence("Ctrl+K, Ctrl+M")); - - cut1->setEnabled(true); - cut4->setEnabled(false); - - currentResult = NoResult; - sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 ); - sendKeyEvents( Qt::CTRL+Qt::Key_Q, 0 ); - QCOMPARE( currentResult, NoResult ); - if (over_330) - QCOMPARE( sbText, QString("Ctrl+K, Ctrl+Q not defined") ); - - currentResult = NoResult; - sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 ); - sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 ); - QCOMPARE( currentResult, NoResult ); - if (over_330) - QCOMPARE( sbText, QString() ); - - currentResult = NoResult; - sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 ); - sendKeyEvents( Qt::CTRL+Qt::Key_L, 0 ); - QCOMPARE( currentResult, Slot1Triggered ); - if (over_330) - QCOMPARE( sbText, QString() ); -#endif clearAllShortcuts(); - cut1 = 0; - cut4 = 0; } // ------------------------------------------------------------------ // Ambiguous Elements ----------------------------------------------- @@ -854,10 +814,6 @@ void tst_QShortcut::ambiguousRotation() QCOMPARE(ambigResult, Slot7Triggered); clearAllShortcuts(); - cut1 = 0; cut2 = 0; - cut3 = 0; cut4 = 0; - cut5 = 0; cut6 = 0; - cut7 = 0; } void tst_QShortcut::ambiguousItems() @@ -877,7 +833,7 @@ void tst_QShortcut::ambiguousItems() pb2.show(); setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M"); - setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, "M"); + setupShortcut(&pb2, "shortcut2-pb2", TriggerSlot2, "M"); currentResult = NoResult; sendKeyEvents( Qt::Key_M, 'm' ); @@ -918,7 +874,7 @@ void tst_QShortcut::unicodeCompare() QKeySequence ks1("Ctrl+M"); // Unicode QKeySequence ks2(Qt::CTRL+Qt::Key_M); // non-Unicode setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, ks1); - setupShortcut(&pb1, "shortcut2-pb2", TriggerSlot2, ks2); + setupShortcut(&pb2, "shortcut2-pb2", TriggerSlot2, ks2); currentResult = NoResult; sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 ); @@ -948,13 +904,13 @@ void tst_QShortcut::keypressConsumption() sendKeyEvents(edit, Qt::CTRL + Qt::Key_I, 0); // Send key to edit QCOMPARE( currentResult, NoResult ); QCOMPARE( ambigResult, NoResult ); - QCOMPARE(edit->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); // Make sure next keypress is eaten (failing multiple keysequence) sendKeyEvents(edit, Qt::Key_C, 'c'); // Send key to edit QCOMPARE( currentResult, NoResult ); QCOMPARE( ambigResult, NoResult ); - QCOMPARE(edit->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); // Next keypress should be normal sendKeyEvents(edit, Qt::Key_C, 'c'); // Send key to edit @@ -995,7 +951,7 @@ void tst_QShortcut::keypressConsumption() sendKeyEvents(edit, Qt::CTRL + Qt::Key_A, 0); QCOMPARE(currentResult, SentKeyEvent); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString(QString(""))); + QCOMPARE(edit->toPlainText(), QLatin1String("")); } // ------------------------------------------------------------------ @@ -1006,9 +962,9 @@ void tst_QShortcut::context() clearAllShortcuts(); QWidget myBox; - TestEdit *other1 = new TestEdit(&myBox, "test_edit_other1"); - TestEdit *other2 = new TestEdit(&myBox, "test_edit_other2"); - QHBoxLayout *layout = new QHBoxLayout(&myBox); + auto other1 = new TestEdit(&myBox, "test_edit_other1"); + auto other2 = new TestEdit(&myBox, "test_edit_other2"); + auto layout = new QHBoxLayout(&myBox); layout->addWidget(other1); layout->addWidget(other2); myBox.show(); @@ -1033,8 +989,8 @@ void tst_QShortcut::context() // Focus on 'other1' edit, so Active Window context should trigger other1->activateWindow(); // <--- QApplication::setActiveWindow(other1); - QCOMPARE(qApp->activeWindow(), other1->window()); - QCOMPARE(qApp->focusWidget(), (QWidget *)other1); + QCOMPARE(QApplication::activeWindow(), other1->window()); + QCOMPARE(QApplication::focusWidget(), static_cast(other1)); currentResult = NoResult; ambigResult = NoResult; @@ -1042,13 +998,13 @@ void tst_QShortcut::context() other1->clear(); other2->clear(); - QCOMPARE(qApp->focusWidget(), (QWidget *)other1); + QCOMPARE(QApplication::focusWidget(), static_cast(other1)); sendKeyEvents(other1, Qt::ALT+Qt::Key_1); QCOMPARE(currentResult, Slot1Triggered); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString("")); - QCOMPARE(other1->toPlainText(), QString("")); - QCOMPARE(other2->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); + QCOMPARE(other1->toPlainText(), QString()); + QCOMPARE(other2->toPlainText(), QString()); // ..but not Focus context on 'other2'.. currentResult = NoResult; @@ -1060,9 +1016,9 @@ void tst_QShortcut::context() sendKeyEvents(other1, Qt::ALT+Qt::Key_2); QCOMPARE(currentResult, NoResult); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); QCOMPARE(other1->toPlainText(), QString("")); - QCOMPARE(other2->toPlainText(), QString("")); + QCOMPARE(other2->toPlainText(), QString()); // ..however, application global context on 'edit' should.. currentResult = NoResult; @@ -1074,15 +1030,15 @@ void tst_QShortcut::context() sendKeyEvents(other1, Qt::ALT+Qt::Key_3); QCOMPARE(currentResult, Slot3Triggered); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString("")); - QCOMPARE(other1->toPlainText(), QString("")); - QCOMPARE(other2->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); + QCOMPARE(other1->toPlainText(), QString()); + QCOMPARE(other2->toPlainText(), QString()); // Changing focus to 'other2' should make the Focus context there work other2->activateWindow(); other2->setFocus(); // ### - QTRY_COMPARE(qApp->activeWindow(), other2->window()); - QCOMPARE(qApp->focusWidget(), (QWidget *)other2); + QTRY_COMPARE(QApplication::activeWindow(), other2->window()); + QCOMPARE(QApplication::focusWidget(), static_cast(other2)); currentResult = NoResult; ambigResult = NoResult; @@ -1093,9 +1049,9 @@ void tst_QShortcut::context() sendKeyEvents(other2, Qt::ALT+Qt::Key_2); QCOMPARE(currentResult, Slot2Triggered); QCOMPARE(ambigResult, NoResult); - QCOMPARE(edit->toPlainText(), QString("")); - QCOMPARE(other1->toPlainText(), QString("")); - QCOMPARE(other2->toPlainText(), QString("")); + QCOMPARE(edit->toPlainText(), QString()); + QCOMPARE(other1->toPlainText(), QString()); + QCOMPARE(other2->toPlainText(), QString()); clearAllShortcuts(); } @@ -1104,9 +1060,9 @@ void tst_QShortcut::context() class OverrideCountingWidget : public QWidget { public: - OverrideCountingWidget(QWidget *parent = 0) : QWidget(parent), overrideCount(0) {} + using QWidget::QWidget; - int overrideCount; + int overrideCount = 0; bool event(QEvent *e) override { @@ -1140,70 +1096,67 @@ void tst_QShortcut::clearAllShortcuts() shortcuts.clear(); } -QShortcut *tst_QShortcut::setupShortcut(int testWidget, const QKeySequence &ks) +QShortcut *tst_QShortcut::setupShortcut(Widget testWidget, const QKeySequence &ks) { return setupShortcut(mainW, QTest::currentDataTag() ? QTest::currentDataTag() : "", testWidget, ks); } -QShortcut *tst_QShortcut::setupShortcut(int testWidget, const QString &txt, int k1, int k2, int k3, int k4) +QShortcut *tst_QShortcut::setupShortcut(Widget testWidget, const QString &txt, int k1, int k2, int k3, int k4) { return setupShortcut(mainW, QTest::currentDataTag() ? QTest::currentDataTag() : "", testWidget, (txt.isEmpty() ? QKeySequence(k1, k2, k3, k4) : QKeySequence(txt))); } -QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, int testWidget, const QString &txt, int k1, int k2, int k3, int k4) +QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, Widget testWidget, const QString &txt, int k1, int k2, int k3, int k4) { return setupShortcut(parent, name, testWidget, (txt.isEmpty() ? QKeySequence(k1, k2, k3, k4) : QKeySequence(txt))); } -QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, int testWidget, +QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, Widget testWidget, const QKeySequence &ks, Qt::ShortcutContext context) { // Set up shortcut for next test - QShortcut *cut = new QShortcut(QKeySequence(), parent, 0, 0, context); + auto cut = new QShortcut(ks, parent, nullptr, nullptr, context); cut->setObjectName(name); - cut->setKey(ks); - const char *normal = 0; - const char *ambig = 0; switch(testWidget) { case TriggerSlot1: - normal = SLOT(slotTrig1()); - ambig = SLOT(ambigSlot1()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig1); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot1); break; case TriggerSlot2: - normal = SLOT(slotTrig2()); - ambig = SLOT(ambigSlot2()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig2); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot2); break; case TriggerSlot3: - normal = SLOT(slotTrig3()); - ambig = SLOT(ambigSlot3()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig3); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot3); break; case TriggerSlot4: - normal = SLOT(slotTrig4()); - ambig = SLOT(ambigSlot4()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig4); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot4); break; case TriggerSlot5: - normal = SLOT(slotTrig5()); - ambig = SLOT(ambigSlot5()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig5); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot5); break; case TriggerSlot6: - normal = SLOT(slotTrig6()); - ambig = SLOT(ambigSlot6()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig6); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot6); break; case TriggerSlot7: - normal = SLOT(slotTrig7()); - ambig = SLOT(ambigSlot7()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig7); + connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot7); break; case SendKeyEvent: - normal = SLOT(sendKeyEvent()); + connect(cut, &QShortcut::activated, this, &tst_QShortcut::sendKeyEvent); + break; + case NoWidget: + break; } - connect(cut, SIGNAL(activated()), this, normal); - if (ambig) - connect(cut, SIGNAL(activatedAmbiguously()), this, ambig); - connect(cut, SIGNAL(destroyed(QObject*)), this, SLOT(shortcutDestroyed(QObject*))); + connect(cut, &QObject::destroyed, this, &tst_QShortcut::shortcutDestroyed); shortcuts.append(cut); return cut; } @@ -1278,7 +1231,7 @@ void tst_QShortcut::testElement() setupShortcut(testWidget, txt, k1, k2, k3, k4); } else { sendKeyEvents(k1, c1, k2, c2, k3, c3, k4, c4); - QCOMPARE((int)currentResult, (int)result); + QCOMPARE(currentResult, result); } } From d5f65d8814e85611f8eff85c6a7d64813c08206d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 21 Jun 2019 12:36:49 +0200 Subject: [PATCH 118/172] Remove hook handling code from QEventDispatcherWin32 Since commit 6a7cea64 qt_GetMessageHook is effectively a no-op, and we can remove the complete hook handling code. Change-Id: I90383c0c09c2b0f1d715872de5f9519a879d9bae Reviewed-by: Alex Trotsenko Reviewed-by: Oliver Wolff --- src/corelib/kernel/qeventdispatcher_win.cpp | 43 +------------------ src/corelib/kernel/qeventdispatcher_win_p.h | 4 -- .../direct2d/qwindowsdirect2dintegration.cpp | 1 - 3 files changed, 1 insertion(+), 47 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index dea6cf6389c..c15d740f9e8 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -100,7 +100,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA QEventDispatcherWin32Private::QEventDispatcherWin32Private() : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), - getMessageHook(0), wakeUps(0), activateNotifiersPosted(false), + wakeUps(0), activateNotifiersPosted(false), winEventNotifierActivatedEvent(NULL) { } @@ -269,14 +269,6 @@ static inline UINT inputTimerMask() return result; } -LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp) -{ - QEventDispatcherWin32 *q = qobject_cast(QAbstractEventDispatcher::instance()); - Q_ASSERT(q != 0); - - return q->d_func()->getMessageHook ? CallNextHookEx(0, code, wp, lp) : 0; -} - // Provide class name and atom for the message window used by // QEventDispatcherWin32Private via Q_GLOBAL_STATIC shared between threads. struct QWindowsMessageWindowClassContext @@ -455,38 +447,11 @@ void QEventDispatcherWin32::createInternalHwnd() return; d->internalHwnd = qt_create_internal_window(this); - installMessageHook(); - // start all normal timers for (int i = 0; i < d->timerVec.count(); ++i) d->registerTimer(d->timerVec.at(i)); } -void QEventDispatcherWin32::installMessageHook() -{ - Q_D(QEventDispatcherWin32); - - if (d->getMessageHook) - return; - - // setup GetMessage hook needed to drive our posted events - d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId()); - if (Q_UNLIKELY(!d->getMessageHook)) { - int errorCode = GetLastError(); - qFatal("Qt: INTERNAL ERROR: failed to install GetMessage hook: %d, %ls", - errorCode, qUtf16Printable(qt_error_string(errorCode))); - } -} - -void QEventDispatcherWin32::uninstallMessageHook() -{ - Q_D(QEventDispatcherWin32); - - if (d->getMessageHook) - UnhookWindowsHookEx(d->getMessageHook); - d->getMessageHook = 0; -} - QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent) : QAbstractEventDispatcher(*new QEventDispatcherWin32Private, parent) { @@ -582,10 +547,6 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } } if (haveMessage) { - // The Direct2d integration unsets getMessageHook. See QTBUG-42428 - if (!d->getMessageHook) - (void) qt_GetMessageHook(0, PM_REMOVE, reinterpret_cast(&msg)); - if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) { // Set result to 'true', if the message was sent by wakeUp(). if (msg.wParam == WMWP_QT_FROMWAKEUP) { @@ -1043,8 +1004,6 @@ void QEventDispatcherWin32::closingDown() d->timerDict.clear(); d->closingDown = true; - - uninstallMessageHook(); } bool QEventDispatcherWin32::event(QEvent *e) diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index f672530ff80..697c07f9127 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -73,8 +73,6 @@ class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher protected: void createInternalHwnd(); - void installMessageHook(); - void uninstallMessageHook(); public: explicit QEventDispatcherWin32(QObject *parent = 0); @@ -115,7 +113,6 @@ protected: private: friend LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp); - friend LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int, WPARAM, LPARAM); }; struct QSockNot { @@ -169,7 +166,6 @@ public: // internal window handle used for socketnotifiers/timers/etc HWND internalHwnd; - HHOOK getMessageHook; // for controlling when to send posted events QAtomicInt wakeUps; diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp index 0cf05cb0acf..e637bd13fd3 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp @@ -63,7 +63,6 @@ public: QWindowsDirect2DEventDispatcher(QObject *parent = nullptr) : QWindowsGuiEventDispatcher(parent) { - uninstallMessageHook(); // ### Workaround for QTBUG-42428 } }; From 5342805920064dfe64c23690cd1d895a95478154 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 18 Jun 2019 08:56:16 +0200 Subject: [PATCH 119/172] QCoreWlanEngine: port away from Java-style iterators (and other fixes) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The main goal of this patch was to port away from Java-style iterators, to make QtBase QT_NO_JAVA_STYLE_ITERATORS-clean. And this the patch achieves. But I couldn't resist a few drive-by fixes, too, to wit: - Use qDeleteAll() instead of while(!isEmpty()) delete takeFirst() - Use QMap::last() instead of iterating to the end, remembering the last-seen value - Use QMap::contains() instead of QMap::keys().contains() - Use qExchange() instead of copy+clear - Make some functions const (requires the mutex member to be marked as mutable, which is common for mutex members) I am almost certain that getSsidFromNetworkName() cannot work correctly. But this patch does not attempt to change the algorithm. Change-Id: Ifa04d7837bdc0837036c3a7a73f8c51f4e681f42 Reviewed-by: Tor Arne Vestbø Reviewed-by: Timur Pocheptsov --- src/plugins/bearer/corewlan/qcorewlanengine.h | 8 +-- .../bearer/corewlan/qcorewlanengine.mm | 61 +++++-------------- 2 files changed, 20 insertions(+), 49 deletions(-) diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h index 4a431b886ef..6dddee66a41 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.h +++ b/src/plugins/bearer/corewlan/qcorewlanengine.h @@ -122,9 +122,9 @@ public: QString interfaceName; QMap configurationInterface; void getUserConfigurations(); - QString getNetworkNameFromSsid(const QString &ssid); - QString getSsidFromNetworkName(const QString &name); - bool isKnownSsid(const QString &ssid); + QString getNetworkNameFromSsid(const QString &ssid) const; + QString getSsidFromNetworkName(const QString &name) const; + bool isKnownSsid(const QString &ssid) const; QMap > userProfiles; signals: @@ -135,7 +135,7 @@ protected: private: QList fetchedConfigurations; - QMutex mutex; + mutable QMutex mutex; QStringList foundNetwork(const QString &id, const QString &ssid, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose); }; diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index c3dd49ff3e1..4644b5af9fb 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -203,9 +203,7 @@ void QScanThread::run() } } // add known configurations that are not around. - QMapIterator > i(userProfiles); - while (i.hasNext()) { - i.next(); + for (auto i = userProfiles.cbegin(), end = userProfiles.cend(); i != end; ++i) { QString networkName = i.key(); const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkName)); @@ -215,11 +213,8 @@ void QScanThread::run() const QString ssidId = QString::number(qHash(QLatin1String("corewlan:") + networkSsid)); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; QString interfaceName; - QMapIterator ij(i.value()); - while (ij.hasNext()) { - ij.next(); - interfaceName = ij.value(); - } + if (!i.value().isEmpty()) + interfaceName = i.value().last(); if (currentInterfaceServiceActive) { if (networkSsid == QString::fromNSString([currentInterface ssid])) { @@ -269,11 +264,7 @@ QStringList QScanThread::foundNetwork(const QString &id, const QString &name, co QList QScanThread::getConfigurations() { QMutexLocker locker(&mutex); - - QList foundConfigurations = fetchedConfigurations; - fetchedConfigurations.clear(); - - return foundConfigurations; + return qExchange(fetchedConfigurations, {}); } void QScanThread::getUserConfigurations() @@ -363,17 +354,12 @@ void QScanThread::getUserConfigurations() } } -QString QScanThread::getSsidFromNetworkName(const QString &name) +QString QScanThread::getSsidFromNetworkName(const QString &name) const { QMutexLocker locker(&mutex); - QMapIterator > i(userProfiles); - while (i.hasNext()) { - i.next(); - QMap map = i.value(); - QMapIterator ij(i.value()); - while (ij.hasNext()) { - ij.next(); + for (auto i = userProfiles.cbegin(), end = userProfiles.cend(); i != end; ++i) { + for (auto ij = i.value().cbegin(), end = i.value().cend(); ij != end; ++ij) { const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") +i.key())); if(name == i.key() || name == networkNameHash) { return ij.key(); @@ -383,36 +369,24 @@ QString QScanThread::getSsidFromNetworkName(const QString &name) return QString(); } -QString QScanThread::getNetworkNameFromSsid(const QString &ssid) +QString QScanThread::getNetworkNameFromSsid(const QString &ssid) const { QMutexLocker locker(&mutex); - QMapIterator > i(userProfiles); - while (i.hasNext()) { - i.next(); - QMap map = i.value(); - QMapIterator ij(i.value()); - while (ij.hasNext()) { - ij.next(); - if(ij.key() == ssid) { - return i.key(); - } - } + for (auto i = userProfiles.cbegin(), end = userProfiles.cend(); i != end; ++i) { + if (i.value().contains(ssid)) + return i.key(); } return QString(); } -bool QScanThread::isKnownSsid(const QString &ssid) +bool QScanThread::isKnownSsid(const QString &ssid) const { QMutexLocker locker(&mutex); - QMapIterator > i(userProfiles); - while (i.hasNext()) { - i.next(); - QMap map = i.value(); - if(map.keys().contains(ssid)) { + for (auto i = userProfiles.cbegin(), end = userProfiles.cend(); i != end; ++i) { + if (i.value().contains(ssid)) return true; - } } return false; } @@ -430,8 +404,7 @@ QCoreWlanEngine::~QCoreWlanEngine() { scanThread->wait(); - while (!foundConfigurations.isEmpty()) - delete foundConfigurations.takeFirst(); + qDeleteAll(qExchange(foundConfigurations, {})); [listener remove]; [listener release]; } @@ -486,9 +459,7 @@ void QCoreWlanEngine::connectToId(const QString &id) const QString idHash2 = QString::number(qHash(QLatin1String("corewlan:") + scanThread->getNetworkNameFromSsid(ptr->name))); QString wantedNetwork; - QMapIterator > i(scanThread->userProfiles); - while (i.hasNext()) { - i.next(); + for (auto i = scanThread->userProfiles.cbegin(), end = scanThread->userProfiles.cend(); i != end; ++i) { wantedNetwork = i.key(); const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") + wantedNetwork)); if (id == networkNameHash) { From 5e0a45e932424c5ed661ae518ca21d2ab627db2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 21 Jun 2019 13:02:34 +0200 Subject: [PATCH 120/172] QSocks5SocketEngine: pass data to application when connected If we end up in the connected state then we should pass on any remaining data immediately instead of waiting until the next time we get a read notification. The other `case`s in the switch might be able to do something similar, but I don't want to introduce that logic now in case it breaks something else, the Connected branch is small and simple to deal with. Should severely reduce flakiness with socks proxy in CI under pressure. Task-number: QTBUG-76367 Change-Id: I0965d4c62a29a25ce6b8dd60862a464279aef0b4 Reviewed-by: Timur Pocheptsov Reviewed-by: Ryan Chu --- src/network/socket/qsocks5socketengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 6791b85273b..d2328f85363 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1188,6 +1188,8 @@ void QSocks5SocketEnginePrivate::_q_controlSocketReadNotification() break; case RequestMethodSent: parseRequestMethodReply(); + if (socks5State == Connected && data->controlSocket->bytesAvailable()) + _q_controlSocketReadNotification(); break; case Connected: { QByteArray buf; From 1eeab2d27f61485cb53364d40339a8d832a076e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 24 Jun 2019 18:55:36 +0200 Subject: [PATCH 121/172] QSocks5SocketEngine: account for in-transit signal when waiting for read When calling waitFor{ReadyRead,Disconnected} it will wait for data but if the data is already received and the read notification has been queued (and there's no more data coming in) it will return false. By checking if a read notification has been queued and then handling this we can easily take care of this scenario. Fixes some flaky tests which missed the read data in waitForDisconnect and similar. Fixes: QTBUG-38385 Change-Id: Ic05d59883c1175783e56ff1822b6636c35aec874 Reviewed-by: Volker Hilsheimer --- src/network/socket/qsocks5socketengine.cpp | 5 +++++ tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index d2328f85363..e7e4d64c322 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1753,6 +1753,11 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) return false; if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) return true; + if (bytesAvailable() && d->readNotificationPending) { + // We've got some data incoming, but the queued call hasn't been performed yet. + // The data is where we expect it to be already, so just return true. + return true; + } // we're connected if (d->mode == QSocks5SocketEnginePrivate::ConnectMode || diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index c473230246b..2d64714f922 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -328,8 +328,8 @@ void tst_QTcpSocket::initTestCase_data() qDebug() << QtNetworkSettings::serverName(); QTest::newRow("WithoutProxy") << false << 0 << false; - //QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; ### temporarily disabled, QTBUG-38385 - //QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; ### temporarily disabled, QTBUG-38385 + QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; + QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; QTest::newRow("WithHttpProxy") << true << int(HttpProxy) << false; QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic) << false; @@ -337,8 +337,8 @@ void tst_QTcpSocket::initTestCase_data() #ifndef QT_NO_SSL QTest::newRow("WithoutProxy SSL") << false << 0 << true; - //QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; ### temporarily disabled, QTBUG-38385 - //QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; ### temporarily disabled, QTBUG-38385 + QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; + QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; QTest::newRow("WithHttpProxy SSL") << true << int(HttpProxy) << true; QTest::newRow("WithHttpProxyBasicAuth SSL") << true << int(HttpProxy | AuthBasic) << true; From 555661b625c40f21a6a3e4c73e928a6e8a46db20 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 21 Jun 2019 16:31:04 +0200 Subject: [PATCH 122/172] Update visible window's alpha when toggling WA_TranslucentBackground MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWidgetPrivate::updateIsTranslucent sets the surface format of the window with the alpha based on the translucency attribute, so we need to call this function when the attribute value changes. The test can confirm that the window's requested surface format has changed, we can't rely on what is actually set, and don't have to rely on hard-coded values like 8bit alpha. While WA_NoSystemBackground needs to be set for WA_TranslucentBackground to have an effect, we can't clear the attribute when clearing translucency (as it might have been set explicitly). Change-Id: I238d6930b7e0488397467a4e035b5f530566a1ff Fixes: QTBUG-60822 Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 5 ++--- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6ef3a4f1633..50745175b4e 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -11474,10 +11474,9 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } break; case Qt::WA_TranslucentBackground: - if (on) { + if (on) setAttribute(Qt::WA_NoSystemBackground); - d->updateIsTranslucent(); - } + d->updateIsTranslucent(); break; case Qt::WA_AcceptTouchEvents: diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 489edb703c0..7edca2017de 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -8855,6 +8855,12 @@ void tst_QWidget::translucentWidget() QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(actual.size(),expected.size()); QCOMPARE(actual,expected); + + const QWindow *window = label.windowHandle(); + const QSurfaceFormat translucentFormat = window->requestedFormat(); + label.setAttribute(Qt::WA_TranslucentBackground, false); + const QSurfaceFormat opaqueFormat = window->requestedFormat(); + QVERIFY(translucentFormat != opaqueFormat); } class MaskResizeTestWidget : public QWidget From 24b9424adcda1ab083fae4ae857007227ba5fee2 Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Tue, 2 Jul 2019 14:24:25 +0200 Subject: [PATCH 123/172] Skip flaky test on MacOS_10_12 This is the most flaky-pass test currently. It fails the first time it is run on MacOS_10_12, but succeeds all the following times. This happens extremely often, so disable it until the issue is resolved. Task-number: QTBUG-76566 Change-Id: I94359eceb91c3b958930424e6c8b5957fb3f1252 Reviewed-by: Volker Hilsheimer --- .../graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 9a75774927d..ae0d91dfe3f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -5049,6 +5049,12 @@ public: void tst_QGraphicsItem::paint() { +#if defined(Q_OS_MACOS) + if (QSysInfo::productVersion() == QLatin1String("10.12")) { + QSKIP("Test is very flaky on MacOS_10_12, see QTBUG-76566"); + } +#endif + QGraphicsScene scene; PaintTester paintTester; From 13997cccc9dd9a1242b7707b5e934deae84d253a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 21 Jun 2019 12:44:33 +0200 Subject: [PATCH 124/172] Remove QWindowsDirect2DEventDispatcher This class was introduced to modify the hook handling of QWindowsGuiEventDispatcher. As the hook handling code is removed now, we can remove QWindowsDirect2DEventDispatcher entirely. Change-Id: I56491a67f163784f43b1025225e536d386cead1d Reviewed-by: Alex Trotsenko Reviewed-by: Oliver Wolff --- .../direct2d/qwindowsdirect2dintegration.cpp | 15 --------------- .../direct2d/qwindowsdirect2dintegration.h | 1 - 2 files changed, 16 deletions(-) diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp index e637bd13fd3..e074f87eb45 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp @@ -51,21 +51,11 @@ #include #include #include -#include #include QT_BEGIN_NAMESPACE -class QWindowsDirect2DEventDispatcher : public QWindowsGuiEventDispatcher -{ -public: - QWindowsDirect2DEventDispatcher(QObject *parent = nullptr) - : QWindowsGuiEventDispatcher(parent) - { - } -}; - class QWindowsDirect2DIntegrationPrivate { public: @@ -187,11 +177,6 @@ QPlatformBackingStore *QWindowsDirect2DIntegration::createPlatformBackingStore(Q return new QWindowsDirect2DBackingStore(window); } -QAbstractEventDispatcher *QWindowsDirect2DIntegration::createEventDispatcher() const -{ - return new QWindowsDirect2DEventDispatcher; -} - QWindowsDirect2DContext *QWindowsDirect2DIntegration::direct2DContext() const { return &d->m_d2dContext; diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h index 19c7521eb79..5ea36e04bc9 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h @@ -61,7 +61,6 @@ public: QPlatformNativeInterface *nativeInterface() const override; QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const override; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; - QAbstractEventDispatcher *createEventDispatcher() const override; QWindowsDirect2DContext *direct2DContext() const; From dce7dbecb0135501eb8641c8f5ec8e98bddc808c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 2 May 2019 19:56:29 +0200 Subject: [PATCH 125/172] qlalr: replace QLinkedList with std::list This is in preparation of deprecating QLinkedList. Most is straight-forward, except where operator+ was used on linked-list iterators. In one case, replaced this with std::next, in the other, with prefix increments, since the advancement was always equal to the loop control variable. Since advancing a linked-list iterator is a linear operation, this removes a source of quadratic complexity. Another obstacle was the overloaded op< set, which was in the Qt namespace while the iterator is from std and the payload, as before, was global. This breaks ADL, so move these operators to namespace std. This violates the standard, but the functions are tagged with our distinct types, so it shouldn't cause any trouble. Change-Id: Ifec0a927bfdabb002838cdf86fb8d23b32a38ff7 Reviewed-by: Giuseppe D'Angelo --- src/tools/bootstrap/bootstrap.pro | 1 - src/tools/qlalr/cppgenerator.cpp | 17 ++++++++-------- src/tools/qlalr/lalr.cpp | 10 +++++---- src/tools/qlalr/lalr.h | 34 ++++++++++--------------------- src/tools/qlalr/main.cpp | 2 +- 5 files changed, 27 insertions(+), 37 deletions(-) diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 8598fc27212..757460393e9 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -84,7 +84,6 @@ SOURCES += \ ../../corelib/tools/qcryptographichash.cpp \ ../../corelib/tools/qhash.cpp \ ../../corelib/tools/qlist.cpp \ - ../../corelib/tools/qlinkedlist.cpp \ ../../corelib/tools/qlocale.cpp \ ../../corelib/tools/qlocale_tools.cpp \ ../../corelib/tools/qmap.cpp \ diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp index ee17be041e9..95f70dc988c 100644 --- a/src/tools/qlalr/cppgenerator.cpp +++ b/src/tools/qlalr/cppgenerator.cpp @@ -36,6 +36,8 @@ #include #include +#include + namespace { void generateSeparator(int i, QTextStream &out) @@ -126,7 +128,7 @@ QString CppGenerator::endIncludeGuard(const QString &fileName) void CppGenerator::operator () () { // action table... - state_count = aut.states.size (); + state_count = static_cast(aut.states.size()); terminal_count = static_cast(grammar.terminals.size()); non_terminal_count = static_cast(grammar.non_terminals.size()); @@ -156,7 +158,7 @@ void CppGenerator::operator () () if (grammar.isNonTerminal (a.key ())) { - Q_ASSERT (symbol >= terminal_count && symbol < grammar.names.size ()); + Q_ASSERT(symbol >= terminal_count && symbol < static_cast(grammar.names.size())); GOTO (q, symbol - terminal_count) = r; } @@ -245,7 +247,7 @@ void CppGenerator::operator () () << Qt::endl; } - QBitArray used_rules (grammar.rules.count ()); + QBitArray used_rules{static_cast(grammar.rules.size())}; int q = 0; for (StatePointer state = aut.states.begin (); state != aut.states.end (); ++state, ++q) @@ -259,12 +261,11 @@ void CppGenerator::operator () () } } - for (int i = 0; i < used_rules.count (); ++i) + auto rule = grammar.rules.begin(); + for (int i = 0; i < used_rules.count (); ++i, ++rule) { if (! used_rules.testBit (i)) { - RulePointer rule = grammar.rules.begin () + i; - if (rule != grammar.goal) qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << Qt::endl; } @@ -280,7 +281,7 @@ void CppGenerator::operator () () if (u >= 0) continue; - RulePointer rule = grammar.rules.begin () + (- u - 1); + RulePointer rule = std::next(grammar.rules.begin(), - u - 1); if (state->defaultReduce == rule) u = 0; @@ -619,7 +620,7 @@ void CppGenerator::generateImpl (QTextStream &out) out << "const int " << grammar.table_name << "::rule_index [] = {"; idx = 0; - int offset = 0; + size_t offset = 0; for (RulePointer rule = grammar.rules.begin (); rule != grammar.rules.end (); ++rule, ++idx) { generateSeparator(idx, out); diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp index 8af3b3c0dbc..b9a9cf264f1 100644 --- a/src/tools/qlalr/lalr.cpp +++ b/src/tools/qlalr/lalr.cpp @@ -51,7 +51,9 @@ QTextStream &qout() static QTextStream result(stdout, QIODevice::WriteOnly); return result; } +QT_END_NAMESPACE +namespace std { bool operator < (Name a, Name b) { return *a < *b; @@ -66,7 +68,7 @@ bool operator < (StatePointer a, StatePointer b) { return &*a < &*b; } -QT_END_NAMESPACE +} bool Read::operator < (const Read &other) const { @@ -329,7 +331,7 @@ QPair Automaton::internState (const State &state) struct _Bucket { - QLinkedList items; + std::list items; void insert (ItemPointer item) { items.push_back (item); } @@ -338,8 +340,8 @@ struct _Bucket { State st (aut->_M_grammar); - for (QLinkedList::iterator item = items.begin (); item != items.end (); ++item) - st.insert ((*item)->next ()); + for (auto &item : items) + st.insert(item->next()); return st; } diff --git a/src/tools/qlalr/lalr.h b/src/tools/qlalr/lalr.h index 55b65a640d0..473ea89769a 100644 --- a/src/tools/qlalr/lalr.h +++ b/src/tools/qlalr/lalr.h @@ -51,34 +51,22 @@ class Automaton; // names -typedef QLinkedList::iterator Name; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(QLinkedList::iterator, Q_PRIMITIVE_TYPE); -QT_END_NAMESPACE -typedef QLinkedList NameList; +typedef std::list::iterator Name; +typedef std::list NameList; typedef std::set NameSet; // items -typedef QLinkedList ItemList; +typedef std::list ItemList; typedef ItemList::iterator ItemPointer; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(ItemList::iterator, Q_PRIMITIVE_TYPE); -QT_END_NAMESPACE // rules -typedef QLinkedList debug_infot; +typedef std::list debug_infot; typedef debug_infot::iterator RulePointer; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(debug_infot::iterator, Q_PRIMITIVE_TYPE); -QT_END_NAMESPACE typedef QMultiMap RuleMap; // states -typedef QLinkedList StateList; +typedef std::list StateList; typedef StateList::iterator StatePointer; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(StateList::iterator, Q_PRIMITIVE_TYPE); -QT_END_NAMESPACE // arrows typedef QMap Bundle; @@ -175,7 +163,7 @@ class Node public: typedef std::set > Repository; typedef typename Repository::iterator iterator; - typedef typename QLinkedList::iterator edge_iterator; + typedef typename std::list::iterator edge_iterator; public: static iterator get (_Tp data); @@ -213,7 +201,7 @@ public: // attributes mutable bool root; mutable int dfn; mutable _Tp data; - mutable QLinkedList outs; + mutable std::list outs; protected: inline Node () {} @@ -235,7 +223,7 @@ typename Node<_Tp>::iterator Node<_Tp>::get (_Tp data) } template -QPair::iterator>::iterator, bool> Node<_Tp>::insertEdge (typename Node<_Tp>::iterator other) const +QPair::iterator>::iterator, bool> Node<_Tp>::insertEdge(typename Node<_Tp>::iterator other) const { edge_iterator it = std::find (outs.begin (), outs.end (), other); @@ -272,7 +260,7 @@ public: QString decl_file_name; QString impl_file_name; QString token_prefix; - QLinkedList names; + std::list names; Name start; NameSet terminals; NameSet non_terminals; @@ -401,11 +389,11 @@ private: int _M_includes_dfn; }; -QT_BEGIN_NAMESPACE +namespace std { bool operator < (Name a, Name b); bool operator < (StatePointer a, StatePointer b); bool operator < (ItemPointer a, ItemPointer b); -QT_END_NAMESPACE +} QTextStream &operator << (QTextStream &out, const Name &n); QTextStream &operator << (QTextStream &out, const Rule &r); diff --git a/src/tools/qlalr/main.cpp b/src/tools/qlalr/main.cpp index a920b13c858..6a57c7aa7ab 100644 --- a/src/tools/qlalr/main.cpp +++ b/src/tools/qlalr/main.cpp @@ -106,7 +106,7 @@ int main (int argc, char *argv[]) if (! p.parse (file_name)) exit (EXIT_FAILURE); - if (grammar.rules.isEmpty ()) + if (grammar.rules.empty()) { qerr() << "*** Fatal. No rules!" << Qt::endl; exit (EXIT_FAILURE); From 3d87ea91af766d99dffc17f233b35e941eeefaf1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Jul 2019 16:20:06 +0200 Subject: [PATCH 126/172] RHI/D3D11: Remove hard dependency on D3DCompiler library Varying versions of the library may be available depending on build tool chain or Windows version. Try to dynamically resolve the D3DCompile function. Fixes: QTBUG-76845 Change-Id: Ib7eb3b8c454e9c25731eb2ba9ba45e54fe3f1283 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhid3d11.cpp | 21 ++++++++++++++++++++- src/gui/rhi/rhi.pri | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index eea2a13d8c5..a8a490eb5cd 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -3218,6 +3219,18 @@ static inline D3D11_BLEND_OP toD3DBlendOp(QRhiGraphicsPipeline::BlendOp op) } } +static pD3DCompile resolveD3DCompile() +{ + for (const wchar_t *libraryName : {L"D3DCompiler_47", L"D3DCompiler_43"}) { + QSystemLibrary library(libraryName); + if (library.load()) { + if (auto symbol = library.resolve("D3DCompile")) + return reinterpret_cast(symbol); + } + } + return nullptr; +} + static QByteArray compileHlslShaderSource(const QShader &shader, QShader::Variant shaderVariant, QString *error) { QShaderCode dxbc = shader.shader({ QShader::DxbcShader, 50, shaderVariant }); @@ -3255,9 +3268,15 @@ static QByteArray compileHlslShaderSource(const QShader &shader, QShader::Varian return QByteArray(); } + static const pD3DCompile d3dCompile = resolveD3DCompile(); + if (d3dCompile == nullptr) { + qWarning("Unable to resolve function D3DCompile()"); + return QByteArray(); + } + ID3DBlob *bytecode = nullptr; ID3DBlob *errors = nullptr; - HRESULT hr = D3DCompile(hlslSource.shader().constData(), hlslSource.shader().size(), + HRESULT hr = d3dCompile(hlslSource.shader().constData(), hlslSource.shader().size(), nullptr, nullptr, nullptr, hlslSource.entryPoint().constData(), target, 0, 0, &bytecode, &errors); if (FAILED(hr) || !bytecode) { diff --git a/src/gui/rhi/rhi.pri b/src/gui/rhi/rhi.pri index d8607f10241..4297a5602b9 100644 --- a/src/gui/rhi/rhi.pri +++ b/src/gui/rhi/rhi.pri @@ -40,7 +40,7 @@ win32 { SOURCES += \ rhi/qrhid3d11.cpp - LIBS += -ld3d11 -ldxgi -ldxguid -ld3dcompiler + LIBS += -ld3d11 -ldxgi -ldxguid } # darwin { From 9ea53c4a98281e4be12164929a7ca5dc7c014280 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 1 Jul 2019 14:35:27 +0200 Subject: [PATCH 127/172] QShortcut: Brush up the code, preparing the extraction of a base class to QtGui - Use member initialization - Introduce nullptr - Use auto where applicable - Use range-based for Task-number: QTBUG-76493 Change-Id: Ic4dbee2d76a65be1f8a4c25f4ca7e4f032443579 Reviewed-by: Frederik Gladhorn --- src/widgets/kernel/qshortcut.cpp | 68 +++++++++++++++----------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index c418db14ff6..a4ebcdfc844 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -96,8 +96,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) QWindow *qwindow = QGuiApplication::focusWindow(); if (qwindow && qwindow->isActive()) { while (qwindow) { - QWidgetWindow *widgetWindow = qobject_cast(qwindow); - if (widgetWindow) { + if (auto widgetWindow = qobject_cast(qwindow)) { active_window = widgetWindow->widget(); break; } @@ -110,27 +109,25 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) return false; #ifndef QT_NO_ACTION - if (QAction *a = qobject_cast(object)) + if (auto a = qobject_cast(object)) return correctActionContext(context, a, active_window); #endif #if QT_CONFIG(graphicsview) - if (QGraphicsWidget *gw = qobject_cast(object)) + if (auto gw = qobject_cast(object)) return correctGraphicsWidgetContext(context, gw, active_window); #endif - QWidget *w = qobject_cast(object); + auto w = qobject_cast(object); if (!w) { - QShortcut *s = qobject_cast(object); - if (s) + if (auto s = qobject_cast(object)) w = s->parentWidget(); } if (!w) { - QWindow *qwindow = qobject_cast(object); + auto qwindow = qobject_cast(object); while (qwindow) { - QWidgetWindow *widget_window = qobject_cast(qwindow); - if (widget_window) { + if (auto widget_window = qobject_cast(qwindow)) { w = widget_window->widget(); break; } @@ -148,7 +145,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge { bool visible = w->isVisible(); #if QT_CONFIG(menubar) - if (QMenuBar *menuBar = qobject_cast(w)) { + if (auto menuBar = qobject_cast(w)) { if (auto *pmb = menuBar->platformMenuBar()) { if (menuBar->parentWidget()) { visible = true; @@ -166,7 +163,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge return false; if (context == Qt::ApplicationShortcut) - return QApplicationPrivate::tryModalHelper(w, 0); // true, unless w is shadowed by a modal dialog + return QApplicationPrivate::tryModalHelper(w, nullptr); // true, unless w is shadowed by a modal dialog if (context == Qt::WidgetShortcut) return w == QApplication::focusWidget(); @@ -181,9 +178,9 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge // Below is Qt::WindowShortcut context QWidget *tlw = w->window(); #if QT_CONFIG(graphicsview) - if (QWExtra *topData = static_cast(QObjectPrivate::get(tlw))->extra) { + if (auto topData = static_cast(QObjectPrivate::get(tlw))->extra) { if (topData->proxyWidget) { - bool res = correctGraphicsWidgetContext(context, (QGraphicsWidget *)topData->proxyWidget, active_window); + bool res = correctGraphicsWidgetContext(context, topData->proxyWidget, active_window); return res; } } @@ -244,9 +241,9 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW // Applicationwide shortcuts are always reachable unless their owner // is shadowed by modality. In QGV there's no modality concept, but we // must still check if all views are shadowed. - QList views = w->scene()->views(); - for (int i = 0; i < views.size(); ++i) { - if (QApplicationPrivate::tryModalHelper(views.at(i), 0)) + const auto &views = w->scene()->views(); + for (auto view : views) { + if (QApplicationPrivate::tryModalHelper(view, nullptr)) return true; } return false; @@ -258,7 +255,7 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW if (context == Qt::WidgetWithChildrenShortcut) { const QGraphicsItem *ti = w->scene()->focusItem(); if (ti && ti->isWidget()) { - const QGraphicsWidget *tw = static_cast(ti); + const auto *tw = static_cast(ti); while (tw && tw != w && (tw->windowType() == Qt::Widget || tw->windowType() == Qt::Popup)) tw = tw->parentWidget(); return tw == w; @@ -269,10 +266,9 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW // Below is Qt::WindowShortcut context // Find the active view (if any). - QList views = w->scene()->views(); - QGraphicsView *activeView = 0; - for (int i = 0; i < views.size(); ++i) { - QGraphicsView *view = views.at(i); + const auto &views = w->scene()->views(); + QGraphicsView *activeView = nullptr; + for (auto view : views) { if (view->window() == active_window) { activeView = view; break; @@ -291,15 +287,14 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW #ifndef QT_NO_ACTION static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window) { - const QList &widgets = static_cast(QObjectPrivate::get(a))->widgets; + const QWidgetList &widgets = static_cast(QObjectPrivate::get(a))->widgets; #if defined(DEBUG_QSHORTCUTMAP) if (widgets.isEmpty()) qDebug() << a << "not connected to any widgets; won't trigger"; #endif - for (int i = 0; i < widgets.size(); ++i) { - QWidget *w = widgets.at(i); + for (auto w : widgets) { #if QT_CONFIG(menu) - if (QMenu *menu = qobject_cast(w)) { + if (auto menu = qobject_cast(w)) { #ifdef Q_OS_DARWIN // On Mac, menu item shortcuts are processed before reaching any window. // That means that if a menu action shortcut has not been already processed @@ -325,14 +320,13 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge } #if QT_CONFIG(graphicsview) - const QList &graphicsWidgets = static_cast(QObjectPrivate::get(a))->graphicsWidgets; + const auto &graphicsWidgets = static_cast(QObjectPrivate::get(a))->graphicsWidgets; #if defined(DEBUG_QSHORTCUTMAP) if (graphicsWidgets.isEmpty()) qDebug() << a << "not connected to any widgets; won't trigger"; #endif - for (int i = 0; i < graphicsWidgets.size(); ++i) { - QGraphicsWidget *w = graphicsWidgets.at(i); - if (correctGraphicsWidgetContext(context, w, active_window)) + for (auto graphicsWidget : graphicsWidgets) { + if (correctGraphicsWidgetContext(context, graphicsWidget, active_window)) return true; } #endif @@ -433,12 +427,12 @@ class QShortcutPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QShortcut) public: - QShortcutPrivate() : sc_context(Qt::WindowShortcut), sc_enabled(true), sc_autorepeat(true), sc_id(0) {} + QShortcutPrivate() = default; QKeySequence sc_sequence; - Qt::ShortcutContext sc_context; - bool sc_enabled; - bool sc_autorepeat; - int sc_id; + Qt::ShortcutContext sc_context = Qt::WindowShortcut; + bool sc_enabled = true; + bool sc_autorepeat = true; + int sc_id = 0; QString sc_whatsthis; void redoGrab(QShortcutMap &map); }; @@ -472,7 +466,7 @@ void QShortcutPrivate::redoGrab(QShortcutMap &map) QShortcut::QShortcut(QWidget *parent) : QObject(*new QShortcutPrivate, parent) { - Q_ASSERT(parent != 0); + Q_ASSERT(parent != nullptr); } /*! @@ -667,7 +661,7 @@ bool QShortcut::event(QEvent *e) Q_D(QShortcut); bool handled = false; if (d->sc_enabled && e->type() == QEvent::Shortcut) { - QShortcutEvent *se = static_cast(e); + auto se = static_cast(e); if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){ #if QT_CONFIG(whatsthis) if (QWhatsThis::inWhatsThisMode()) { From e5ab131c18d1c2f75c097272c3300bf25f256367 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Jul 2019 14:15:04 +0200 Subject: [PATCH 128/172] tst_QShortcut: Remove test widget and other member variables Remove the mainW, edit widget member variables from the test and use widgets instantiated on the stack in the tests. For the data-driven tests, use a static QScopedPointer, which is reset by a newly introduced TestEnd action. The book-keeping logic maintaining a list of shortcuts can then be removed. The setupShortcut() helpers are simplified and the special case TestWidget::SendKeyEvent is replaced by a lambda in keypressConsumption(). Task-number: QTBUG-76493 Change-Id: I15dfa86dfa0666ed8288b7190e37cdb862c261c8 Reviewed-by: Allan Sandfeld Jensen --- .../kernel/qshortcut/tst_qshortcut.cpp | 383 +++++++++--------- 1 file changed, 194 insertions(+), 189 deletions(-) diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index d86236bea53..8c262ff3a54 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -50,14 +50,12 @@ class tst_QShortcut : public QObject { Q_OBJECT public: - tst_QShortcut(); - virtual ~tst_QShortcut(); - enum Action { SetupAccel, TestAccel, - ClearAll + ClearAll, + TestEnd }; Q_ENUM(Action) @@ -70,7 +68,6 @@ public: TriggerSlot5, TriggerSlot6, TriggerSlot7, - SendKeyEvent }; Q_ENUM(Widget) @@ -85,7 +82,7 @@ public: Slot7Triggered, SentKeyEvent, Ambiguous - } currentResult; + } currentResult = NoResult; Q_ENUM(Result) public slots: @@ -103,15 +100,9 @@ public slots: void ambigSlot5() { currentResult = Ambiguous; ambigResult = Slot5Triggered; } void ambigSlot6() { currentResult = Ambiguous; ambigResult = Slot6Triggered; } void ambigSlot7() { currentResult = Ambiguous; ambigResult = Slot7Triggered; } - void shortcutDestroyed(QObject* obj); - void sendKeyEvent() { sendKeyEvents(edit, Qt::CTRL + Qt::Key_B, 0); currentResult = SentKeyEvent; } - -public slots: - void initTestCase(); - void cleanupTestCase(); - void cleanup() { QCOMPARE(QApplication::topLevelWidgets().size(), 1); } private slots: + void cleanup(); void number_data(); void number(); void text_data(); @@ -129,21 +120,16 @@ protected: static Qt::KeyboardModifiers toButtons( int key ); void defElements(); - void clearAllShortcuts(); - QShortcut *setupShortcut(Widget testWidget, const QKeySequence &ks); - QShortcut *setupShortcut(Widget testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0); + QShortcut *setupShortcut(QWidget *parent, const QString &name, const QKeySequence &ks, + Qt::ShortcutContext context = Qt::WindowShortcut); + QShortcut *setupShortcut(QWidget *parent, const QString &name, Widget testWidget, + const QKeySequence &ks, Qt::ShortcutContext context = Qt::WindowShortcut); - QShortcut *setupShortcut(QWidget *parent, const char *name, Widget testWidget, const QString &txt, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0); - QShortcut *setupShortcut(QWidget *parent, const char *name, Widget testWidget, const QKeySequence &ks, Qt::ShortcutContext context = Qt::WindowShortcut); - - void sendKeyEvents(QWidget *w, int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0); - void sendKeyEvents(int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0); + static void sendKeyEvents(QWidget *w, int k1, QChar c1 = 0, int k2 = 0, QChar c2 = 0, + int k3 = 0, QChar c3 = 0, int k4 = 0, QChar c4 = 0); void testElement(); - QMainWindow *mainW; - QList shortcuts; - QTextEdit *edit; Result ambigResult; }; @@ -192,31 +178,28 @@ protected: } }; -tst_QShortcut::tst_QShortcut(): mainW( nullptr ) +class MainWindow : public QMainWindow { +public: + MainWindow(); + + TestEdit *testEdit() const { return m_testEdit; } + +private: + TestEdit *m_testEdit; +}; + +MainWindow::MainWindow() +{ + setWindowFlags(Qt::X11BypassWindowManagerHint); + m_testEdit = new TestEdit(this, "test_edit"); + setCentralWidget(m_testEdit); + setFixedSize(200, 200); } -tst_QShortcut::~tst_QShortcut() +void tst_QShortcut::cleanup() { - clearAllShortcuts(); -} - -void tst_QShortcut::initTestCase() -{ - currentResult = NoResult; - mainW = new QMainWindow(nullptr); - mainW->setWindowFlags(Qt::X11BypassWindowManagerHint); - edit = new TestEdit(mainW, "test_edit"); - mainW->setFixedSize( 200, 200 ); - mainW->setCentralWidget( edit ); - mainW->show(); - mainW->activateWindow(); - QVERIFY(QTest::qWaitForWindowActive(mainW)); -} - -void tst_QShortcut::cleanupTestCase() -{ - delete mainW; + QVERIFY(QApplication::topLevelWidgets().size() <= 1); // The data driven tests keep a widget around } Qt::KeyboardModifiers tst_QShortcut::toButtons( int key ) @@ -448,7 +431,7 @@ void tst_QShortcut::number_data() QTest::newRow("N:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; QTest::newRow("N:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered; QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("N13 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("N:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; } // ------------------------------------------------------------------ @@ -592,7 +575,35 @@ void tst_QShortcut::text_data() QTest::newRow("T:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; QTest::newRow("T:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered; QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered; - QTest::newRow("T13 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all + QTest::newRow("T:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; +} + +class ButtonWidget : public QWidget +{ +public: + ButtonWidget(); + + QPushButton *pushButton1() const { return m_pb1; } + QPushButton *pushButton2() const { return m_pb2; } + +private: + QPushButton *m_pb1; + QPushButton *m_pb2; +}; + +ButtonWidget::ButtonWidget() +{ + // Setup two identical shortcuts on different pushbuttons + QString name = QLatin1String("pushbutton-1"); + m_pb1 = new QPushButton(name, this); + m_pb1->setObjectName(name); + name = QLatin1String("pushbutton-2"); + m_pb2 = new QPushButton(name, this); + m_pb2->setObjectName(name); + auto hLayout = new QHBoxLayout(this); + hLayout->addWidget(m_pb1); + hLayout->addWidget(m_pb2); + hLayout->addStretch(); } // ------------------------------------------------------------------ @@ -600,9 +611,11 @@ void tst_QShortcut::text_data() // ------------------------------------------------------------------ void tst_QShortcut::disabledItems() { - clearAllShortcuts(); - mainW->activateWindow(); - QVERIFY(QTest::qWaitForWindowActive(mainW)); + ButtonWidget mainW; + mainW.setWindowTitle(QTest::currentTestFunction()); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); /* Testing Disabled Shortcuts Qt::Key_M on slot1 @@ -612,27 +625,27 @@ void tst_QShortcut::disabledItems() */ // Setup two identical shortcuts on different pushbuttons - QPushButton pb1(mainW); - QPushButton pb2(mainW); - pb1.setObjectName("pushbutton-1"); - pb2.setObjectName("pushbutton-2"); - pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger - pb2.show(); - - QShortcut *cut1 = setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M"); - QShortcut *cut2 = setupShortcut(&pb1, "shortcut2-pb1", TriggerSlot1, "Shift+M"); - QShortcut *cut3 = setupShortcut(&pb2, "shortcut3-pb2", TriggerSlot2, "M"); - QShortcut *cut4 = setupShortcut(&pb2, "shortcut4-pb2", TriggerSlot2, "Shift+M"); + auto pb1 = mainW.pushButton1(); + auto pb2 = mainW.pushButton2(); + const int shiftM = Qt::SHIFT + Qt::Key_M; + QShortcut *cut1 = setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, + QKeySequence(Qt::Key_M)); + QShortcut *cut2 = setupShortcut(pb1, "shortcut2-pb1", TriggerSlot1, + QKeySequence(shiftM)); + QShortcut *cut3 = setupShortcut(pb2, "shortcut3-pb2", TriggerSlot2, + QKeySequence(Qt::Key_M)); + QShortcut *cut4 = setupShortcut(pb2, "shortcut4-pb2", TriggerSlot2, + QKeySequence(shiftM)); cut3->setEnabled(false); cut4->setEnabled(false); currentResult = NoResult; - sendKeyEvents(Qt::Key_M, 'm'); + sendKeyEvents(&mainW, Qt::Key_M, 'm'); QCOMPARE(currentResult, Slot1Triggered); currentResult = NoResult; - sendKeyEvents(Qt::SHIFT+Qt::Key_M, 'M'); + sendKeyEvents(&mainW, shiftM, 'M'); QCOMPARE(currentResult, Slot1Triggered); cut2->setEnabled(false); @@ -645,11 +658,11 @@ void tst_QShortcut::disabledItems() Shift + Qt::Key_M on slot2 */ currentResult = NoResult; - sendKeyEvents( Qt::Key_M, 'm' ); + sendKeyEvents(&mainW, Qt::Key_M, 'm' ); QCOMPARE( currentResult, Slot1Triggered ); currentResult = NoResult; - sendKeyEvents( Qt::SHIFT+Qt::Key_M, 'M' ); + sendKeyEvents(&mainW, shiftM, 'M' ); QCOMPARE( currentResult, Slot2Triggered ); @@ -657,32 +670,34 @@ void tst_QShortcut::disabledItems() Qt::Key_F5 on slot1 Shift + Qt::Key_F5 on slot2 (disabled) */ - clearAllShortcuts(); - cut1 = setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "F5"); - cut4 = setupShortcut(&pb2, "shortcut4-pb2", TriggerSlot2, "Shift+F5"); - - cut1->setKey(QKeySequence("F5")); - cut4->setKey(QKeySequence("Shift+F5")); + qDeleteAll(mainW.findChildren()); + const int shiftF5 = Qt::SHIFT + Qt::Key_F5; + cut1 = setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, QKeySequence(Qt::Key_F5)); + cut4 = setupShortcut(pb2, "shortcut4-pb2", TriggerSlot2, QKeySequence(shiftF5)); cut1->setEnabled(true); cut4->setEnabled(false); currentResult = NoResult; - sendKeyEvents( Qt::Key_F5, 0 ); + sendKeyEvents(&mainW, Qt::Key_F5, 0 ); QCOMPARE( currentResult, Slot1Triggered ); currentResult = NoResult; - sendKeyEvents( Qt::SHIFT+Qt::Key_F5, 0 ); + sendKeyEvents(&mainW, shiftF5, 0 ); QCOMPARE( currentResult, NoResult ); - - clearAllShortcuts(); } // ------------------------------------------------------------------ // Ambiguous Elements ----------------------------------------------- // ------------------------------------------------------------------ void tst_QShortcut::ambiguousRotation() { - clearAllShortcuts(); + MainWindow mainW; + const QString name = QLatin1String(QTest::currentTestFunction()); + mainW.setWindowTitle(name); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); + /* Testing Shortcut rotation scheme Ctrl + Qt::Key_A on slot1 (disabled) Ctrl + Qt::Key_A on slot2 (disabled) @@ -692,13 +707,15 @@ void tst_QShortcut::ambiguousRotation() Ctrl + Qt::Key_A on slot6 Ctrl + Qt::Key_A on slot7 (disabled) */ - QShortcut *cut1 = setupShortcut(TriggerSlot1, "Ctrl+A"); - QShortcut *cut2 = setupShortcut(TriggerSlot2, "Ctrl+A"); - QShortcut *cut3 = setupShortcut(TriggerSlot3, "Ctrl+A"); - QShortcut *cut4 = setupShortcut(TriggerSlot4, "Ctrl+A"); - QShortcut *cut5 = setupShortcut(TriggerSlot5, "Ctrl+A"); - QShortcut *cut6 = setupShortcut(TriggerSlot6, "Ctrl+A"); - QShortcut *cut7 = setupShortcut(TriggerSlot7, "Ctrl+A"); + const int ctrlA = Qt::CTRL + Qt::Key_A; + QKeySequence ctrlA_Sequence(ctrlA); + QShortcut *cut1 = setupShortcut(&mainW, name, TriggerSlot1, ctrlA_Sequence); + QShortcut *cut2 = setupShortcut(&mainW, name, TriggerSlot2, ctrlA_Sequence); + QShortcut *cut3 = setupShortcut(&mainW, name, TriggerSlot3, ctrlA_Sequence); + QShortcut *cut4 = setupShortcut(&mainW, name, TriggerSlot4, ctrlA_Sequence); + QShortcut *cut5 = setupShortcut(&mainW, name, TriggerSlot5, ctrlA_Sequence); + QShortcut *cut6 = setupShortcut(&mainW, name, TriggerSlot6, ctrlA_Sequence); + QShortcut *cut7 = setupShortcut(&mainW, name, TriggerSlot7, ctrlA_Sequence); cut1->setEnabled(false); cut2->setEnabled(false); @@ -712,37 +729,37 @@ void tst_QShortcut::ambiguousRotation() // Continue... currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot3Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot4Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot6Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot3Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot4Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot6Triggered); @@ -767,90 +784,87 @@ void tst_QShortcut::ambiguousRotation() currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot1Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot2Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot5Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot7Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot1Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot2Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot5Triggered); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(Qt::CTRL+Qt::Key_A); + sendKeyEvents(&mainW, ctrlA); QCOMPARE(currentResult, Ambiguous); QCOMPARE(ambigResult, Slot7Triggered); - - clearAllShortcuts(); } void tst_QShortcut::ambiguousItems() { - clearAllShortcuts(); + ButtonWidget mainW; + mainW.setWindowTitle(QTest::currentTestFunction()); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); + /* Testing Ambiguous Shortcuts Qt::Key_M on Pushbutton 1 Qt::Key_M on Pushbutton 2 */ // Setup two identical shortcuts on different pushbuttons - QPushButton pb1(mainW); - QPushButton pb2(mainW); - pb1.setObjectName("pushbutton-1"); - pb2.setObjectName("pushbutton-2"); - pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger - pb2.show(); + auto pb1 = mainW.pushButton1(); + auto pb2 = mainW.pushButton2(); - setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, "M"); - setupShortcut(&pb2, "shortcut2-pb2", TriggerSlot2, "M"); + setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, QKeySequence(Qt::Key_M)); + setupShortcut(pb2, "shortcut2-pb2", TriggerSlot2, QKeySequence(Qt::Key_M)); currentResult = NoResult; - sendKeyEvents( Qt::Key_M, 'm' ); + sendKeyEvents(&mainW, Qt::Key_M, 'm' ); QCOMPARE( currentResult, Ambiguous ); QCOMPARE( ambigResult, Slot1Triggered ); currentResult = NoResult; - sendKeyEvents( Qt::Key_M, 'm' ); + sendKeyEvents(&mainW, Qt::Key_M, 'm' ); QCOMPARE( currentResult, Ambiguous ); QCOMPARE( ambigResult, Slot2Triggered ); currentResult = NoResult; - sendKeyEvents( Qt::Key_M, 'm' ); + sendKeyEvents(&mainW, Qt::Key_M, 'm' ); QCOMPARE( currentResult, Ambiguous ); QCOMPARE( ambigResult, Slot1Triggered ); - - clearAllShortcuts(); } @@ -859,32 +873,31 @@ void tst_QShortcut::ambiguousItems() // ------------------------------------------------------------------ void tst_QShortcut::unicodeCompare() { - clearAllShortcuts(); + ButtonWidget mainW; + mainW.setWindowTitle(QTest::currentTestFunction()); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); + /* Testing Unicode/non-Unicode Shortcuts Qt::Key_M on Pushbutton 1 Qt::Key_M on Pushbutton 2 */ - QPushButton pb1(mainW); - QPushButton pb2(mainW); - pb1.setObjectName("pushbutton-1"); - pb2.setObjectName("pushbutton-2"); - pb1.show(); // Must be show for QShortcutMap::correctSubWindow to trigger - pb2.show(); + auto pb1 = mainW.pushButton1(); + auto pb2 = mainW.pushButton2(); QKeySequence ks1("Ctrl+M"); // Unicode QKeySequence ks2(Qt::CTRL+Qt::Key_M); // non-Unicode - setupShortcut(&pb1, "shortcut1-pb1", TriggerSlot1, ks1); - setupShortcut(&pb2, "shortcut2-pb2", TriggerSlot2, ks2); + setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, ks1); + setupShortcut(pb2, "shortcut2-pb2", TriggerSlot2, ks2); currentResult = NoResult; - sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 ); + sendKeyEvents(&mainW, Qt::CTRL + Qt::Key_M, 0); QCOMPARE( currentResult, Ambiguous ); // They _are_ ambiguous, so the QKeySequence operator== // should indicate the same QVERIFY( ks1 == ks2 ); QVERIFY( !(ks1 != ks2) ); - - clearAllShortcuts(); } // ------------------------------------------------------------------ @@ -892,16 +905,20 @@ void tst_QShortcut::unicodeCompare() // ------------------------------------------------------------------ void tst_QShortcut::keypressConsumption() { - clearAllShortcuts(); - edit->clear(); - QCOMPARE(edit->toPlainText().size(), 0); + MainWindow mainW; + mainW.setWindowTitle(QTest::currentTestFunction()); + mainW.show(); + mainW.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&mainW)); + auto edit = mainW.testEdit(); - QShortcut *cut1 = setupShortcut(edit, "shortcut1-line", TriggerSlot1, "Ctrl+I, A"); - QShortcut *cut2 = setupShortcut(edit, "shortcut1-line", TriggerSlot2, "Ctrl+I, B"); + const int ctrlI = Qt::CTRL + Qt::Key_I; + QShortcut *cut1 = setupShortcut(edit, "shortcut1-line", TriggerSlot1, QKeySequence(ctrlI, Qt::Key_A)); + QShortcut *cut2 = setupShortcut(edit, "shortcut1-line", TriggerSlot2, QKeySequence(ctrlI, Qt::Key_B)); currentResult = NoResult; ambigResult = NoResult; - sendKeyEvents(edit, Qt::CTRL + Qt::Key_I, 0); // Send key to edit + sendKeyEvents(edit, ctrlI, 0); // Send key to edit QCOMPARE( currentResult, NoResult ); QCOMPARE( ambigResult, NoResult ); QCOMPARE(edit->toPlainText(), QString()); @@ -938,11 +955,15 @@ void tst_QShortcut::keypressConsumption() QCOMPARE( ambigResult, NoResult ); QVERIFY(edit->toPlainText().endsWith("a")); - clearAllShortcuts(); + qDeleteAll(mainW.findChildren()); edit->clear(); QCOMPARE(edit->toPlainText().size(), 0); - setupShortcut(edit, "first", SendKeyEvent, "Ctrl+A"); + auto cut = setupShortcut(edit, QLatin1String("first"), QKeySequence(Qt::CTRL + Qt::Key_A)); + connect(cut, &QShortcut::activated, edit, [this, edit] () { + this->sendKeyEvents(edit, Qt::CTRL + Qt::Key_B, 0); + this->currentResult = tst_QShortcut::SentKeyEvent; + }); // Verify reentrancy when a non-shortcut is triggered as part // of shortcut processing. @@ -959,9 +980,14 @@ void tst_QShortcut::keypressConsumption() // ------------------------------------------------------------------ void tst_QShortcut::context() { - clearAllShortcuts(); + const QString name = QLatin1String(QTest::currentTestFunction()); + MainWindow mainW; + mainW.setWindowTitle(name + QLatin1String("_Helper")); + mainW.show(); + auto edit = mainW.testEdit(); QWidget myBox; + myBox.setWindowTitle(name); auto other1 = new TestEdit(&myBox, "test_edit_other1"); auto other2 = new TestEdit(&myBox, "test_edit_other2"); auto layout = new QHBoxLayout(&myBox); @@ -1052,8 +1078,6 @@ void tst_QShortcut::context() QCOMPARE(edit->toPlainText(), QString()); QCOMPARE(other1->toPlainText(), QString()); QCOMPARE(other2->toPlainText(), QString()); - - clearAllShortcuts(); } // QTBUG-38986, do not generate duplicated QEvent::ShortcutOverride in event processing. @@ -1086,42 +1110,21 @@ void tst_QShortcut::duplicatedShortcutOverride() QCOMPARE(w.overrideCount, 1); } -// ------------------------------------------------------------------ -// Element Testing helper functions --------------------------------- -// ------------------------------------------------------------------ -void tst_QShortcut::clearAllShortcuts() -{ - QList shortcutsCpy = shortcuts; - qDeleteAll(shortcutsCpy); - shortcuts.clear(); -} - -QShortcut *tst_QShortcut::setupShortcut(Widget testWidget, const QKeySequence &ks) -{ - return setupShortcut(mainW, QTest::currentDataTag() ? QTest::currentDataTag() : "", testWidget, ks); -} - -QShortcut *tst_QShortcut::setupShortcut(Widget testWidget, const QString &txt, int k1, int k2, int k3, int k4) -{ - return setupShortcut(mainW, QTest::currentDataTag() ? QTest::currentDataTag() : "", testWidget, - (txt.isEmpty() ? QKeySequence(k1, k2, k3, k4) : QKeySequence(txt))); -} - -QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, Widget testWidget, const QString &txt, int k1, int k2, int k3, int k4) -{ - return setupShortcut(parent, name, testWidget, - (txt.isEmpty() ? QKeySequence(k1, k2, k3, k4) : QKeySequence(txt))); -} - -QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, Widget testWidget, - const QKeySequence &ks, Qt::ShortcutContext context) +QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const QString &name, const QKeySequence &ks, Qt::ShortcutContext context) { // Set up shortcut for next test auto cut = new QShortcut(ks, parent, nullptr, nullptr, context); cut->setObjectName(name); + return cut; +} - switch(testWidget) - { +QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const QString &name, Widget testWidget, + const QKeySequence &ks, Qt::ShortcutContext context) +{ + // Set up shortcut for next test + auto cut = setupShortcut(parent, name, ks, context); + + switch (testWidget) { case TriggerSlot1: connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig1); connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot1); @@ -1150,28 +1153,12 @@ QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, Widge connect(cut, &QShortcut::activated, this, &tst_QShortcut::slotTrig7); connect(cut, &QShortcut::activatedAmbiguously, this, &tst_QShortcut::ambigSlot7); break; - case SendKeyEvent: - connect(cut, &QShortcut::activated, this, &tst_QShortcut::sendKeyEvent); - break; case NoWidget: break; } - connect(cut, &QObject::destroyed, this, &tst_QShortcut::shortcutDestroyed); - shortcuts.append(cut); return cut; } -void tst_QShortcut::shortcutDestroyed(QObject* obj) -{ - shortcuts.erase(std::remove(shortcuts.begin(), shortcuts.end(), obj), - shortcuts.end()); -} - -void tst_QShortcut::sendKeyEvents(int k1, QChar c1, int k2, QChar c2, int k3, QChar c3, int k4, QChar c4) -{ - sendKeyEvents(mainW, k1, c1, k2, c2, k3, c3, k4, c4); -} - void tst_QShortcut::sendKeyEvents(QWidget *w, int k1, QChar c1, int k2, QChar c2, int k3, QChar c3, int k4, QChar c4) { Qt::KeyboardModifiers b1 = toButtons( k1 ); @@ -1211,6 +1198,8 @@ void tst_QShortcut::sendKeyEvents(QWidget *w, int k1, QChar c1, int k2, QChar c2 void tst_QShortcut::testElement() { + static QScopedPointer mainW; + currentResult = NoResult; QFETCH(tst_QShortcut::Action, action); QFETCH(tst_QShortcut::Widget, testWidget); @@ -1225,13 +1214,29 @@ void tst_QShortcut::testElement() QFETCH(int, c4); QFETCH(tst_QShortcut::Result, result); - if (action == ClearAll) { - clearAllShortcuts(); - } else if (action == SetupAccel) { - setupShortcut(testWidget, txt, k1, k2, k3, k4); - } else { - sendKeyEvents(k1, c1, k2, c2, k3, c3, k4, c4); + if (mainW.isNull()) { + mainW.reset(new MainWindow); + mainW->setWindowTitle(QTest::currentTestFunction()); + mainW->show(); + mainW->activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(mainW.data())); + } + + switch (action) { + case ClearAll: + qDeleteAll(mainW->findChildren()); + break; + case SetupAccel: + setupShortcut(mainW.data(), txt, testWidget, txt.isEmpty() + ? QKeySequence(k1, k2, k3, k4) : QKeySequence::fromString(txt)); + break; + case TestAccel: + sendKeyEvents(mainW.data(), k1, c1, k2, c2, k3, c3, k4, c4); QCOMPARE(currentResult, result); + break; + case TestEnd: + mainW.reset(); + break; } } From 833519f2debf963ec198760475ba26319303d0e0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 2 Jul 2019 13:20:03 +0200 Subject: [PATCH 129/172] Fix compiler warnings when building with DEBUG defines set Change-Id: I51fc7aae246916e585b21b4e7da1fc5a4ac392fd Reviewed-by: Timur Pocheptsov --- .../socket/qnativesocketengine_win.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index c999bd2088f..986b0b48619 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -608,13 +608,13 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() socketType = qt_socket_getType(socketDescriptor); #if defined (QNATIVESOCKETENGINE_DEBUG) - QString socketProtocolStr = "UnknownProtocol"; - if (socketProtocol == QAbstractSocket::IPv4Protocol) socketProtocolStr = "IPv4Protocol"; - else if (socketProtocol == QAbstractSocket::IPv6Protocol) socketProtocolStr = "IPv6Protocol"; + QString socketProtocolStr = QStringLiteral("UnknownProtocol"); + if (socketProtocol == QAbstractSocket::IPv4Protocol) socketProtocolStr = QStringLiteral("IPv4Protocol"); + else if (socketProtocol == QAbstractSocket::IPv6Protocol) socketProtocolStr = QStringLiteral("IPv6Protocol"); - QString socketTypeStr = "UnknownSocketType"; - if (socketType == QAbstractSocket::TcpSocket) socketTypeStr = "TcpSocket"; - else if (socketType == QAbstractSocket::UdpSocket) socketTypeStr = "UdpSocket"; + QString socketTypeStr = QStringLiteral("UnknownSocketType"); + if (socketType == QAbstractSocket::TcpSocket) socketTypeStr = QStringLiteral("TcpSocket"); + else if (socketType == QAbstractSocket::UdpSocket) socketTypeStr = QStringLiteral("UdpSocket"); qDebug("QNativeSocketEnginePrivate::fetchConnectionParameters() localAddress == %s, localPort = %i, peerAddress == %s, peerPort = %i, socketProtocol == %s, socketType == %s", localAddress.toString().toLatin1().constData(), localPort, peerAddress.toString().toLatin1().constData(), peerPort, socketProtocolStr.toLatin1().constData(), socketTypeStr.toLatin1().constData()); #endif @@ -1487,8 +1487,8 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len) } #if defined (QNATIVESOCKETENGINE_DEBUG) - qDebug("QNativeSocketEnginePrivate::nativeWrite(%p \"%s\", %li) == %li", - data, qt_prettyDebug(data, qMin((int)ret, 16), (int)ret).data(), (int)len, (int)ret); + qDebug("QNativeSocketEnginePrivate::nativeWrite(%p \"%s\", %lli) == %lli", + data, qt_prettyDebug(data, qMin(int(ret), 16), int(ret)).data(), len, ret); #endif return ret; @@ -1530,11 +1530,11 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxLength) #if defined (QNATIVESOCKETENGINE_DEBUG) if (ret != -2) { - qDebug("QNativeSocketEnginePrivate::nativeRead(%p \"%s\", %li) == %li", - data, qt_prettyDebug(data, qMin((int)bytesRead, 16), (int)bytesRead).data(), (int)maxLength, (int)ret); + qDebug("QNativeSocketEnginePrivate::nativeRead(%p \"%s\", %lli) == %lli", + data, qt_prettyDebug(data, qMin(int(bytesRead), 16), int(bytesRead)).data(), maxLength, ret); } else { - qDebug("QNativeSocketEnginePrivate::nativeRead(%p, %li) == -2 (WOULD BLOCK)", - data, int(maxLength)); + qDebug("QNativeSocketEnginePrivate::nativeRead(%p, %lli) == -2 (WOULD BLOCK)", + data, maxLength); } #endif From 1e4e006c3f6e8cbd0092fe882bc23a2280352a91 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 11 May 2019 13:37:12 +0200 Subject: [PATCH 130/172] QPainter: mark obsolete RenderHints as deprecated RenderHint::HighQualityAntialiasing and NonCosmeticDefaultPen are obsolete since Qt5 but not marked as such. Therefore add Q_DECL_ENUMERATOR_DEPRECATED_X now so those two enumerations can be removed with Qt6. [ChangeLog][QtGui][QPainter] HighQualityAntialiasing and NonCosmeticDefaultPen are marked as deprecated and don't have an effect anymore Change-Id: Ib0c966a078a1d23d492d0255288e2066c50e87b6 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Eirik Aavitsland --- src/gui/opengl/qopenglpaintengine.cpp | 5 ++++- src/gui/painting/qpaintengine_raster.cpp | 6 +++++- src/gui/painting/qpainter.h | 6 ++++-- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 5 ++++- .../platforms/direct2d/qwindowsdirect2dpaintengine.cpp | 6 +++++- .../qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 2 +- .../graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 8 ++++---- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 2 +- tests/benchmarks/opengl/main.cpp | 5 ----- 9 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 042b9ebd79b..c087326068f 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1475,7 +1475,10 @@ void QOpenGL2PaintEngineEx::renderHintsChanged() if (!QOpenGLContext::currentContext()->isOpenGLES()) { Q_D(QOpenGL2PaintEngineEx); if ((state()->renderHints & QPainter::Antialiasing) - || (state()->renderHints & QPainter::HighQualityAntialiasing)) +#if QT_DEPRECATED_SINCE(5, 14) + || (state()->renderHints & QPainter::HighQualityAntialiasing) +#endif + ) d->funcs.glEnable(GL_MULTISAMPLE); else d->funcs.glDisable(GL_MULTISAMPLE); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 64183c2be6e..461ad51200f 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -904,7 +904,11 @@ void QRasterPaintEngine::renderHintsChanged() bool was_aa = s->flags.antialiased; bool was_bilinear = s->flags.bilinear; - s->flags.antialiased = bool(s->renderHints & (QPainter::Antialiasing | QPainter::HighQualityAntialiasing)); + s->flags.antialiased = bool(s->renderHints & QPainter::Antialiasing); +#if QT_DEPRECATED_SINCE(5, 14) + if (s->renderHints & QPainter::HighQualityAntialiasing) + s->flags.antialiased = true; +#endif s->flags.bilinear = bool(s->renderHints & QPainter::SmoothPixmapTransform); s->flags.legacy_rounding = !bool(s->renderHints & QPainter::Antialiasing) && bool(s->renderHints & QPainter::Qt4CompatiblePainting); diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 843f24e3e11..3394da63c72 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -89,8 +89,10 @@ public: Antialiasing = 0x01, TextAntialiasing = 0x02, SmoothPixmapTransform = 0x04, - HighQualityAntialiasing = 0x08, - NonCosmeticDefaultPen = 0x10, +#if QT_DEPRECATED_SINCE(5, 14) + HighQualityAntialiasing Q_DECL_ENUMERATOR_DEPRECATED_X("Use Antialiasing instead") = 0x08, + NonCosmeticDefaultPen Q_DECL_ENUMERATOR_DEPRECATED_X("Default pen is non-cosmetic now") = 0x10, +#endif Qt4CompatiblePainting = 0x20, LosslessImageRendering = 0x40, }; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index cc97bed3f71..e8ff40304e8 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1393,7 +1393,10 @@ void QGL2PaintEngineEx::renderHintsChanged() #if !defined(QT_OPENGL_ES_2) if (!d->ctx->contextHandle()->isOpenGLES()) { if ((state()->renderHints & QPainter::Antialiasing) - || (state()->renderHints & QPainter::HighQualityAntialiasing)) +#if QT_DEPRECATED_SINCE(5, 14) + || (state()->renderHints & QPainter::HighQualityAntialiasing) +#endif + ) d->glEnable(GL_MULTISAMPLE); else d->glDisable(GL_MULTISAMPLE); diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp index cf3e88d54e1..d7aba66b2f7 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp @@ -943,7 +943,11 @@ public: // Default path (no optimization) if (!(path.shape() == QVectorPath::LinesHint || path.shape() == QVectorPath::PolygonHint) - || !pen.dashBrush || q->state()->renderHints.testFlag(QPainter::HighQualityAntialiasing)) { + || !pen.dashBrush +#if QT_DEPRECATED_SINCE(5, 14) + || q->state()->renderHints.testFlag(QPainter::HighQualityAntialiasing) +#endif + || q->state()->renderHints.testFlag(QPainter::Antialiasing)) { ComPtr geometry = vectorPathToID2D1PathGeometry(path); if (!geometry) { qWarning("%s: Could not convert path to d2d geometry", __FUNCTION__); diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 4a301337ef0..530c3bb4645 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -330,7 +330,7 @@ public: { // Make sure QGraphicsProxyWidget::paint does not modify the render hints set on the painter. painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform - | QPainter::NonCosmeticDefaultPen | QPainter::TextAntialiasing); + | QPainter::TextAntialiasing); const QPainter::RenderHints oldRenderHints = painter->renderHints(); QGraphicsProxyWidget::paint(painter, option, widget); QCOMPARE(painter->renderHints(), oldRenderHints); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 6e42758122e..52cc7ed1285 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -352,8 +352,8 @@ void tst_QGraphicsView::renderHints() view.setScene(&scene); - view.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | QPainter::NonCosmeticDefaultPen); - QCOMPARE(view.renderHints(), QPainter::TextAntialiasing | QPainter::Antialiasing | QPainter::NonCosmeticDefaultPen); + view.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing); + QCOMPARE(view.renderHints(), QPainter::TextAntialiasing | QPainter::Antialiasing); QCOMPARE(item->hints, 0); view.show(); @@ -361,8 +361,8 @@ void tst_QGraphicsView::renderHints() view.repaint(); QTRY_COMPARE(item->hints, view.renderHints()); - view.setRenderHints(QPainter::Antialiasing | QPainter::NonCosmeticDefaultPen); - QCOMPARE(view.renderHints(), QPainter::Antialiasing | QPainter::NonCosmeticDefaultPen); + view.setRenderHints(QPainter::Antialiasing); + QCOMPARE(view.renderHints(), QPainter::Antialiasing); view.repaint(); QTRY_COMPARE(item->hints, view.renderHints()); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index fb40674d98f..19b745768aa 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -7056,7 +7056,7 @@ void tst_QWidget::renderWithPainter() // Make sure QWidget::render does not modify the render hints set on the painter. painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform - | QPainter::NonCosmeticDefaultPen | QPainter::TextAntialiasing); + | QPainter::TextAntialiasing); QPainter::RenderHints oldRenderHints = painter.renderHints(); widget.render(&painter); QCOMPARE(painter.renderHints(), oldRenderHints); diff --git a/tests/benchmarks/opengl/main.cpp b/tests/benchmarks/opengl/main.cpp index 5008f1592b9..0886c0e55be 100644 --- a/tests/benchmarks/opengl/main.cpp +++ b/tests/benchmarks/opengl/main.cpp @@ -76,7 +76,6 @@ void OpenGLBench::initTestCase() QPainter p(pb); p.setRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::HighQualityAntialiasing); p.drawImage(0, 0, QImage(256, 256, QImage::Format_ARGB32_Premultiplied)); } @@ -120,7 +119,6 @@ void OpenGLBench::imageDrawing() QPainter p(pb); p.setRenderHint(QPainter::SmoothPixmapTransform, smoothPixmapTransform); p.setRenderHint(QPainter::Antialiasing, highQualityAntialiasing); - p.setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing); QBENCHMARK { if (pixmap) { @@ -182,7 +180,6 @@ void OpenGLBench::pathDrawing() dummy.addRect(-1, -1, 2, 2); QPainter p(pb); p.setRenderHint(QPainter::Antialiasing, highQualityAntialiasing); - p.setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing); p.translate(pb->width() / 2, pb->height() / 2); p.rotate(30); p.drawPath(dummy); @@ -196,7 +193,6 @@ void OpenGLBench::pathDrawing() QBENCHMARK { p.setRenderHint(QPainter::Antialiasing, highQualityAntialiasing); - p.setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing); p.rotate(0.01); p.drawPath(path); @@ -227,7 +223,6 @@ void OpenGLBench::startupCost() QGLPixelBuffer buffer(512, 512); QPainter p(&buffer); p.setRenderHint(QPainter::Antialiasing, highQualityAntialiasing); - p.setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing); p.translate(buffer.width() / 2, buffer.height() / 2); p.drawPath(path); From ee6b19042f9a1a1e4d240e8216224e17dba93079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Fri, 21 Jun 2019 10:31:30 +0200 Subject: [PATCH 131/172] Fix 'make check' for android-mingw32 g_options.buildPath did not have native separators. This caused INSTALL_ROOT to not have native path separators, which again made 'mingw32-make check' fail to deploy the .apk. (The actual failure was that mkdir failed because it did not accept paths with forward-slashes, so the install_target rule failed. For the record, the command of that rule had the following call to mkdir: mkdir $(INSTALL_ROOT:@msyshack@%=%)\libs\x86 Change-Id: Id792c36986b52a527546d48aa9f7d9587e7a18d9 Reviewed-by: BogDan Vatra Reviewed-by: Frederik Gladhorn --- src/tools/androidtestrunner/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp index bb69b7b9149..e6d6f723541 100644 --- a/src/tools/androidtestrunner/main.cpp +++ b/src/tools/androidtestrunner/main.cpp @@ -454,7 +454,7 @@ int main(int argc, char *argv[]) if (!g_options.makeCommand.isEmpty()) { // we need to run make INSTALL_ROOT=path install to install the application file(s) first if (!execCommand(QStringLiteral("%1 INSTALL_ROOT=%2 install") - .arg(g_options.makeCommand, g_options.buildPath), nullptr, g_options.verbose)) { + .arg(g_options.makeCommand, QDir::toNativeSeparators(g_options.buildPath)), nullptr, g_options.verbose)) { return 1; } } From 2021b36ebdbdd1da1595f281a694b54beb1b23a3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 2 Jul 2019 20:48:40 -0300 Subject: [PATCH 132/172] QPluginLoader: fix failing test comparing the Qt version We stopped storing the patch release number of Qt in the plugin metadata in commit 7bd79b3cffbbbece23867c5e111a3dd2ebcad016 (5.13), to make it simpler to parse the validity of plugins before decoding the CBOR payload. Fixes: QTBUG-76855 Change-Id: I6aed4df6a12e43c3ac8efffd15adbbf83e928866 Reviewed-by: Liang Qi --- tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 4316ea14ea6..85763b03885 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -549,7 +549,8 @@ void tst_QPluginLoader::staticPlugins() } QVERIFY(found); - QCOMPARE(metaData.value("version").toInt(), QT_VERSION); + // We don't store the patch release version anymore (since 5.13) + QCOMPARE(metaData.value("version").toInt() / 0x100, QT_VERSION / 0x100); QCOMPARE(metaData.value("IID").toString(), "SomeIID"); QCOMPARE(metaData.value("ExtraMetaData"), QJsonArray({ "StaticPlugin", "foo" })); } From fb353592261e04896ad417ce5ace8adda1fe9fdf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 1 Jul 2019 10:30:14 +0200 Subject: [PATCH 133/172] [docs] Fix issues in QRect/QMargin API docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix grammar in op-(QRect, QMargin) - Correct shunk for grown in op-(QRectF, QMarginsF) Change-Id: Ia0dbd933cc9f6ed5e0dad05a27794c1135c794ed Reviewed-by: Mårten Nordheim --- src/corelib/tools/qrect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 6e51deebea0..c8301e25908 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -1194,7 +1194,7 @@ bool QRect::intersects(const QRect &r) const Q_DECL_NOTHROW \fn QRect operator-(const QRect &lhs, const QMargins &rhs) \relates QRect - Returns the \a lhs rectangle shrunken by the \a rhs margins. + Returns the \a lhs rectangle shrunk by the \a rhs margins. \since 5.3 */ @@ -2417,7 +2417,7 @@ QRect QRectF::toAlignedRect() const Q_DECL_NOTHROW \relates QRectF \since 5.3 - Returns the \a lhs rectangle grown by the \a rhs margins. + Returns the \a lhs rectangle shrunk by the \a rhs margins. */ /*! From 8d414e67941fdc45ab682b763a119ecc71291483 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 15:32:50 +0200 Subject: [PATCH 134/172] Mark QObject::deleteLater() as \threadsafe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because it is. It's just QCoreApplication::postEvent(), which is thread-safe. It also _has_ to be, because we recommend to use deleteLater() to delete QObjects that live in another thread: Quoting the ~QObject() docs: > Warning: Deleting a QObject while pending events are waiting to be delivered > can cause a crash. You must not delete the QObject directly if it exists in > a different thread than the one currently executing. Use deleteLater() > instead, which will cause the event loop to delete the object after all > pending events have been delivered to it. If deleteLater() is not thread-safe, it cannot be used for one of its intended purposes. Change-Id: I333d506b42bdfcdff00fe6cefa234c21865625a6 Reviewed-by: Mårten Nordheim --- src/corelib/kernel/qobject.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 68c5460b6a8..d685eaf27f2 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2163,6 +2163,8 @@ void QObject::removeEventFilter(QObject *obj) */ /*! + \threadsafe + Schedules this object for deletion. The object will be deleted when control returns to the event From 6ff0614b61b8645ec7ca4ea40501a0b6719a92fd Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 20 Jun 2019 13:07:04 +0200 Subject: [PATCH 135/172] Handle multiple font-families in face attribute This seems to be a common use case, and to be expected from pastes of MSWord documents. Change-Id: I5849d7f51408e76f15a0b03c2118649f118af1d6 Fixes: QTBUG-66794 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/text/qtexthtmlparser.cpp | 11 ++++++++- .../text/qtextdocument/tst_qtextdocument.cpp | 24 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 895232e4c70..929db40e5da 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1505,7 +1505,16 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) n -= 3; node->charFormat.setProperty(QTextFormat::FontSizeAdjustment, n); } else if (key == QLatin1String("face")) { - node->charFormat.setFontFamily(value); + if (value.contains(QLatin1Char(','))) { + const QStringList values = value.split(QLatin1Char(',')); + QStringList families; + for (const QString &family : values) + families << family.trimmed(); + node->charFormat.setFontFamilies(families); + node->charFormat.setFontFamily(families.at(0)); + } else { + node->charFormat.setFontFamily(value); + } } else if (key == QLatin1String("color")) { QColor c; c.setNamedColor(value); if (!c.isValid()) diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index e4ee778f64f..591fafc7fb3 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -188,6 +188,9 @@ private slots: void lineHeightType(); void cssLineHeightMultiplier(); + + void fontTagFace(); + private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); @@ -3498,5 +3501,26 @@ void tst_QTextDocument::cssLineHeightMultiplier() } } +void tst_QTextDocument::fontTagFace() +{ + { + QTextDocument td; + td.setHtml("Foobar"); + QTextFragment fragment = td.begin().begin().fragment(); + QTextCharFormat format = fragment.charFormat(); + QCOMPARE(format.fontFamily(), QLatin1String("Times")); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextFragment fragment = td.begin().begin().fragment(); + QTextCharFormat format = fragment.charFormat(); + QCOMPARE(format.fontFamily(), QLatin1String("Times")); + QStringList expectedFamilies = { QLatin1String("Times"), QLatin1String("serif") }; + QCOMPARE(format.fontFamilies().toStringList(), expectedFamilies); + } +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" From 0f92f2f35d55f2de545e8472c6b240c8fd0bb53f Mon Sep 17 00:00:00 2001 From: Felix Barz Date: Sun, 30 Jun 2019 20:43:03 +0200 Subject: [PATCH 136/172] Add custom verb support for WASM HTTP requests The QNetworkReply implementation for Qt for WebAssembly now supports usage of the QNetworkAccessManager::sendCustomRequest, making it possible to send requests with custom verbs. [ChangeLog][QtNetwork][QNetworkAccessManager] Fixed QNetworkAccessManager::sendCustomRequest for Qt For WebAssembly. Fixes: QTBUG-76775 Change-Id: I9394ffef110fce4ed2c877893631bedc7631f71e Reviewed-by: Lorn Potter --- src/network/access/qnetworkreplywasmimpl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index 9f6422a107f..ee91dc20b33 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -236,6 +236,7 @@ QNetworkReplyWasmImpl::~QNetworkReplyWasmImpl() QByteArray QNetworkReplyWasmImpl::methodName() const { + const Q_D( QNetworkReplyWasmImpl); switch (operation()) { case QNetworkAccessManager::HeadOperation: return "HEAD"; @@ -247,6 +248,8 @@ QByteArray QNetworkReplyWasmImpl::methodName() const return "POST"; case QNetworkAccessManager::DeleteOperation: return "DELETE"; + case QNetworkAccessManager::CustomOperation: + return d->request.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray(); default: break; } From e40a139abf6bc191ad10c22734848a5d1176cc76 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Jul 2019 15:28:20 +0200 Subject: [PATCH 137/172] QtWidgets: Fix wrong screen returned by newly added QWidgetPrivate::associatedScreen() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWidgetPrivate::windowHandle() should not return nullptr from the WindowHandleMode::Direct branch in case WindowHandleMode::Closest was passed. Ameds eed9a8fbd300dafb2802b6c09c018fbda4e13ef1. Task-number: QTBUG-62094 Task-number: QTBUG-73231 Change-Id: Ia55fff15f0a499cef9525e53111ddd55b2e012d0 Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index f686341f6ef..9f4098a88ab 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1255,8 +1255,10 @@ void QWidgetPrivate::createRecursively() QWindow *QWidgetPrivate::windowHandle(WindowHandleMode mode) const { if (mode == WindowHandleMode::Direct || mode == WindowHandleMode::Closest) { - if (QTLWExtra *x = maybeTopData()) - return x->window; + if (QTLWExtra *x = maybeTopData()) { + if (x->window != nullptr || mode == WindowHandleMode::Direct) + return x->window; + } } if (mode == WindowHandleMode::Closest) { if (auto nativeParent = q_func()->nativeParentWidget()) { From e1c9276c778b66d5f7fd71f01c26338f3d6f2c5e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 2 Jul 2019 10:16:43 +0200 Subject: [PATCH 138/172] Optimize QSet set operations Replace the identity check with a check for the underlying QHash objects being shared and replace backwards iteration, which is really forwards iteration with wrapping at bucket boundaries, with forward iteration. QSet cannot contain duplicates, so the order in which the RHS elements are presented to the algorithms does not matter. Change-Id: Iad8528e3a9501b14cb85601b221a848aad91480c Reviewed-by: Lars Knoll --- src/corelib/tools/qset.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 83e574bf1cc..98caabfb575 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -284,11 +284,9 @@ Q_INLINE_TEMPLATE void QSet::reserve(int asize) { q_hash.reserve(asize); } template Q_INLINE_TEMPLATE QSet &QSet::unite(const QSet &other) { - QSet copy(other); - typename QSet::const_iterator i = copy.constEnd(); - while (i != copy.constBegin()) { - --i; - insert(*i); + if (!q_hash.isSharedWith(other.q_hash)) { + for (const T &e : other) + insert(e); } return *this; } @@ -306,11 +304,9 @@ Q_INLINE_TEMPLATE QSet &QSet::intersect(const QSet &other) copy2 = *this; *this = copy1; } - typename QSet::const_iterator i = copy1.constEnd(); - while (i != copy1.constBegin()) { - --i; - if (!copy2.contains(*i)) - remove(*i); + for (const auto &e : qAsConst(copy1)) { + if (!copy2.contains(e)) + remove(e); } return *this; } @@ -346,14 +342,11 @@ Q_INLINE_TEMPLATE bool QSet::intersects(const QSet &other) const template Q_INLINE_TEMPLATE QSet &QSet::subtract(const QSet &other) { - if (&other == this) { + if (q_hash.isSharedWith(other.q_hash)) { clear(); } else { - auto i = other.constEnd(); - while (i != other.constBegin()) { - --i; - remove(*i); - } + for (const auto &e : other) + remove(e); } return *this; } From 33fdd5c83331290a52fdefcff56e49e6c0409711 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 3 Jul 2019 10:40:30 +0200 Subject: [PATCH 139/172] Fix a warning treated as error - 'importDevice not used' Change-Id: Id48ff52d6532cf3585648addd498cdddccbcb994 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 646f0aef136..d7c1607e576 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -3829,6 +3829,7 @@ QRhi *QRhi::create(Implementation impl, QRhiInitParams *params, Flags flags, QRh static_cast(importDevice)); break; #else + Q_UNUSED(importDevice); qWarning("This build of Qt has no Vulkan support"); break; #endif From f99bbfb9ea7a7c96b2fbb7aee2d1d1a9056ca4e7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 19 May 2019 23:25:12 +0200 Subject: [PATCH 140/172] QFseventsFileSystemWatcherEngine: port some Java-style iterators to ranged-for MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amends b03385f9cff7acc2b37933f493e3eff2d8bbef59. Java-style iterators are scheduled to be deprecated. The general pattern used in the patch is that instead of copying an input list, then iterating over the copy with some calls to it.remove() (which leads to quadratic-complexity loops), we simply copy conditionally (a la remove_copy_if instead of remove_if). To make clearer what's going on, rename the outgoing list to 'unhandled'. To avoid having to touch too much of the loops' structure, which sometimes is quite convoluted, use qScopeGuard to do the append to 'unhandled', unless the original code removed the element. Change-Id: I808a939b9c816b329ee87620e0a3461fee6e3e40 Reviewed-by: Thiago Macieira Reviewed-by: Mårten Nordheim --- src/corelib/io/qfilesystemwatcher_fsevents.mm | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm index fb3b6f86fd8..6194bf7c713 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.mm +++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm @@ -50,6 +50,7 @@ #include #include #include +#include #undef FSEVENT_DEBUG #ifdef FSEVENT_DEBUG @@ -338,10 +339,10 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, bool needsRestart = false; WatchingState oldState = watchingState; - QStringList p = paths; - QMutableListIterator it(p); - while (it.hasNext()) { - QString origPath = it.next().normalized(QString::NormalizationForm_C); + QStringList unhandled; + for (const QString &path : paths) { + auto sg = qScopeGuard([&]{ unhandled.push_back(path); }); + QString origPath = path.normalized(QString::NormalizationForm_C); QString realPath = origPath; if (realPath.endsWith(QDir::separator())) realPath = realPath.mid(0, realPath.size() - 1); @@ -362,17 +363,17 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, continue; directories->append(origPath); watchedPath = realPath; - it.remove(); } else { if (files->contains(origPath)) continue; files->append(origPath); - it.remove(); watchedPath = fi.path(); parentPath = watchedPath; } + sg.dismiss(); + for (PathRefCounts::const_iterator i = watchingState.watchedPaths.begin(), ei = watchingState.watchedPaths.end(); i != ei; ++i) { if (watchedPath.startsWith(i.key() % QDir::separator())) { @@ -409,14 +410,14 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, // ok, something went wrong, let's try to restore the previous state watchingState = std::move(oldState); // and because we don't know which path caused the issue (if any), fail on all of them - p = paths; + unhandled = paths; if (wasRunning) startStream(); } } - return p; + return unhandled; } QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &paths, @@ -430,10 +431,9 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat bool needsRestart = false; WatchingState oldState = watchingState; - QStringList p = paths; - QMutableListIterator it(p); - while (it.hasNext()) { - QString origPath = it.next(); + QStringList unhandled; + for (const QString &origPath : paths) { + auto sg = qScopeGuard([&]{ unhandled.push_back(origPath); }); QString realPath = origPath; if (realPath.endsWith(QDir::separator())) realPath = realPath.mid(0, realPath.size() - 1); @@ -447,7 +447,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat needsRestart |= derefPath(dirIt->dirInfo.watchedPath); watchingState.watchedDirectories.erase(dirIt); directories->removeAll(origPath); - it.remove(); + sg.dismiss(); DEBUG("Removed directory '%s'", qPrintable(realPath)); } } else { @@ -463,7 +463,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat if (filesInDir.isEmpty()) watchingState.watchedFiles.erase(pIt); files->removeAll(origPath); - it.remove(); + sg.dismiss(); DEBUG("Removed file '%s'", qPrintable(realPath)); } } @@ -479,7 +479,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat } } - return p; + return unhandled; } // Returns false if FSEventStream* calls failed for some mysterious reason, true if things got a From f70905448f612f52d4c3034faee61fc103b9eb7c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 May 2019 13:55:07 +0200 Subject: [PATCH 141/172] Add QT_NO_JAVA_STYLE_ITERATORS and mark QtBase free of it ... except for tests, which manually undefine the macro. Like QT_NO_FOREACH, this is a technical way to keep JSI-free modules JSI-free going forward. Change-Id: Icf1342da00a700f42f9e32a253d1cdb94c38dd7e Reviewed-by: Lars Knoll --- .qmake.conf | 2 ++ src/corelib/tools/qbytearraylist.h | 3 +++ src/corelib/tools/qiterator.h | 9 +++++++++ src/corelib/tools/qset.h | 2 ++ src/corelib/tools/qstringlist.h | 2 ++ tests/auto/corelib/thread/qfuture/qfuture.pro | 1 + tests/auto/corelib/tools/collections/collections.pro | 1 + tests/auto/corelib/tools/qhash/qhash.pro | 2 ++ tests/auto/corelib/tools/qmap/qmap.pro | 2 ++ tests/auto/corelib/tools/qset/qset.pro | 2 ++ 10 files changed, 26 insertions(+) diff --git a/.qmake.conf b/.qmake.conf index 08e1a4723c3..5c64c109814 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,6 +1,8 @@ load(qt_build_config) CONFIG += warning_clean +DEFINES += QT_NO_JAVA_STYLE_ITERATORS + QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h index 1261e1757ce..0250b649b8a 100644 --- a/src/corelib/tools/qbytearraylist.h +++ b/src/corelib/tools/qbytearraylist.h @@ -48,8 +48,11 @@ QT_BEGIN_NAMESPACE +#if !defined(QT_NO_JAVA_STYLE_ITERATORS) typedef QListIterator QByteArrayListIterator; typedef QMutableListIterator QMutableByteArrayListIterator; +#endif + #ifndef Q_CLANG_QDOC typedef QList QByteArrayList; diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h index 449d1049a05..84a0e116ca0 100644 --- a/src/corelib/tools/qiterator.h +++ b/src/corelib/tools/qiterator.h @@ -44,6 +44,8 @@ QT_BEGIN_NAMESPACE +#if !defined(QT_NO_JAVA_STYLE_ITERATORS) + #define Q_DECLARE_SEQUENTIAL_ITERATOR(C) \ \ template \ @@ -179,6 +181,13 @@ public: \ n = c->end(); return false; } \ }; +#else // QT_NO_JAVA_STYLE_ITERATORS +#define Q_DECLARE_SEQUENTIAL_ITERATOR(C) +#define Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(C) +#define Q_DECLARE_ASSOCIATIVE_ITERATOR(C) +#define Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(C) +#endif // QT_NO_JAVA_STYLE_ITERATORS + template class QKeyValueIterator { diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 98caabfb575..19d6982133b 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -402,6 +402,7 @@ QList QList::fromSet(const QSet &set) Q_DECLARE_SEQUENTIAL_ITERATOR(Set) +#if !defined(QT_NO_JAVA_STYLE_ITERATORS) template class QMutableSetIterator { @@ -433,6 +434,7 @@ public: { while (c->constBegin() != i) if (*(n = --i) == t) return true; n = c->end(); return false; } }; +#endif // QT_NO_JAVA_STYLE_ITERATORS QT_END_NAMESPACE diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index 45f51bfcc6d..a464d443dcf 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -54,8 +54,10 @@ QT_BEGIN_NAMESPACE class QRegExp; class QRegularExpression; +#if !defined(QT_NO_JAVA_STYLE_ITERATORS) typedef QListIterator QStringListIterator; typedef QMutableListIterator QMutableStringListIterator; +#endif class QStringList; diff --git a/tests/auto/corelib/thread/qfuture/qfuture.pro b/tests/auto/corelib/thread/qfuture/qfuture.pro index b1667760d6e..1f21130af78 100644 --- a/tests/auto/corelib/thread/qfuture/qfuture.pro +++ b/tests/auto/corelib/thread/qfuture/qfuture.pro @@ -3,3 +3,4 @@ TARGET = tst_qfuture QT = core core-private testlib SOURCES = tst_qfuture.cpp DEFINES += QT_STRICT_ITERATORS +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/collections/collections.pro b/tests/auto/corelib/tools/collections/collections.pro index 5c04515fa03..b074fa93380 100644 --- a/tests/auto/corelib/tools/collections/collections.pro +++ b/tests/auto/corelib/tools/collections/collections.pro @@ -5,3 +5,4 @@ QT = core testlib # This test does not work with strict iterators DEFINES -= QT_STRICT_ITERATORS +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qhash/qhash.pro b/tests/auto/corelib/tools/qhash/qhash.pro index 79ffd4e9d12..e96c0d1bf19 100644 --- a/tests/auto/corelib/tools/qhash/qhash.pro +++ b/tests/auto/corelib/tools/qhash/qhash.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qhash QT = core testlib SOURCES = $$PWD/tst_qhash.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qmap/qmap.pro b/tests/auto/corelib/tools/qmap/qmap.pro index 27820a76c8b..2cc772720d1 100644 --- a/tests/auto/corelib/tools/qmap/qmap.pro +++ b/tests/auto/corelib/tools/qmap/qmap.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qmap QT = core testlib SOURCES = $$PWD/tst_qmap.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qset/qset.pro b/tests/auto/corelib/tools/qset/qset.pro index 10ae3307d11..d0c63371470 100644 --- a/tests/auto/corelib/tools/qset/qset.pro +++ b/tests/auto/corelib/tools/qset/qset.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_qset QT = core testlib SOURCES = tst_qset.cpp + +DEFINES -= QT_NO_JAVA_STYLE_ITERATORS From f883f8409f6867a9f16d1916bebc29f1debfaff0 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Tue, 11 Jun 2019 15:20:03 +0200 Subject: [PATCH 142/172] qtlite: Fix build with -no-feature-commandlineparser Change-Id: Ie7b7b119073691c0d3b6358f876298fc86cfe9e9 Reviewed-by: Tasuku Suzuki Reviewed-by: Timo Aarnipuro Reviewed-by: Kari Oikarinen --- src/corelib/kernel/qcoreapplication.cpp | 2 ++ src/corelib/kernel/qcoreapplication_p.h | 4 ++++ src/gui/kernel/qguiapplication.cpp | 2 ++ src/gui/kernel/qguiapplication_p.h | 2 ++ 4 files changed, 10 insertions(+) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e5b88c3c26d..9d8da70e471 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -227,12 +227,14 @@ bool QCoreApplicationPrivate::checkInstance(const char *function) return b; } +#if QT_CONFIG(commandlineparser) void QCoreApplicationPrivate::addQtOptions(QList *options) { options->append(QCommandLineOption(QStringLiteral("qmljsdebugger"), QStringLiteral("Activates the QML/JS debugger with a specified port. The value must be of format port:1234[,block]. \"block\" makes the application wait for a connection."), QStringLiteral("value"))); } +#endif void QCoreApplicationPrivate::processCommandLineArguments() { diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 0b9029b5fe7..3bad42d076c 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -52,7 +52,9 @@ // #include "QtCore/qcoreapplication.h" +#if QT_CONFIG(commandlineparser) #include "QtCore/qcommandlineoption.h" +#endif #include "QtCore/qtranslator.h" #if QT_CONFIG(settings) #include "QtCore/qsettings.h" @@ -105,7 +107,9 @@ public: static bool checkInstance(const char *method); +#if QT_CONFIG(commandlineparser) virtual void addQtOptions(QList *options); +#endif #ifndef QT_NO_QOBJECT bool sendThroughApplicationEventFilters(QObject *, QEvent *); diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index b8bfad4f164..ceb5055a9d3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1306,6 +1306,7 @@ static void init_plugins(const QList &pluginList) } } +#if QT_CONFIG(commandlineparser) void QGuiApplicationPrivate::addQtOptions(QList *options) { QCoreApplicationPrivate::addQtOptions(options); @@ -1357,6 +1358,7 @@ void QGuiApplicationPrivate::addQtOptions(QList *options) QGuiApplication::tr("Alias for --windowtitle."), QStringLiteral("title"))); } } +#endif // QT_CONFIG(commandlineparser) void QGuiApplicationPrivate::createPlatformIntegration() { diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 2ecde0354a5..afca7579eaa 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -92,7 +92,9 @@ public: virtual void notifyLayoutDirectionChange(); virtual void notifyActiveWindowChange(QWindow *previous); +#if QT_CONFIG(commandlineparser) void addQtOptions(QList *options) override; +#endif virtual bool shouldQuit() override; bool shouldQuitInternal(const QWindowList &processedWindows); From faf742b05d0564a58bfe0290e53e0b2844bc59c1 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 5 Mar 2018 09:21:44 +0100 Subject: [PATCH 143/172] dumpcpp: Run dumpcpp if the generated files do not exist at qmake time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By running dumpcpp if the files do not exist at qmake time we enable the dependency finder to find these files and set up the dependencies as appropriate. Since other changes ensure that dumpcpp will be called at the right time when building if the typelib changes, we no longer need to have the generated files dependent on the objects. As a result, we are able to prevent it from unnecessarily rebuilding everything if certain files are updated. Change-Id: I334f48c7a980aa8b893c14cb2a4687d3b2b7a4b9 Reviewed-by: Jörg Bornemann --- mkspecs/features/win32/dumpcpp.prf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mkspecs/features/win32/dumpcpp.prf b/mkspecs/features/win32/dumpcpp.prf index c8cb0dd24b6..d19da3d0778 100644 --- a/mkspecs/features/win32/dumpcpp.prf +++ b/mkspecs/features/win32/dumpcpp.prf @@ -22,15 +22,15 @@ dumpcpp_impl.depends += ${QMAKE_FILE_BASE}.h QMAKE_EXTRA_COMPILERS += dumpcpp_impl -# Create dependencies from every object file to our generated header files. -if(isEmpty(BUILDS)|build_pass):have_target:!contains(TEMPLATE, vc.*) { +# Call dumpcpp the first time if the files do not exist to help find dependencies +!build_pass:have_target:!contains(TEMPLATE, vc.*) { for(tlb, TYPELIBS) { + tlbCopy = $$replace(tlb, \", ) hdr = $$basename(tlb) - hdr = $$section(hdr, ., 0, -2).h - TYPELIB_HEADERS += $$hdr + hdr = $$section(hdr, ., 0, -2) + tmp_command = $$QMAKE_DUMPCPP $$system_quote($$absolute_path($$tlb, $$_PRO_FILE_PWD_)) \ + -o $$system_quote($$OUT_PWD/$$hdr) + qaxcontainer_compat: tmp_command += -compat + !exists($$OUT_PWD/$${hdr}.h): system($$tmp_command) } - - objtgt.target = $(OBJECTS) - objtgt.depends += $$TYPELIB_HEADERS - QMAKE_EXTRA_TARGETS += objtgt } From 1e4a973b7e048f15c8a331ab5085091db23c8a4e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 10 Dec 2018 10:40:54 +0100 Subject: [PATCH 144/172] Use QRegularExpression for filtering in QDirIterator Reduce our usage of QRegExp in preparation towards deprecating it. This also brings it in line with QDir that already uses QRegularExpression for filtering. Keep the old QRegExp based code around in bootstrapped mode, since qmake uses this functionality. Change-Id: I98b9d2875c30e17e406b6711dfe3265ba37624ac Reviewed-by: Samuel Gaist --- src/corelib/io/qdiriterator.cpp | 38 ++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 21214ee2732..303caf29a45 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -97,6 +97,9 @@ #include #include #include +#if QT_CONFIG(regularexpression) +#include +#endif #include #include @@ -136,8 +139,11 @@ public: const QDir::Filters filters; const QDirIterator::IteratorFlags iteratorFlags; -#ifndef QT_NO_REGEXP +#if defined(QT_BOOTSTRAPPED) + // ### Qt6: Get rid of this once we don't bootstrap qmake anymore QVector nameRegExps; +#elif QT_CONFIG(regularexpression) + QVector nameRegExps; #endif QDirIteratorPrivateIteratorStack fileEngineIterators; @@ -162,13 +168,21 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QFileSystemEntry &entry, const QS , filters(QDir::NoFilter == filters ? QDir::AllEntries : filters) , iteratorFlags(flags) { -#ifndef QT_NO_REGEXP +#if defined(QT_BOOTSTRAPPED) nameRegExps.reserve(nameFilters.size()); - for (int i = 0; i < nameFilters.size(); ++i) + for (const auto &filter : nameFilters) { nameRegExps.append( - QRegExp(nameFilters.at(i), + QRegExp(filter, (filters & QDir::CaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive, QRegExp::Wildcard)); + } +#elif QT_CONFIG(regularexpression) + nameRegExps.reserve(nameFilters.size()); + for (const auto &filter : nameFilters) { + QString re = QRegularExpression::anchoredPattern(QRegularExpression::wildcardToRegularExpression(filter)); + nameRegExps.append( + QRegularExpression(re, (filters & QDir::CaseSensitive) ? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption)); + } #endif QFileSystemMetaData metaData; if (resolveEngine) @@ -335,19 +349,23 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf return false; // name filter -#ifndef QT_NO_REGEXP +#if QT_CONFIG(regularexpression) || defined(QT_BOOTSTRAPPED) // Pass all entries through name filters, except dirs if the AllDirs if (!nameFilters.isEmpty() && !((filters & QDir::AllDirs) && fi.isDir())) { bool matched = false; - for (QVector::const_iterator iter = nameRegExps.constBegin(), - end = nameRegExps.constEnd(); - iter != end; ++iter) { - - QRegExp copy = *iter; + for (const auto &re : nameRegExps) { +#if defined(QT_BOOTSTRAPPED) + QRegExp copy = re; if (copy.exactMatch(fileName)) { matched = true; break; } +#else + if (re.match(fileName).hasMatch()) { + matched = true; + break; + } +#endif } if (!matched) return false; From c50362597a6f3a3541479b2a84937f406999b954 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 4 Jul 2019 01:37:24 +0900 Subject: [PATCH 145/172] Fix build without features.cursor Change-Id: Id7617e03f86a4dd7d1ada37c91cf792bca7f1d6d Reviewed-by: Volker Hilsheimer --- src/widgets/widgets/qtextedit.cpp | 4 ++++ src/widgets/widgets/qtextedit.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 8c1d7e7a03e..8599573e5a9 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -167,7 +167,9 @@ void QTextEditPrivate::init(const QString &html) QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool))); QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged())); QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(_q_cursorPositionChanged())); +#if QT_CONFIG(cursor) QObject::connect(control, SIGNAL(blockMarkerHovered(QTextBlock)), q, SLOT(_q_hoveredBlockWithMarkerChanged(QTextBlock))); +#endif QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus())); @@ -230,6 +232,7 @@ void QTextEditPrivate::_q_cursorPositionChanged() #endif } +#if QT_CONFIG(cursor) void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block) { Q_Q(QTextEdit); @@ -244,6 +247,7 @@ void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block) } viewport->setCursor(cursor); } +#endif void QTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode) { diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 09ef44b7b2a..5c8a3c77937 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -331,7 +331,9 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars()) Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &)) Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged()) +#if QT_CONFIG(cursor) Q_PRIVATE_SLOT(d_func(), void _q_hoveredBlockWithMarkerChanged(const QTextBlock &)) +#endif friend class QTextEditControl; friend class QTextDocument; friend class QWidgetTextControl; From 1bddb4ad7d33ba92ce4387bcaba55c2489dc6615 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 Oct 2017 15:31:25 +0100 Subject: [PATCH 146/172] QApplication::topLevelWidgets(): Avoid allocation of list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the QSet QWidgetPrivate::allWidgets directly instead of calling QApplication::allWidgets(), which allocates a QList. Change-Id: I16d289030cecefae7811d4b2c94f865f46f700d5 Reviewed-by: Marc Mutz Reviewed-by: Mårten Nordheim --- src/widgets/kernel/qapplication.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 58f63c0feda..c922aeccebf 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -111,6 +111,9 @@ #include +#include +#include + //#define ALIEN_DEBUG static void initResources() @@ -1658,12 +1661,12 @@ void QApplicationPrivate::notifyWindowIconChanged() QWidgetList QApplication::topLevelWidgets() { QWidgetList list; - QWidgetList all = allWidgets(); - - for (QWidgetList::ConstIterator it = all.constBegin(), cend = all.constEnd(); it != cend; ++it) { - QWidget *w = *it; - if (w->isWindow() && w->windowType() != Qt::Desktop) - list.append(w); + if (QWidgetPrivate::allWidgets != nullptr) { + const auto isTopLevelWidget = [] (const QWidget *w) { + return w->isWindow() && w->windowType() != Qt::Desktop; + }; + std::copy_if(QWidgetPrivate::allWidgets->cbegin(), QWidgetPrivate::allWidgets->cend(), + std::back_inserter(list), isTopLevelWidget); } return list; } From 656117100b52bb404828d02106fd0dee760b6019 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 30 Jun 2019 12:02:24 +0200 Subject: [PATCH 147/172] QSet docs: don't use std::find for lookups That code would normally call for QSet::find instead (Uniform Container Find cannot come soon enough). Since the code is showcasing a STL algorithm usage, port it to std::find_if to showcase a real use case. As a drive-by: fix the usage of endl with std::cout. (Ok, it's just a variable called "cout", and I'd argue that in example code "cout" is not the name of a QTextStream). Change-Id: I8686178b33c31552eb4d909a4089453d60994b79 Reviewed-by: Marc Mutz --- src/corelib/doc/snippets/code/doc_src_qset.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/doc/snippets/code/doc_src_qset.cpp b/src/corelib/doc/snippets/code/doc_src_qset.cpp index 4248c496422..96ef07738be 100644 --- a/src/corelib/doc/snippets/code/doc_src_qset.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qset.cpp @@ -131,9 +131,10 @@ while (i != set.end()) { //! [10] QSet set; ... -QSet::iterator it = std::find(set.begin(), set.end(), "Jeanette"); +const auto predicate = [](const QString &s) { return s.compare("Jeanette", Qt::CaseInsensitive) == 0; }; +QSet::iterator it = std::find_if(set.begin(), set.end(), predicate); if (it != set.end()) - cout << "Found Jeanette" << Qt::endl; + cout << "Found Jeanette" << endl; //! [10] @@ -150,9 +151,10 @@ for (i = set.begin(); i != set.end(); ++i) //! [12] QSet set; ... -QSet::iterator it = std::find(set.begin(), set.end(), "Jeanette"); +const auto predicate = [](const QString &s) { return s.compare("Jeanette", Qt::CaseInsensitive) == 0; }; +QSet::const_iterator it = std::find_if(set.cbegin(), set.cend(), predicate); if (it != set.constEnd()) - cout << "Found Jeanette" << Qt::endl; + cout << "Found Jeanette" << endl; //! [12] From ff561baabdf2f807ba4867e11f0dbed17ad4f8bf Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 4 Jul 2019 11:26:59 +0200 Subject: [PATCH 148/172] Testlib: Reset the global benchmark data only if it matches You can create multiple instances of QBenchmarkGlobalData as the ctor is public. The qmltest plugin does create a static one, but only conditionally assigns it to the singleton pointer. On shutdown the plugin is removed and the QBenchmarkGlobalData::current should only be reset by the dtor if it's actually pointing to the same object. Change-Id: I616c1ccf6f7a00abf1de342094da88481510bc7b Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/testlib/qbenchmark.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index 8d5543a0fcc..cbc009c9932 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -66,7 +66,8 @@ QBenchmarkGlobalData::QBenchmarkGlobalData() QBenchmarkGlobalData::~QBenchmarkGlobalData() { delete measurer; - QBenchmarkGlobalData::current = 0; + if (QBenchmarkGlobalData::current == this) + QBenchmarkGlobalData::current = nullptr; } void QBenchmarkGlobalData::setMode(Mode mode) From 7b17113e49b44ba5eec86831e3f697e98010f228 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 4 Jul 2019 14:01:32 +0900 Subject: [PATCH 149/172] Fix build without features.inotify -no-feature-inotify was ignored on Linux Change-Id: I65bab5b31740f10eacea6735119702a79df5c263 Reviewed-by: Volker Hilsheimer --- src/corelib/io/qfilesystemwatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index e3e4433a6b0..64c422c55aa 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -47,7 +47,7 @@ #include #include -#if defined(Q_OS_LINUX) || (defined(Q_OS_QNX) && !defined(QT_NO_INOTIFY)) +#if (defined(Q_OS_LINUX) || defined(Q_OS_QNX)) && QT_CONFIG(inotify) #define USE_INOTIFY #endif From be1e682572733ca5a0c3c65d049551daf8546f41 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 3 Jun 2019 21:24:15 +0900 Subject: [PATCH 150/172] Fix build without feature.xmlstreamreader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces a new feature called vkgen for the tool which depends on xmlstreamreader. Note that when features.vkgen is disabled, vulkan.pri will generate dummy qvulkanfunctions.h and qvulkanfunctions_p.h because buildsystem needs them. Task-number: QTBUG-76159 Change-Id: I03d526a0fd76a2d8b531940f37538cead109d9d3 Reviewed-by: Jörg Bornemann --- src/gui/configure.json | 7 ++++- src/gui/vulkan/vulkan.pri | 66 +++++++++++++++++++++------------------ src/src.pro | 8 +++-- 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/src/gui/configure.json b/src/gui/configure.json index c7bafb8925e..764e92a729a 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1357,9 +1357,14 @@ "condition": "features.opengl-desktop || features.opengl-dynamic || features.opengles2", "output": [ "publicFeature", "feature" ] }, + "vkgen": { + "label": "vkgen", + "condition": "features.xmlstreamreader", + "output": [ "privateFeature" ] + }, "vulkan": { "label": "Vulkan", - "condition": "libs.vulkan", + "condition": "features.vkgen && libs.vulkan", "output": [ "publicFeature" ] }, "openvg": { diff --git a/src/gui/vulkan/vulkan.pri b/src/gui/vulkan/vulkan.pri index 9bd73912353..5c902e8b827 100644 --- a/src/gui/vulkan/vulkan.pri +++ b/src/gui/vulkan/vulkan.pri @@ -17,39 +17,45 @@ qtConfig(vulkan) { QMAKE_USE += vulkan/nolink } -# Generate qvulkanfunctions.h, qvulkanfunctions_p.h, qvulkanfunctions_p.cpp -QMAKE_QVKGEN_INPUT = vulkan/vk.xml -QMAKE_QVKGEN_LICENSE_HEADER = $$QT_SOURCE_TREE/header.LGPL -qtPrepareTool(QMAKE_QVKGEN, qvkgen) +qtConfig(vkgen) { + # Generate qvulkanfunctions.h, qvulkanfunctions_p.h, qvulkanfunctions_p.cpp + QMAKE_QVKGEN_INPUT = vulkan/vk.xml + QMAKE_QVKGEN_LICENSE_HEADER = $$QT_SOURCE_TREE/header.LGPL + qtPrepareTool(QMAKE_QVKGEN, qvkgen) -qvkgen_h.commands = $$QMAKE_QVKGEN ${QMAKE_FILE_IN} $$shell_quote($$QMAKE_QVKGEN_LICENSE_HEADER) ${QMAKE_FILE_OUT_PATH}/${QMAKE_FILE_OUT_BASE} -qvkgen_h.output = $$OUT_PWD/vulkan/qvulkanfunctions.h -qvkgen_h.input = QMAKE_QVKGEN_INPUT -qtConfig(vulkan): \ - qvkgen_h.variable_out = HEADERS -else: \ - qvkgen_h.CONFIG += target_predeps no_link -QMAKE_EXTRA_COMPILERS += qvkgen_h + qvkgen_h.commands = $$QMAKE_QVKGEN ${QMAKE_FILE_IN} $$shell_quote($$QMAKE_QVKGEN_LICENSE_HEADER) ${QMAKE_FILE_OUT_PATH}/${QMAKE_FILE_OUT_BASE} + qvkgen_h.output = $$OUT_PWD/vulkan/qvulkanfunctions.h + qvkgen_h.input = QMAKE_QVKGEN_INPUT + qtConfig(vulkan): \ + qvkgen_h.variable_out = HEADERS + else: \ + qvkgen_h.CONFIG += target_predeps no_link + QMAKE_EXTRA_COMPILERS += qvkgen_h -qvkgen_ph.commands = $$escape_expand(\\n) -qvkgen_ph.output = $$OUT_PWD/vulkan/qvulkanfunctions_p.h -qvkgen_ph.input = QMAKE_QVKGEN_INPUT -qvkgen_ph.depends += $$OUT_PWD/vulkan/qvulkanfunctions.h -qtConfig(vulkan): \ - qvkgen_ph.variable_out = HEADERS -else: \ - qvkgen_ph.CONFIG += target_predeps no_link -QMAKE_EXTRA_COMPILERS += qvkgen_ph + qvkgen_ph.commands = $$escape_expand(\\n) + qvkgen_ph.output = $$OUT_PWD/vulkan/qvulkanfunctions_p.h + qvkgen_ph.input = QMAKE_QVKGEN_INPUT + qvkgen_ph.depends += $$OUT_PWD/vulkan/qvulkanfunctions.h + qtConfig(vulkan): \ + qvkgen_ph.variable_out = HEADERS + else: \ + qvkgen_ph.CONFIG += target_predeps no_link + QMAKE_EXTRA_COMPILERS += qvkgen_ph -qvkgen_pimpl.commands = $$escape_expand(\\n) -qvkgen_pimpl.output = $$OUT_PWD/vulkan/qvulkanfunctions_p.cpp -qvkgen_pimpl.input = QMAKE_QVKGEN_INPUT -qvkgen_pimpl.depends += $$OUT_PWD/vulkan/qvulkanfunctions_p.h -qtConfig(vulkan): \ - qvkgen_pimpl.variable_out = SOURCES -else: \ - qvkgen_pimpl.CONFIG += target_predeps no_link -QMAKE_EXTRA_COMPILERS += qvkgen_pimpl + qvkgen_pimpl.commands = $$escape_expand(\\n) + qvkgen_pimpl.output = $$OUT_PWD/vulkan/qvulkanfunctions_p.cpp + qvkgen_pimpl.input = QMAKE_QVKGEN_INPUT + qvkgen_pimpl.depends += $$OUT_PWD/vulkan/qvulkanfunctions_p.h + qtConfig(vulkan): \ + qvkgen_pimpl.variable_out = SOURCES + else: \ + qvkgen_pimpl.CONFIG += target_predeps no_link + QMAKE_EXTRA_COMPILERS += qvkgen_pimpl +} else { + # generate dummy files to make qmake happy + write_file($$OUT_PWD/vulkan/qvulkanfunctions.h) + write_file($$OUT_PWD/vulkan/qvulkanfunctions_p.h) +} # Ensure qvulkanfunctions.h gets installed correctly targ_headers.CONFIG += no_check_exist diff --git a/src/src.pro b/src/src.pro index b1afdd27a59..9ccc1e8f65e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -214,9 +214,11 @@ qtConfig(gui) { SUBDIRS += src_3rdparty_freetype src_platformsupport.depends += src_3rdparty_freetype } - SUBDIRS += src_tools_qvkgen - src_gui.depends += src_tools_qvkgen - TOOLS += src_tools_qvkgen + qtConfig(vkgen) { + SUBDIRS += src_tools_qvkgen + src_gui.depends += src_tools_qvkgen + TOOLS += src_tools_qvkgen + } SUBDIRS += src_gui src_platformsupport src_platformheaders qtConfig(opengl): SUBDIRS += src_openglextensions src_plugins.depends += src_gui src_platformsupport src_platformheaders From c4932f93d53a08401fc61460e1ab2fe3919d9e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Tue, 25 Jun 2019 11:39:52 +0200 Subject: [PATCH 151/172] Do not access invalid QAccessibleInterface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Noticed this when running Qt Creator against dev Change-Id: Ie75b2e0f2a77033ce0455d7ee3304193aa6e511c Reviewed-by: André de la Rocha --- .../platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index b2767983165..943c1ff3684 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -153,7 +153,7 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve int count = listacc->childCount(); for (int i = 0; i < count; ++i) { QAccessibleInterface *item = listacc->child(i); - if (item && item->text(QAccessible::Name) == event->value()) { + if (item && item->isValid() && item->text(QAccessible::Name) == event->value()) { if (!item->state().selected) { if (QAccessibleActionInterface *actionInterface = item->actionInterface()) actionInterface->doAction(QAccessibleActionInterface::toggleAction()); From bcd4b14026094d0077ad1069054676cc6da96251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Tue, 2 Jul 2019 17:11:20 +0200 Subject: [PATCH 152/172] Fix qFindTestData() to work with relative resource paths If the resource path 'base' was relative it would enter condition 3) in qFindTestData() and it would actually find the nonsensical "://data" as a viable candidate. We don't want to enter that case, but rather enter the subsequent ('Try resources') case Change-Id: I1928ba02c941e23fee4fec9052a1981e46fa59b7 Task-number: QTBUG-73512 Reviewed-by: Friedemann Kleint --- src/testlib/qtestcase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 10477238cb4..619376fd33e 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2206,7 +2206,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co } // 3. relative to test source. - if (found.isEmpty()) { + if (found.isEmpty() && qstrncmp(file, ":/", 2) != 0) { // srcdir is the directory containing the calling source file. QFileInfo srcdir = QFileInfo(QFile::decodeName(file)).path(); From 6061e6820b97c45100d2e761a9bb302c71ce3e62 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 23 May 2018 11:52:14 +0200 Subject: [PATCH 153/172] Initialize variables to make coverity happy Change-Id: Id574a114cbed04927ae380c6d97027cf4b351032 Reviewed-by: Thiago Macieira --- src/corelib/io/qtemporaryfile_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index 0fec88d3cd4..6bcff936b4a 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -145,10 +145,10 @@ public: bool isUnnamedFile() const override final; const QString &templateName; - quint32 fileMode; + quint32 fileMode = 0; int flags = 0; - bool filePathIsTemplate; - bool filePathWasTemplate; + bool filePathIsTemplate = true; + bool filePathWasTemplate = true; bool unnamedFile = false; }; From 78d67d17a6c108a419816b8bd47f78864ddbb07f Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 19 Jun 2019 17:43:19 +0200 Subject: [PATCH 154/172] CMake: Fix prl and library names on macOS for debug configurations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The paths to the libraries and prl files should have the "_debug" suffix for the debug configuration. This prefix is added to the TARGET when by qt_module.prf when doing a debug build, but not during a debug_and_release build. Make sure to strip the _debug suffix if it's there, and re-add it later always, to be consistent in both debug_and_release builds and in debug builds. Amends a12b6e7bf6688021c6af809d024958b59dfa3555. Task-number: QTBUG-38913 Task-number: QTBUG-75520 Change-Id: I29e88f2b991e2be06b23652d64edc768fa35a5ae Reviewed-by: Jörg Bornemann --- mkspecs/features/create_cmake.prf | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index c9910dda53d..00da9bd33f1 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -34,10 +34,20 @@ CMAKE_INCLUDE_NAME = $$eval(QT.$${MODULE}.name) # TARGET here is the one changed at the end of qt_module.prf, # which already contains the Qt5 prefix and QT_LIBINFIX suffix : -# Qt5Core_suffix, Qt5Network_suffix, Foo_suffix -# (or QtCore_suffix, Foo_suffix on macos with -framework) +# Qt5Core_{libinfix_suffix}, Qt5Network_{libinfix_suffix}, Foo_{libinfix_suffix} +# (or QtCore_{libinfix_suffix}, Foo_{libinfix_suffix} on macos with -framework). CMAKE_QT_STEM = $${TARGET} +# On macOS when building just a debug configuration which is not part of debug_and_release, +# $${TARGET} already contains a _debug suffix, as per the following call chain: +# qt_module.prf -> qt5LibraryTarget -> qtLibraryTarget -> qtPlatformTargetSuffix. +# Remove the _debug suffix in the stem, to keep all further uses of CMAKE_QT_STEM consistent. +# The _debug suffix is then re-added where needed regardless if it's a debug_and_release build +# or just debug. +darwin:!qt_framework:!debug_and_release:CONFIG(debug, debug|release) { + CMAKE_QT_STEM = $$replace(CMAKE_QT_STEM, _debug$, ) +} + !generated_privates { isEmpty(SYNCQT.INJECTED_PRIVATE_HEADER_FILES):isEmpty(SYNCQT.PRIVATE_HEADER_FILES): \ CMAKE_NO_PRIVATE_INCLUDES = true @@ -211,18 +221,18 @@ CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";") mac { !isEmpty(CMAKE_STATIC_TYPE) { - CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.a + CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a - CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.prl + CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.prl CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl } else { qt_framework { - CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM} + CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM}_debug CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.framework/$${CMAKE_QT_STEM} CMAKE_BUILD_IS_FRAMEWORK = "true" } else { - CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib + CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.$$eval(QT.$${MODULE}.VERSION).dylib CMAKE_LIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.$$eval(QT.$${MODULE}.VERSION).dylib } } From 6ad08b9cad4efefc72e64deaa0b720a3aab0fa54 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 20 Jun 2019 11:46:49 +0200 Subject: [PATCH 155/172] CMake: Fix handling of static dependencies that have spaces in path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The absolute paths of certain static dependencies can have spaces in them. The _qt5_$${CMAKE_MODULE_NAME}_process_prl_file fails to handle this, and simply replaces all spaces with semicolons, which obviously breaks the list of dependencies, and a consuming application fails to link with a message like: LINK : fatal error LNK1181: cannot open input file 'C:\Program.obj' This change partially restores the functionality that was added in 102e1822ffcdc9954d3c698f863734a8083e349c specifically the part that changes qmake to export an additional variable QMAKE_PRL_LIBS_FOR_CMAKE. This variable has the same content as QMAKE_PRL_LIBS except it uses a semicolon as a separator, so that CMake can correctly parse the separate lib entries. This is much cleaner than trying to parse the original QMAKE_PRL_LIBS variable with a complicated regular expression. Amends eda28621f6c1a68774719f382be53ec109123b18. Task-number: QTBUG-38913 Change-Id: I1d18fb779606505bc92320d8ce13232c7022e212 Reviewed-by: Jörg Bornemann --- mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in | 13 ++++++++++--- qmake/generators/makefile.cpp | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index 705e0a3c933..ba7d9575c0d 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -56,9 +56,16 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura get_filename_component(_qt5_install_libs \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib\" ABSOLUTE) if(EXISTS \"${prl_file_location}\") - file(STRINGS \"${prl_file_location}\" _prl_strings REGEX \"QMAKE_PRL_LIBS[ \\t]*=\") - string(REGEX REPLACE \"QMAKE_PRL_LIBS[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends ${_prl_strings}) - string(REGEX REPLACE \"[ \\t]+\" \";\" _static_depends ${_static_depends}) + file(STRINGS \"${prl_file_location}\" _prl_strings REGEX \"QMAKE_PRL_LIBS_FOR_CMAKE[ \\t]*=\") + + # file(STRINGS) replaces all semicolons read from the file with backslash semicolons. + # We need to do a reverse transformation in CMake. For that we replace all backslash + # semicolons with just semicolons, but due to the qmake substitution feature + # creating this file, we need to double the amount of backslashes, so the final file + # should have three backslashes and one semicolon. + string(REGEX REPLACE \"\\\\\\;\" \";\" _prl_strings \"${_prl_strings}\") + + string(REGEX REPLACE \"QMAKE_PRL_LIBS_FOR_CMAKE[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends \"${_prl_strings}\") string(REGEX REPLACE \"[ \\t]+\" \";\" _standard_libraries \"${CMAKE_CXX_STANDARD_LIBRARIES}\") set(_search_paths) string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\") diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 956deba25bb..a963c381789 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1023,6 +1023,14 @@ MakefileGenerator::writePrlFile(QTextStream &t) for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it) t << qv(project->values((*it).toKey())); t << endl; + + t << "QMAKE_PRL_LIBS_FOR_CMAKE = "; + QString sep; + for (ProStringList::Iterator it = libs.begin(); it != libs.end(); ++it) { + t << sep << project->values((*it).toKey()).join(';').replace('\\', "\\\\"); + sep = ';'; + } + t << endl; } } From 9b3e8b32f2657948591f6bdffea9d48291b8a69b Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 27 Jun 2019 15:48:30 +0200 Subject: [PATCH 156/172] Remove usages of deprecated APIs of corelib - Replaced the usages of deprecated APIs of corelib by corresponding alternatives in the library code and documentation. - Modified the tests to make them build when deprecated APIs disabled: * Made the the parts of the tests testing the deprecated APIs to be compiled conditionally, only when the corresponding methods are enabled. * If the test-case tests only the deprecated API, but not the corresponding replacement, added tests for the replacement. Task-number: QTBUG-76491 Task-number: QTBUG-76539 Task-number: QTBUG-76541 Change-Id: I62ed4a5b530a965ec3f6502c6480808f938921aa Reviewed-by: Volker Hilsheimer --- examples/widgets/doc/src/stardelegate.qdoc | 2 +- src/corelib/io/qsettings.cpp | 4 +- .../corelib/global/qlogging/tst_qlogging.cpp | 6 + .../corelib/io/qfileinfo/tst_qfileinfo.cpp | 4 + .../auto/corelib/io/qprocess/tst_qprocess.cpp | 251 +++++++++++++++--- .../qresourceengine/tst_qresourceengine.cpp | 60 ++++- .../corelib/io/qsettings/tst_qsettings.cpp | 7 +- .../kernel/qmetaobject/tst_qmetaobject.cpp | 2 +- .../kernel/qmetatype/tst_qmetatype.cpp | 20 ++ .../corelib/kernel/qvariant/tst_qvariant.cpp | 16 ++ .../tools/collections/tst_collections.cpp | 4 + .../tools/qalgorithms/tst_qalgorithms.cpp | 41 ++- .../qcommandlineparser_test_helper.cpp | 2 + tests/auto/corelib/tools/qline/tst_qline.cpp | 4 + .../qsharedpointer/tst_qsharedpointer.cpp | 108 +++++++- .../corelib/tools/qstring/tst_qstring.cpp | 10 +- .../tools/qstringref/tst_qstringref.cpp | 24 ++ .../qstandarditem/tst_qstandarditem.cpp | 2 + tests/auto/tools/qmake/tst_qmake.cpp | 2 +- tests/manual/qcursor/qcursorhighdpi/main.cpp | 2 +- 20 files changed, 499 insertions(+), 72 deletions(-) diff --git a/examples/widgets/doc/src/stardelegate.qdoc b/examples/widgets/doc/src/stardelegate.qdoc index 0b91723a512..b33fa3550f9 100644 --- a/examples/widgets/doc/src/stardelegate.qdoc +++ b/examples/widgets/doc/src/stardelegate.qdoc @@ -269,7 +269,7 @@ \codeline \snippet itemviews/stardelegate/main.cpp 4 - Notice the call to qVariantFromValue to convert a \c + Notice the call to QVariant::fromValue to convert a \c StarRating to a QVariant. \section1 Possible Extensions and Suggestions diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 9234a23f3a9..accde01f160 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2048,8 +2048,8 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, QPixmap, which are part of Qt GUI. In other words, there is no \c toColor(), \c toImage(), or \c toPixmap() functions in QVariant. - Instead, you can use the QVariant::value() or the qVariantValue() - template function. For example: + Instead, you can use the QVariant::value() template function. + For example: \snippet code/src_corelib_io_qsettings.cpp 0 diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 23507ec2e62..7dd2a468077 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -48,7 +48,9 @@ private slots: void defaultHandler(); void installMessageHandler(); +#if QT_DEPRECATED_SINCE(5, 0) void installMsgHandler(); +#endif void installBothHandler(); #ifdef QT_BUILD_INTERNAL @@ -112,7 +114,9 @@ void tst_qmessagehandler::initTestCase() void tst_qmessagehandler::cleanup() { +#if QT_DEPRECATED_SINCE(5, 0) qInstallMsgHandler(0); +#endif qInstallMessageHandler((QtMessageHandler)0); s_type = QtFatalMsg; s_file = 0; @@ -143,6 +147,7 @@ void tst_qmessagehandler::installMessageHandler() QCOMPARE((void*)myHandler, (void*)customMessageHandler); } +#if QT_DEPRECATED_SINCE(5, 0) void tst_qmessagehandler::installMsgHandler() { QtMsgHandler oldHandler = qInstallMsgHandler(customMsgHandler); @@ -158,6 +163,7 @@ void tst_qmessagehandler::installMsgHandler() QtMsgHandler myHandler = qInstallMsgHandler(oldHandler); QCOMPARE((void*)myHandler, (void*)customMsgHandler); } +#endif void tst_qmessagehandler::installBothHandler() { diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 16e81cdd773..eefe7bcecd4 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1036,7 +1036,9 @@ void tst_QFileInfo::systemFiles() QCOMPARE(fi.metadataChangeTime(), fi.lastModified()); // On Windows, they're the same QVERIFY(fi.birthTime().isValid()); QVERIFY(fi.birthTime() <= fi.lastModified()); +#if QT_DEPRECATED_SINCE(5, 10) QCOMPARE(fi.created(), fi.birthTime()); // On Windows, they're the same +#endif } void tst_QFileInfo::compare_data() @@ -2042,7 +2044,9 @@ static void stateCheck(const QFileInfo &info, const QString &dirname, const QStr QCOMPARE(info.permissions(), QFile::Permissions()); +#if QT_DEPRECATED_SINCE(5, 10) QVERIFY(!info.created().isValid()); +#endif QVERIFY(!info.birthTime().isValid()); QVERIFY(!info.metadataChangeTime().isValid()); QVERIFY(!info.lastRead().isValid()); diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index e4ff3c2a089..e799369c8a8 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -151,6 +151,13 @@ private slots: void failToStartEmptyArgs_data(); void failToStartEmptyArgs(); +#if QT_DEPRECATED_SINCE(5, 13) + void crashTest2_deprecated(); + void restartProcessDeadlock_deprecated(); + void waitForReadyReadInAReadyReadSlot_deprecated(); + void finishProcessBeforeReadingDone_deprecated(); +#endif + protected slots: void readFromProcess(); void exitLoopSlot(); @@ -187,12 +194,20 @@ void tst_QProcess::getSetCheck() QProcess obj1; // ProcessChannelMode QProcess::readChannelMode() // void QProcess::setProcessChannelMode(ProcessChannelMode) +#if QT_DEPRECATED_SINCE(5, 13) obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::SeparateChannels)); QCOMPARE(QProcess::ProcessChannelMode(QProcess::SeparateChannels), obj1.readChannelMode()); obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::MergedChannels)); QCOMPARE(QProcess::ProcessChannelMode(QProcess::MergedChannels), obj1.readChannelMode()); obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::ForwardedChannels)); QCOMPARE(QProcess::ProcessChannelMode(QProcess::ForwardedChannels), obj1.readChannelMode()); +#endif + obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::SeparateChannels)); + QCOMPARE(QProcess::ProcessChannelMode(QProcess::SeparateChannels), obj1.processChannelMode()); + obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::MergedChannels)); + QCOMPARE(QProcess::ProcessChannelMode(QProcess::MergedChannels), obj1.processChannelMode()); + obj1.setProcessChannelMode(QProcess::ProcessChannelMode(QProcess::ForwardedChannels)); + QCOMPARE(QProcess::ProcessChannelMode(QProcess::ForwardedChannels), obj1.processChannelMode()); // ProcessChannel QProcess::readChannel() // void QProcess::setReadChannel(ProcessChannel) @@ -335,12 +350,14 @@ void tst_QProcess::crashTest() qRegisterMetaType("QProcess::ExitStatus"); QSignalSpy spy(process.data(), &QProcess::errorOccurred); - QSignalSpy spy2(process.data(), static_cast(&QProcess::error)); - QSignalSpy spy3(process.data(), static_cast(&QProcess::finished)); - + QSignalSpy spy2(process.data(), static_cast(&QProcess::finished)); QVERIFY(spy.isValid()); QVERIFY(spy2.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy spy3(process.data(), static_cast(&QProcess::error)); QVERIFY(spy3.isValid()); +#endif QVERIFY(process->waitForFinished(30000)); @@ -348,10 +365,12 @@ void tst_QProcess::crashTest() QCOMPARE(*static_cast(spy.at(0).at(0).constData()), QProcess::Crashed); QCOMPARE(spy2.count(), 1); - QCOMPARE(*static_cast(spy2.at(0).at(0).constData()), QProcess::Crashed); + QCOMPARE(*static_cast(spy2.at(0).at(1).constData()), QProcess::CrashExit); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(spy3.count(), 1); - QCOMPARE(*static_cast(spy3.at(0).at(1).constData()), QProcess::CrashExit); + QCOMPARE(*static_cast(spy3.at(0).at(0).constData()), QProcess::Crashed); +#endif QCOMPARE(process->exitStatus(), QProcess::CrashExit); @@ -379,7 +398,7 @@ void tst_QProcess::crashTest2() QVERIFY(spy.isValid()); QVERIFY(spy2.isValid()); - QObject::connect(&process, static_cast(&QProcess::finished), + QObject::connect(&process, static_cast(&QProcess::finished), this, &tst_QProcess::exitLoopSlot); QTestEventLoop::instance().enterLoop(30); @@ -645,9 +664,11 @@ void tst_QProcess::readTimeoutAndThenCrash() qRegisterMetaType("QProcess::ProcessError"); QSignalSpy spy(&process, &QProcess::errorOccurred); - QSignalSpy spy2(&process, static_cast(&QProcess::error)); QVERIFY(spy.isValid()); +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy spy2(&process, static_cast(&QProcess::error)); QVERIFY(spy2.isValid()); +#endif process.kill(); @@ -656,8 +677,10 @@ void tst_QProcess::readTimeoutAndThenCrash() QCOMPARE(spy.count(), 1); QCOMPARE(*static_cast(spy.at(0).at(0).constData()), QProcess::Crashed); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(spy2.count(), 1); QCOMPARE(*static_cast(spy2.at(0).at(0).constData()), QProcess::Crashed); +#endif } void tst_QProcess::waitForFinished() @@ -697,12 +720,11 @@ void tst_QProcess::deadWhileReading() void tst_QProcess::restartProcessDeadlock() { - // The purpose of this test is to detect whether restarting a // process in the finished() connected slot causes a deadlock // because of the way QProcessManager uses its locks. QProcess process; - connect(&process, static_cast(&QProcess::finished), + connect(&process, static_cast(&QProcess::finished), this, &tst_QProcess::restartProcess); process.start("testProcessEcho/testProcessEcho"); @@ -710,7 +732,7 @@ void tst_QProcess::restartProcessDeadlock() QCOMPARE(process.write("", 1), qlonglong(1)); QVERIFY(process.waitForFinished(5000)); - QObject::disconnect(&process, static_cast(&QProcess::finished), nullptr, nullptr); + QObject::disconnect(&process, static_cast(&QProcess::finished), nullptr, nullptr); QCOMPARE(process.write("", 1), qlonglong(1)); QVERIFY(process.waitForFinished(5000)); @@ -1027,7 +1049,7 @@ void tst_QProcess::mergedChannels() { QProcess process; process.setProcessChannelMode(QProcess::MergedChannels); - QCOMPARE(process.readChannelMode(), QProcess::MergedChannels); + QCOMPARE(process.processChannelMode(), QProcess::MergedChannels); process.start("testProcessEcho2/testProcessEcho2"); @@ -1155,7 +1177,7 @@ protected: exitCode = 90210; QProcess process; - connect(&process, static_cast(&QProcess::finished), + connect(&process, static_cast(&QProcess::finished), this, &TestThread::catchExitCode, Qt::DirectConnection); process.start("testProcessEcho/testProcessEcho"); @@ -1229,7 +1251,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot() { QProcess process; connect(&process, &QIODevice::readyRead, this, &tst_QProcess::waitForReadyReadInAReadyReadSlotSlot); - connect(&process, static_cast(&QProcess::finished), + connect(&process, static_cast(&QProcess::finished), this, &tst_QProcess::exitLoopSlot); bytesAvailable = 0; @@ -1468,15 +1490,19 @@ void tst_QProcess::failToStart() QProcess process; QSignalSpy stateSpy(&process, &QProcess::stateChanged); QSignalSpy errorSpy(&process, &QProcess::errorOccurred); - QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); - QSignalSpy finishedSpy(&process, static_cast(&QProcess::finished)); - QSignalSpy finishedSpy2(&process, static_cast(&QProcess::finished)); - + QSignalSpy finishedSpy(&process, static_cast(&QProcess::finished)); QVERIFY(stateSpy.isValid()); QVERIFY(errorSpy.isValid()); - QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif +#if QT_DEPRECATED_SINCE(5, 13) + QSignalSpy finishedSpy2(&process, static_cast(&QProcess::finished)); QVERIFY(finishedSpy2.isValid()); +#endif // OS X and HP-UX have a really low default process limit (~100), so spawning // to many processes here will cause test failures later on. @@ -1491,7 +1517,9 @@ void tst_QProcess::failToStart() for (int j = 0; j < 8; ++j) { for (int i = 0; i < attempts; ++i) { QCOMPARE(errorSpy.count(), j * attempts + i); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(errorSpy2.count(), j * attempts + i); +#endif process.start("/blurp"); switch (j) { @@ -1516,9 +1544,13 @@ void tst_QProcess::failToStart() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), j * attempts + i + 1); - QCOMPARE(errorSpy2.count(), j * attempts + i + 1); QCOMPARE(finishedSpy.count(), 0); +#if QT_DEPRECATED_SINCE(5, 6) + QCOMPARE(errorSpy2.count(), j * attempts + i + 1); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(finishedSpy2.count(), 0); +#endif int it = j * attempts + i + 1; @@ -1537,14 +1569,18 @@ void tst_QProcess::failToStartWithWait() QProcess process; QEventLoop loop; QSignalSpy errorSpy(&process, &QProcess::errorOccurred); - QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); - QSignalSpy finishedSpy(&process, static_cast(&QProcess::finished)); - QSignalSpy finishedSpy2(&process, static_cast(&QProcess::finished)); - + QSignalSpy finishedSpy(&process, static_cast(&QProcess::finished)); QVERIFY(errorSpy.isValid()); - QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif +#if QT_DEPRECATED_SINCE(5, 13) + QSignalSpy finishedSpy2(&process, static_cast(&QProcess::finished)); QVERIFY(finishedSpy2.isValid()); +#endif for (int i = 0; i < 50; ++i) { process.start("/blurp", QStringList() << "-v" << "-debug"); @@ -1552,9 +1588,14 @@ void tst_QProcess::failToStartWithWait() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), i + 1); - QCOMPARE(errorSpy2.count(), i + 1); QCOMPARE(finishedSpy.count(), 0); +#if QT_DEPRECATED_SINCE(5, 6) + QCOMPARE(errorSpy2.count(), i + 1); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(finishedSpy2.count(), 0); +#endif + } } @@ -1566,14 +1607,18 @@ void tst_QProcess::failToStartWithEventLoop() QProcess process; QEventLoop loop; QSignalSpy errorSpy(&process, &QProcess::errorOccurred); - QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); - QSignalSpy finishedSpy(&process, static_cast(&QProcess::finished)); - QSignalSpy finishedSpy2(&process, static_cast(&QProcess::finished)); - + QSignalSpy finishedSpy(&process, static_cast(&QProcess::finished)); QVERIFY(errorSpy.isValid()); - QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif +#if QT_DEPRECATED_SINCE(5, 13) + QSignalSpy finishedSpy2(&process, static_cast(&QProcess::finished)); QVERIFY(finishedSpy2.isValid()); +#endif // The error signal may be emitted before start() returns connect(&process, &QProcess::errorOccurred, &loop, &QEventLoop::quit, Qt::QueuedConnection); @@ -1586,9 +1631,13 @@ void tst_QProcess::failToStartWithEventLoop() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), i + 1); - QCOMPARE(errorSpy2.count(), i + 1); QCOMPARE(finishedSpy.count(), 0); +#if QT_DEPRECATED_SINCE(5, 6) + QCOMPARE(errorSpy2.count(), i + 1); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(finishedSpy2.count(), 0); +#endif } } @@ -1606,8 +1655,12 @@ void tst_QProcess::failToStartEmptyArgs() qRegisterMetaType("QProcess::ProcessError"); QProcess process; - QSignalSpy errorSpy(&process, static_cast(&QProcess::error)); + QSignalSpy errorSpy(&process, static_cast(&QProcess::errorOccurred)); QVERIFY(errorSpy.isValid()); +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif switch (startOverload) { case 0: @@ -1625,6 +1678,9 @@ void tst_QProcess::failToStartEmptyArgs() QVERIFY(!process.waitForStarted()); QCOMPARE(errorSpy.count(), 1); +#if QT_DEPRECATED_SINCE(5, 6) + QCOMPARE(errorSpy2.count(), 1); +#endif QCOMPARE(process.error(), QProcess::FailedToStart); } @@ -1856,24 +1912,32 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() QProcess process; QSignalSpy errorSpy(&process, &QProcess::errorOccurred); - QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); - QSignalSpy finishedSpy1(&process, static_cast(&QProcess::finished)); - QSignalSpy finishedSpy2(&process, static_cast(&QProcess::finished)); - + QSignalSpy finishedSpy(&process, static_cast(&QProcess::finished)); QVERIFY(errorSpy.isValid()); - QVERIFY(errorSpy2.isValid()); + QVERIFY(finishedSpy.isValid()); + +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy errorSpy2(&process, static_cast(&QProcess::error)); + QVERIFY(errorSpy2.isValid()); +#endif +#if QT_DEPRECATED_SINCE(5, 13) + QSignalSpy finishedSpy1(&process, static_cast(&QProcess::finished)); QVERIFY(finishedSpy1.isValid()); - QVERIFY(finishedSpy2.isValid()); +#endif QVERIFY(!process.waitForReadyRead()); // used to crash process.start("doesntexist"); QVERIFY(!process.waitForReadyRead()); QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.at(0).at(0).toInt(), 0); + QCOMPARE(finishedSpy.count(), 0); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(errorSpy2.count(), 1); QCOMPARE(errorSpy2.at(0).at(0).toInt(), 0); +#endif +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(finishedSpy1.count(), 0); - QCOMPARE(finishedSpy2.count(), 0); +#endif } void tst_QProcess::setStandardInputFile() @@ -2304,14 +2368,18 @@ void tst_QProcess::invalidProgramString() qRegisterMetaType("QProcess::ProcessError"); QSignalSpy spy(&process, &QProcess::errorOccurred); - QSignalSpy spy2(&process, static_cast(&QProcess::error)); QVERIFY(spy.isValid()); +#if QT_DEPRECATED_SINCE(5, 6) + QSignalSpy spy2(&process, static_cast(&QProcess::error)); QVERIFY(spy2.isValid()); +#endif process.start(programString); QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(spy.count(), 1); +#if QT_DEPRECATED_SINCE(5, 6) QCOMPARE(spy2.count(), 1); +#endif QVERIFY(!QProcess::startDetached(programString)); } @@ -2365,7 +2433,7 @@ void tst_QProcess::finishProcessBeforeReadingDone() QProcess process; BlockOnReadStdOut blocker(&process); QEventLoop loop; - connect(&process, static_cast(&QProcess::finished), + connect(&process, static_cast(&QProcess::finished), &loop, &QEventLoop::quit); process.start("testProcessOutput/testProcessOutput"); QVERIFY(process.waitForStarted()); @@ -2511,5 +2579,106 @@ void tst_QProcess::processEventsInAReadyReadSlot() QVERIFY(process.waitForFinished()); } +#if QT_DEPRECATED_SINCE(5, 13) + +void tst_QProcess::crashTest2_deprecated() +{ + QProcess process; + process.start("testProcessCrash/testProcessCrash"); + QVERIFY(process.waitForStarted(5000)); + + qRegisterMetaType("QProcess::ProcessError"); + qRegisterMetaType("QProcess::ExitStatus"); + + QSignalSpy spy(&process, static_cast(&QProcess::errorOccurred)); + QSignalSpy spy2(&process, static_cast(&QProcess::finished)); + + QVERIFY(spy.isValid()); + QVERIFY(spy2.isValid()); + + QObject::connect(&process, static_cast(&QProcess::finished), + this, &tst_QProcess::exitLoopSlot); + + QTestEventLoop::instance().enterLoop(30); + if (QTestEventLoop::instance().timeout()) + QFAIL("Failed to detect crash : operation timed out"); + + QCOMPARE(spy.count(), 1); + QCOMPARE(*static_cast(spy.at(0).at(0).constData()), QProcess::Crashed); + + QCOMPARE(spy2.count(), 1); + QCOMPARE(*static_cast(spy2.at(0).at(1).constData()), QProcess::CrashExit); + + QCOMPARE(process.exitStatus(), QProcess::CrashExit); +} + +void tst_QProcess::restartProcessDeadlock_deprecated() +{ + // The purpose of this test is to detect whether restarting a + // process in the finished() connected slot causes a deadlock + // because of the way QProcessManager uses its locks. + QProcess process; + connect(&process, static_cast(&QProcess::finished), + this, &tst_QProcess::restartProcess); + + process.start("testProcessEcho/testProcessEcho"); + + QCOMPARE(process.write("", 1), qlonglong(1)); + QVERIFY(process.waitForFinished(5000)); + + QObject::disconnect(&process, static_cast(&QProcess::finished), nullptr, nullptr); + + QCOMPARE(process.write("", 1), qlonglong(1)); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); +} + +void tst_QProcess::waitForReadyReadInAReadyReadSlot_deprecated() +{ + QProcess process; + connect(&process, &QIODevice::readyRead, this, &tst_QProcess::waitForReadyReadInAReadyReadSlotSlot); + connect(&process, static_cast(&QProcess::finished), + this, &tst_QProcess::exitLoopSlot); + bytesAvailable = 0; + + process.start("testProcessEcho/testProcessEcho"); + QVERIFY(process.waitForStarted(5000)); + + QSignalSpy spy(&process, &QProcess::readyRead); + QVERIFY(spy.isValid()); + process.write("foo"); + QTestEventLoop::instance().enterLoop(30); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(spy.count(), 1); + + process.disconnect(); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); + QVERIFY(process.bytesAvailable() > bytesAvailable); +} + +void tst_QProcess::finishProcessBeforeReadingDone_deprecated() +{ + QProcess process; + BlockOnReadStdOut blocker(&process); + QEventLoop loop; + connect(&process, static_cast(&QProcess::finished), + &loop, &QEventLoop::quit); + process.start("testProcessOutput/testProcessOutput"); + QVERIFY(process.waitForStarted()); + loop.exec(); + QStringList lines = QString::fromLocal8Bit(process.readAllStandardOutput()).split( + QRegExp(QStringLiteral("[\r\n]")), QString::SkipEmptyParts); + QVERIFY(!lines.isEmpty()); + QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number")); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); +} + +#endif + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 0b50c391b87..df1dbebbf24 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -55,6 +55,10 @@ private slots: void checkStructure(); void searchPath_data(); void searchPath(); +#if QT_DEPRECATED_SINCE(5, 13) + void searchPath_deprecated_data(); + void searchPath_deprecated(); +#endif void doubleSlashInRoot(); void setLocale(); void lastModified(); @@ -419,6 +423,58 @@ void tst_QResourceEngine::checkStructure() } void tst_QResourceEngine::searchPath_data() +{ + auto searchPath = QFileInfo(QFINDTESTDATA("testqrc")).canonicalFilePath(); + + QTest::addColumn("searchPathPrefix"); + QTest::addColumn("searchPath"); + QTest::addColumn("file"); + QTest::addColumn("expected"); + + QTest::newRow("no_search_path") + << QString() + << QString() + << ":search_file.txt" + << QByteArray("root\n"); + QTest::newRow("path1") + << "searchpath1" + << searchPath + << "searchpath1:searchpath1/search_file.txt" + << QByteArray("path1\n"); + QTest::newRow("no_search_path2") + << QString() + << QString() + << ":/search_file.txt" + << QByteArray("root\n"); + QTest::newRow("path2") + << "searchpath2" + << searchPath + "/searchpath2" + << "searchpath2:search_file.txt" + << QByteArray("path2\n"); +} + +void tst_QResourceEngine::searchPath() +{ + QFETCH(QString, searchPathPrefix); + QFETCH(QString, searchPath); + QFETCH(QString, file); + QFETCH(QByteArray, expected); + + if (!searchPath.isEmpty()) + QDir::addSearchPath(searchPathPrefix, searchPath); + QFile qf(file); + QVERIFY(qf.open(QFile::ReadOnly)); + QByteArray actual = qf.readAll(); + + actual.replace('\r', ""); + + QCOMPARE(actual, expected); + qf.close(); +} + +#if QT_DEPRECATED_SINCE(5, 13) + +void tst_QResourceEngine::searchPath_deprecated_data() { QTest::addColumn("searchPath"); QTest::addColumn("file"); @@ -438,7 +494,7 @@ void tst_QResourceEngine::searchPath_data() << QByteArray("path2\n"); } -void tst_QResourceEngine::searchPath() +void tst_QResourceEngine::searchPath_deprecated() { QFETCH(QString, searchPath); QFETCH(QString, file); @@ -456,6 +512,8 @@ void tst_QResourceEngine::searchPath() qf.close(); } +#endif + void tst_QResourceEngine::checkUnregisterResource_data() { QTest::addColumn("rcc_file"); diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 8b69518ef70..a71a68e4576 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -311,8 +311,11 @@ void tst_QSettings::initTestCase() void tst_QSettings::cleanupTestFiles() { - QSettings::setSystemIniPath(settingsPath("__system__")); - QSettings::setUserIniPath(settingsPath("__user__")); + QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, settingsPath("__system__")); + QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, settingsPath("__system__")); + + QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsPath("__user__")); + QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, settingsPath("__user__")); QDir settingsDir(settingsPath()); if (settingsDir.exists()) diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 89a06b358e9..026c6a6324e 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -520,7 +520,7 @@ public slots: QVector o5, QList o6) { slotResult = QLatin1String("slotWithRegistrableArgument:") + o1->slotResult + o2->slotResult - + o3->slotResult + o4.data()->slotResult + QString::number(o5.size()) + + o3->slotResult + o4.toStrongRef()->slotResult + QString::number(o5.size()) + QString::number(o6.size()); } diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 28458c43c7c..12c29a6e135 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1807,16 +1807,36 @@ void tst_QMetaType::automaticTemplateRegistration() QCOMPARE(extractedPtr.data()->objectName(), sp.data()->objectName()); \ } +#if QT_DEPRECATED_SINCE(5, 0) TEST_NONOWNING_SMARTPOINTER(QWeakPointer, QObject, WeakPointerToQObject, qWeakPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QWeakPointer, QFile, WeakPointerToQObject, qWeakPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QWeakPointer, QTemporaryFile, WeakPointerToQObject, qWeakPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QWeakPointer, MyObject, WeakPointerToQObject, qWeakPointerFromVariant) +#endif TEST_NONOWNING_SMARTPOINTER(QPointer, QObject, TrackingPointerToQObject, qPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QPointer, QFile, TrackingPointerToQObject, qPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QPointer, QTemporaryFile, TrackingPointerToQObject, qPointerFromVariant) TEST_NONOWNING_SMARTPOINTER(QPointer, MyObject, TrackingPointerToQObject, qPointerFromVariant) #undef TEST_NONOWNING_SMARTPOINTER + + +#define TEST_WEAK_SMARTPOINTER(ELEMENT_TYPE, FLAG_TEST) \ + { \ + ELEMENT_TYPE elem; \ + QSharedPointer < ELEMENT_TYPE > shared(new ELEMENT_TYPE); \ + QWeakPointer < ELEMENT_TYPE > sp(shared); \ + sp.toStrongRef()->setObjectName("Test name"); \ + QVariant v = QVariant::fromValue(sp); \ + QCOMPARE(v.typeName(), "QWeakPointer<" #ELEMENT_TYPE ">"); \ + QVERIFY(QMetaType::typeFlags(::qMetaTypeId >()) & QMetaType::FLAG_TEST); \ + } + + TEST_WEAK_SMARTPOINTER(QObject, WeakPointerToQObject) + TEST_WEAK_SMARTPOINTER(QFile, WeakPointerToQObject) + TEST_WEAK_SMARTPOINTER(QTemporaryFile, WeakPointerToQObject) + TEST_WEAK_SMARTPOINTER(MyObject, WeakPointerToQObject) +#undef TEST_WEAK_SMARTPOINTER } template diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index c75e4ef035c..5d06f6e8c8f 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -402,6 +402,8 @@ QT_WARNING_POP QVERIFY( var6.isNull() ); QVariant varLL( (qlonglong)0 ); QVERIFY( !varLL.isNull() ); + +#if QT_DEPRECATED_SINCE(5, 9) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QVariant var7(QString::null); @@ -412,6 +414,7 @@ QT_WARNING_DISABLE_DEPRECATED var7 = QVariant::fromValue(QString::null); QT_WARNING_POP QVERIFY(var7.isNull()); +#endif QVariant var8(QMetaType::Nullptr, nullptr); QVERIFY(var8.isNull()); @@ -433,6 +436,9 @@ QT_WARNING_POP QVERIFY(var11.isNull()); QVERIFY(QVariant::fromValue(nullptr).isNull()); + + QVariant var12(QVariant::fromValue(QString())); + QVERIFY(var12.isNull()); } void tst_QVariant::swap() @@ -2871,6 +2877,7 @@ void tst_QVariant::qvariant_cast_QObject_wrapper() QVERIFY(spVar.canConvert()); QCOMPARE(f, spVar.value()); } +#if QT_DEPRECATED_SINCE(5, 0) { QFile *f = new QFile(this); QT_WARNING_PUSH @@ -2881,6 +2888,15 @@ QT_WARNING_POP QVERIFY(spVar.canConvert()); QCOMPARE(f, spVar.value()); } +#endif + { + QFile *f = new QFile(this); + QSharedPointer sp(f); + QWeakPointer wp = sp; + QVariant wpVar = QVariant::fromValue(wp); + QVERIFY(wpVar.canConvert()); + QCOMPARE(f, wpVar.value()); + } { QFile *f = new QFile(this); QSharedPointer sp(f); diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index e2ce5cb9f97..e79a4dba299 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -1994,13 +1994,17 @@ void tst_Collections::qstring() QString nonNull = ""; QVERIFY(null.left(10).isNull()); QVERIFY(null.mid(0).isNull()); + QVERIFY(null.isNull()); + QVERIFY(!nonNull.isNull()); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(null == QString::null); QVERIFY(QString::null == null); QVERIFY(nonNull != QString::null); QVERIFY(QString::null != nonNull); QVERIFY(null == nonNull); QVERIFY(QString::null == QString::null); +#endif QString fill = "123"; fill.fill('a'); diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index d1bf63bf8af..18432e51a6b 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -48,6 +48,11 @@ class tst_QAlgorithms : public QObject { Q_OBJECT private slots: + void swap(); + void swap2(); + void convenienceAPI(); + +#if QT_DEPRECATED_SINCE(5, 2) void test_qLowerBound_data(); void test_qLowerBound(); void test_qUpperBound_data(); @@ -55,19 +60,23 @@ private slots: void test_qBinaryFind_data(); void test_qBinaryFind(); void qBinaryFindOneEntry(); - void swap(); - void swap2(); void sortEmptyList(); void sortedList(); void sortAPItest(); void stableSortTest(); void stableSortCorrectnessTest_data(); void stableSortCorrectnessTest(); - void convenienceAPI(); + void convenienceAPI_deprecated(); void qCountIterators() const; void qCountContainer() const; void binaryFindOnLargeContainer() const; +#if Q_TEST_PERFORMANCE + void performance(); +#endif + +#endif // QT_DEPRECATED_SINCE(5, 2) + void popCount08_data() { popCount_data_impl(sizeof(quint8 )); } void popCount16_data() { popCount_data_impl(sizeof(quint16)); } void popCount32_data() { popCount_data_impl(sizeof(quint32)); } @@ -96,9 +105,6 @@ private slots: void countLeading64() { countLeading_impl(); } private: -#if Q_TEST_PERFORMANCE - void performance(); -#endif void popCount_data_impl(size_t sizeof_T_Int); template void popCount_impl(); @@ -112,6 +118,8 @@ private: void countLeading_impl(); }; +#if QT_DEPRECATED_SINCE(5, 2) + class TestInt { public: @@ -257,6 +265,8 @@ void testAlgorithm(Algorithm algorithm, QStringList &dataSetTypes) } #endif +#endif // QT_DEPRECATED_SINCE(5, 2) + void tst_QAlgorithms::swap() { { @@ -391,6 +401,17 @@ void tst_QAlgorithms::swap2() } } +void tst_QAlgorithms::convenienceAPI() +{ + // Compile-test for QAlgorithm convenience functions. + + QList pointerList; + qDeleteAll(pointerList); + qDeleteAll(pointerList.begin(), pointerList.end()); +} + +#if QT_DEPRECATED_SINCE(5, 2) + void tst_QAlgorithms::sortEmptyList() { // Only test if it crashes @@ -676,7 +697,7 @@ void tst_QAlgorithms::stableSortCorrectnessTest() QVERIFY(isSorted(sorted)); } -void tst_QAlgorithms::convenienceAPI() +void tst_QAlgorithms::convenienceAPI_deprecated() { // Compile-test for QAlgorithm convenience functions. QList list, list2; @@ -716,10 +737,6 @@ void tst_QAlgorithms::convenienceAPI() qBinaryFind(list, 1); qBinaryFind(list.begin(), list.end(), 1); qBinaryFind(list.begin(), list.end(), 1, qLess()); - - QList pointerList; - qDeleteAll(pointerList); - qDeleteAll(pointerList.begin(), pointerList.end()); } template @@ -1041,6 +1058,8 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const QCOMPARE(foundIt.pos(), 1073987655); } +#endif // QT_DEPRECATED_SINCE(5, 2) + // alternative implementation of qPopulationCount for comparison: static Q_DECL_CONSTEXPR const uint bitsSetInNibble[] = { 0, 1, 1, 2, 1, 2, 2, 3, diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp index b9bcecd607d..513c8117883 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp @@ -74,10 +74,12 @@ int main(int argc, char *argv[]) hiddenOption.setDescription(QStringLiteral("THIS SHOULD NEVER APPEAR")); hiddenOption.setFlags(QCommandLineOption::HiddenFromHelp); parser.addOption(hiddenOption); +#if QT_DEPRECATED_SINCE(5, 8) QCommandLineOption hiddenOption2(QStringList() << QStringLiteral("hidden2")); hiddenOption2.setDescription(QStringLiteral("NEITHER SHOULD THIS")); hiddenOption2.setHidden(true); parser.addOption(hiddenOption2); +#endif // This program supports different options depending on the "command" (first argument). // Call parse() to find out the positional arguments. diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp index 915a24a1f69..0418daf640c 100644 --- a/tests/auto/corelib/tools/qline/tst_qline.cpp +++ b/tests/auto/corelib/tools/qline/tst_qline.cpp @@ -53,8 +53,10 @@ private slots: void testNormalVector(); void testNormalVector_data(); +#if QT_DEPRECATED_SINCE(5, 14) void testAngle(); void testAngle_data(); +#endif void testAngle2(); void testAngle2_data(); @@ -378,6 +380,7 @@ void tst_QLine::testNormalVector() QCOMPARE(n.dy(), qreal(nvy)); } +#if QT_DEPRECATED_SINCE(5, 14) void tst_QLine::testAngle_data() { QTest::addColumn("xa1"); @@ -426,6 +429,7 @@ void tst_QLine::testAngle() double resultAngle = a.angle(b); QCOMPARE(qRound(resultAngle), qRound(angle)); } +#endif void tst_QLine::testAngle2_data() { diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 187b73eeec4..f3c647515a1 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -75,8 +75,10 @@ private slots: void functionCallDownCast(); void upCast(); void qobjectWeakManagement(); +#if QT_DEPRECATED_SINCE(5, 0) void noSharedPointerFromWeakQObject(); void sharedPointerFromQObjectWithWeak(); +#endif void weakQObjectFromSharedPointer(); void objectCast(); void objectCastStdSharedPtr(); @@ -878,6 +880,78 @@ class OtherObject: public QObject void tst_QSharedPointer::qobjectWeakManagement() { + { + QWeakPointer weak; + weak = QWeakPointer(); + QVERIFY(weak.isNull()); + QVERIFY(weak.toStrongRef().isNull()); + } + + { + QObject *obj = new QObject; + QSharedPointer shared(obj); + QWeakPointer weak(shared); + QVERIFY(!weak.isNull()); + QVERIFY(weak.toStrongRef() == obj); + + // now delete + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // same, bit with operator= + QObject *obj = new QObject; + QSharedPointer shared(obj); + QWeakPointer weak; + weak = shared; + QVERIFY(!weak.isNull()); + QVERIFY(weak.toStrongRef() == obj); + + // now delete + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // with two QWeakPointers + QObject *obj = new QObject; + QSharedPointer shared(obj); + QWeakPointer weak(shared); + + { + QWeakPointer weak2(shared); + QVERIFY(!weak2.isNull()); + QVERIFY(weak == weak2); + } + QVERIFY(!weak.isNull()); + + shared.reset(); + QVERIFY(weak.isNull()); + } + safetyCheck(); + + { + // same, but delete the pointer while two QWeakPointers exist + QObject *obj = new QObject; + QSharedPointer shared(obj); + QWeakPointer weak(shared); + + { + QWeakPointer weak2(shared); + QVERIFY(!weak2.isNull()); + + shared.reset(); + QVERIFY(weak.isNull()); + QVERIFY(weak2.isNull()); + } + QVERIFY(weak.isNull()); + } + safetyCheck(); + +#if QT_DEPRECATED_SINCE(5, 0) { QWeakPointer weak; weak = QWeakPointer(); @@ -972,8 +1046,10 @@ void tst_QSharedPointer::qobjectWeakManagement() QVERIFY(weak.isNull()); } safetyCheck(); +#endif } +#if QT_DEPRECATED_SINCE(5, 0) void tst_QSharedPointer::noSharedPointerFromWeakQObject() { // you're not allowed to create a QSharedPointer from an unmanaged QObject @@ -1007,18 +1083,32 @@ void tst_QSharedPointer::sharedPointerFromQObjectWithWeak() } QVERIFY(weak.isNull()); } +#endif void tst_QSharedPointer::weakQObjectFromSharedPointer() { - // this is the inverse of the above: you're allowed to create a QWeakPointer - // from a managed QObject - QSharedPointer shared(new QObject); - QWeakPointer weak = shared.data(); - QVERIFY(!weak.isNull()); +#if QT_DEPRECATED_SINCE(5, 0) + { + // this is the inverse of the above: you're allowed to create a QWeakPointer + // from a managed QObject + QSharedPointer shared(new QObject); + QWeakPointer weak = shared.data(); + QVERIFY(!weak.isNull()); - // delete: - shared.clear(); - QVERIFY(weak.isNull()); + // delete: + shared.clear(); + QVERIFY(weak.isNull()); + } +#endif + { + QSharedPointer shared(new QObject); + QWeakPointer weak = shared; + QVERIFY(!weak.isNull()); + + // delete: + shared.clear(); + QVERIFY(weak.isNull()); + } } void tst_QSharedPointer::objectCast() @@ -2376,6 +2466,7 @@ void tst_QSharedPointer::qvariantCast() // Intentionally does not compile. // QSharedPointer sop = qSharedPointerFromVariant(v); +#if QT_DEPRECATED_SINCE(5, 0) v = QVariant::fromValue(sp.toWeakRef()); { @@ -2419,6 +2510,7 @@ void tst_QSharedPointer::qvariantCast() QWeakPointer other = qWeakPointerFromVariant(v); QVERIFY(!other); } +#endif } class SomeClass : public QEnableSharedFromThis diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 79f5a8c46d2..e4aa00f500b 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -521,7 +521,9 @@ private slots: void stringRef_local8Bit_data(); void stringRef_local8Bit(); void fromLatin1(); +#if QT_DEPRECATED_SINCE(5, 0) void fromAscii(); +#endif void fromUcs4(); void toUcs4(); void arg(); @@ -4284,9 +4286,9 @@ void tst_QString::fromLocal8Bit_data() //QTest::newRow("null5") << QByteArray() << 5 << QString(); //QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << -1 << QString(); //QTest::newRow("empty0") << QByteArray() << 0 << QString(); - //QTest::newRow("empty5") << QByteArray("\0abcd", 5) << 5 << QString::fromAscii("\0abcd", 5); - //QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << -1 << QString::fromAscii("ab"); - //QTest::newRow("other5") << QByteArray("ab\0cd", 5) << 5 << QString::fromAscii("ab\0cd", 5); + //QTest::newRow("empty5") << QByteArray("\0abcd", 5) << 5 << QString::fromLatin1("\0abcd", 5); + //QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << -1 << QString::fromLatin1("ab"); + //QTest::newRow("other5") << QByteArray("ab\0cd", 5) << 5 << QString::fromLatin1("ab\0cd", 5); } void tst_QString::fromLocal8Bit() @@ -4590,6 +4592,7 @@ void tst_QString::fromLatin1() QVERIFY(a.size() == 5); } +#if QT_DEPRECATED_SINCE(5, 0) void tst_QString::fromAscii() { QString a; @@ -4610,6 +4613,7 @@ void tst_QString::fromAscii() a = QString::fromAscii("\0abcd", 5); QVERIFY(a.size() == 5); } +#endif void tst_QString::fromUcs4() { diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index 581e9152e62..6f019471312 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -596,7 +596,10 @@ void tst_QStringRef::startsWith() QVERIFY(!ref.startsWith("C")); QVERIFY(!ref.startsWith("ABCDEF")); QVERIFY(ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(ref.startsWith('A')); QVERIFY(ref.startsWith(QLatin1Char('A'))); QVERIFY(ref.startsWith(QChar('A'))); @@ -623,7 +626,10 @@ void tst_QStringRef::startsWith() QVERIFY(!ref.startsWith("c", Qt::CaseInsensitive)); QVERIFY(!ref.startsWith("abcdef", Qt::CaseInsensitive)); QVERIFY(ref.startsWith("", Qt::CaseInsensitive)); + QVERIFY(ref.startsWith(QString(), Qt::CaseInsensitive)); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null, Qt::CaseInsensitive)); +#endif QVERIFY(ref.startsWith('a', Qt::CaseInsensitive)); QVERIFY(ref.startsWith('A', Qt::CaseInsensitive)); QVERIFY(ref.startsWith(QLatin1Char('a'), Qt::CaseInsensitive)); @@ -656,7 +662,10 @@ void tst_QStringRef::startsWith() const QString a = QString::fromLatin1(""); CREATE_REF(a); QVERIFY(ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(!ref.startsWith("ABC")); QVERIFY(ref.startsWith(QLatin1String(""))); @@ -670,7 +679,10 @@ void tst_QStringRef::startsWith() { const QStringRef ref; QVERIFY(!ref.startsWith("")); + QVERIFY(ref.startsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.startsWith(QString::null)); +#endif QVERIFY(!ref.startsWith("ABC")); QVERIFY(!ref.startsWith(QLatin1String(""))); @@ -693,7 +705,10 @@ void tst_QStringRef::endsWith() QVERIFY(!ref.endsWith("C")); QVERIFY(!ref.endsWith("ABCDEF")); QVERIFY(ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(ref.endsWith('B')); QVERIFY(ref.endsWith(QLatin1Char('B'))); QVERIFY(ref.endsWith(QChar('B'))); @@ -720,7 +735,10 @@ void tst_QStringRef::endsWith() QVERIFY(!ref.endsWith("c", Qt::CaseInsensitive)); QVERIFY(!ref.endsWith("abcdef", Qt::CaseInsensitive)); QVERIFY(ref.endsWith("", Qt::CaseInsensitive)); + QVERIFY(ref.endsWith(QString(), Qt::CaseInsensitive)); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null, Qt::CaseInsensitive)); +#endif QVERIFY(ref.endsWith('b', Qt::CaseInsensitive)); QVERIFY(ref.endsWith('B', Qt::CaseInsensitive)); QVERIFY(ref.endsWith(QLatin1Char('b'), Qt::CaseInsensitive)); @@ -754,7 +772,10 @@ void tst_QStringRef::endsWith() const QString a = QString::fromLatin1(""); CREATE_REF(a); QVERIFY(ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(!ref.endsWith("ABC")); QVERIFY(!ref.endsWith(QLatin1Char(0))); QVERIFY(!ref.endsWith(QLatin1Char('x'))); @@ -768,7 +789,10 @@ void tst_QStringRef::endsWith() { QStringRef ref; QVERIFY(!ref.endsWith("")); + QVERIFY(ref.endsWith(QString())); +#if QT_DEPRECATED_SINCE(5, 9) QVERIFY(ref.endsWith(QString::null)); +#endif QVERIFY(!ref.endsWith("ABC")); QVERIFY(!ref.endsWith(QLatin1String(""))); diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp index 2deb84fa5fc..b6921fc0bbf 100644 --- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp @@ -311,12 +311,14 @@ void tst_QStandardItem::getSetFlags() item.setCheckable(true); QCOMPARE(item.checkState(), Qt::Checked); +#if QT_DEPRECATED_SINCE(5, 6) // deprecated API item.setTristate(true); QVERIFY(item.isTristate()); QVERIFY(item.flags() & Qt::ItemIsTristate); item.setTristate(false); QVERIFY(!(item.flags() & Qt::ItemIsTristate)); +#endif } void tst_QStandardItem::getSetRowAndColumnCount() diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index cacee30c869..1df31904d62 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -422,7 +422,7 @@ void tst_qmake::prompt() { #if 0 QProcess qmake; - qmake.setReadChannelMode(QProcess::MergedChannels); + qmake.setProcessChannelMode(QProcess::MergedChannels); qmake.setWorkingDirectory(QLatin1String("testdata/prompt")); qmake.start(QLatin1String("qmake CONFIG-=debug_and_release CONFIG-=debug CONFIG+=release"), QIODevice::Text | QIODevice::ReadWrite); diff --git a/tests/manual/qcursor/qcursorhighdpi/main.cpp b/tests/manual/qcursor/qcursorhighdpi/main.cpp index 4a7646c39dd..3b18bff91c9 100644 --- a/tests/manual/qcursor/qcursorhighdpi/main.cpp +++ b/tests/manual/qcursor/qcursorhighdpi/main.cpp @@ -183,7 +183,7 @@ private: void DraggableLabel::mousePressEvent(QMouseEvent *) { QMimeData *mimeData = new QMimeData; - mimeData->setImageData(qVariantFromValue(m_pixmap)); + mimeData->setImageData(QVariant::fromValue(m_pixmap)); QDrag *drag = new QDrag(this); QPixmap pixmap = m_pixmap; if (QApplication::keyboardModifiers() & Qt::ShiftModifier) { From b0cd007335853f283c47ffb0f5611d14e6dbe84b Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 4 Jul 2019 15:06:13 +0200 Subject: [PATCH 157/172] Remove usages of QSysInfo's deprecated APIs - Replaced QOperatingSystemVersion::WindowsVersion, QSysInfo::windowsVersion(), QSysInfo::macVersion(), QSysInfo::MacintoshVersion with QOperatingSystemVersion::current(). - Added QOperatingSystemVersion::WindowsVista for convenience, as it is used in lots of places. Change-Id: If9c4ac496005b2e70b5c70be160747afa74b98c1 Reviewed-by: Timur Pocheptsov --- src/corelib/global/qoperatingsystemversion.cpp | 8 ++++++++ src/corelib/global/qoperatingsystemversion.h | 1 + src/network/ssl/qsslsocket_openssl11.cpp | 3 ++- src/network/ssl/qsslsocket_winrt.cpp | 1 + src/plugins/bearer/nativewifi/qnativewifiengine.cpp | 4 +++- src/plugins/styles/windowsvista/qwindowsvistastyle.cpp | 5 ++--- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 3 ++- tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp | 2 +- tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp | 2 +- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 5 +++-- tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | 5 ++++- .../widgets/widgets/qprogressbar/tst_qprogressbar.cpp | 2 +- 12 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index 42a12756217..9084ad933c5 100644 --- a/src/corelib/global/qoperatingsystemversion.cpp +++ b/src/corelib/global/qoperatingsystemversion.cpp @@ -355,6 +355,14 @@ bool QOperatingSystemVersion::isAnyOfType(std::initializer_list types) c return false; } +/*! + \variable QOperatingSystemVersion::WindowsVista + \brief a version corresponding to Windows Vista (version 6.0). + \since 6.0 + */ +const QOperatingSystemVersion QOperatingSystemVersion::WindowsVista = + QOperatingSystemVersion(QOperatingSystemVersion::Windows, 6, 0); + /*! \variable QOperatingSystemVersion::Windows7 \brief a version corresponding to Windows 7 (version 6.1). diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h index e99e4f8997e..75c54b60dfa 100644 --- a/src/corelib/global/qoperatingsystemversion.h +++ b/src/corelib/global/qoperatingsystemversion.h @@ -60,6 +60,7 @@ public: Android }; + static const QOperatingSystemVersion WindowsVista; static const QOperatingSystemVersion Windows7; static const QOperatingSystemVersion Windows8; static const QOperatingSystemVersion Windows8_1; diff --git a/src/network/ssl/qsslsocket_openssl11.cpp b/src/network/ssl/qsslsocket_openssl11.cpp index b60b8be41f2..cc2d6ea2d9e 100644 --- a/src/network/ssl/qsslsocket_openssl11.cpp +++ b/src/network/ssl/qsslsocket_openssl11.cpp @@ -68,6 +68,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -147,7 +148,7 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded() //its own cert bundle rather than the system one. //Same logic that disables the unix on demand cert loading. //Unlike unix, we do preload the certificates from the cert store. - if ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) >= QSysInfo::WV_6_0) + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista) s_loadRootCertsOnDemand = true; #endif } diff --git a/src/network/ssl/qsslsocket_winrt.cpp b/src/network/ssl/qsslsocket_winrt.cpp index d54ac2ad735..39c1ce55e32 100644 --- a/src/network/ssl/qsslsocket_winrt.cpp +++ b/src/network/ssl/qsslsocket_winrt.cpp @@ -177,6 +177,7 @@ void QSslSocketPrivate::ensureInitialized() long QSslSocketPrivate::sslLibraryVersionNumber() { + // ### Qt 6: Find a proper replacement for the deprecated method below. return QSysInfo::windowsVersion(); } diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp index bb43072aba8..777b4eea596 100644 --- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp @@ -45,6 +45,7 @@ #include #include +#include #include @@ -612,7 +613,8 @@ bool QNativeWifiEngine::requiresPolling() const { // On Windows XP SP2 and SP3 only connection and disconnection notifications are available. // We need to poll for changes in available wireless networks. - return QSysInfo::WindowsVersion <= QSysInfo::WV_2003; + return QOperatingSystemVersion::current() + <= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 5, 2); } QT_END_NAMESPACE diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index 8a3ae17b1d7..6881ea8f16e 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -84,9 +84,8 @@ static const int windowsRightBorder = 15; // right border on windows */ bool QWindowsVistaStylePrivate::useVista() { - return (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA - && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) - && QWindowsVistaStylePrivate::useXP(); + return QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista + && QWindowsVistaStylePrivate::useXP(); } /* \internal diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index eefe7bcecd4..60e320c44d3 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1917,7 +1917,8 @@ void tst_QFileInfo::owner() DWORD bufSize = 1024; if (GetUserNameW(usernameBuf, &bufSize)) { userName = QString::fromWCharArray(usernameBuf); - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && IsUserAdmin()) { + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista + && IsUserAdmin()) { // Special case : If the user is a member of Administrators group, all files // created by the current user are owned by the Administrators group. LPLOCALGROUP_USERS_INFO_0 pBuf = NULL; diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index eeeb3bc6e26..8703b15dda7 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -496,7 +496,7 @@ void tst_QLockFile::noPermissionsWindows() QSKIP("This test is for desktop Windows only"); #endif #ifdef Q_OS_WIN - if (QSysInfo::windowsVersion() < QSysInfo::WV_WINDOWS7) + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows7) QSKIP("This test requires at least Windows 7"); #endif if (const int p = processProperties()) { diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index 22ac9aa0765..fc5a7d1fab6 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -882,7 +882,7 @@ void tst_QTcpServer::serverAddress_data() QTest::addColumn("listenAddress"); QTest::addColumn("serverAddress"); #ifdef Q_OS_WIN - if (QSysInfo::windowsVersion() < QSysInfo::WV_6_0) + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::WindowsVista) QTest::newRow("Any") << QHostAddress(QHostAddress::Any) << QHostAddress(QHostAddress::AnyIPv4); //windows XP doesn't support dual stack sockets else #endif diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 19b745768aa..e4bc49a9804 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -7654,7 +7655,7 @@ void tst_QWidget::moveWindowInShowEvent() void tst_QWidget::repaintWhenChildDeleted() { #ifdef Q_OS_WIN - if (QSysInfo::WindowsVersion & QSysInfo::WV_VISTA) { + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista) { QTest::qWait(1000); } #endif @@ -8853,7 +8854,7 @@ void tst_QWidget::translucentWidget() #ifdef Q_OS_WIN QWidget *desktopWidget = QApplication::desktop()->screen(0); - if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::WindowsVista) widgetSnapshot = grabWindow(desktopWidget->windowHandle(), labelPos.x(), labelPos.y(), label.width(), label.height()); else #endif diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index a552c919282..68e672e16db 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -353,7 +353,10 @@ void tst_QStyle::testWindowsVistaStyle() QStyle *vistastyle = QStyleFactory::create("WindowsVista"); QVERIFY(testAllFunctions(vistastyle)); - if (QSysInfo::WindowsVersion == QSysInfo::WV_VISTA) + if (QOperatingSystemVersion::current().majorVersion() + == QOperatingSystemVersion::WindowsVista.majorVersion() + && QOperatingSystemVersion::current().minorVersion() + == QOperatingSystemVersion::WindowsVista.minorVersion()) testPainting(vistastyle, "vista"); delete vistastyle; } diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp index df5ff9d448a..3408fc09469 100644 --- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp @@ -174,7 +174,7 @@ void tst_QProgressBar::format() #ifndef Q_OS_MAC // Animated scroll bars get paint events all the time #ifdef Q_OS_WIN - if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) + if (QOperatingSystemVersion::current() < QOperatingSystemVersion::WindowsVista) #endif QVERIFY(!bar.repainted); #endif From 4cb074925006b75bb42aa2e4cdcb3a0a34453174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 4 Jul 2019 16:13:45 +0200 Subject: [PATCH 158/172] tst_QTcpSocket::hostNotFound Only expect failure for the http proxy When I added the QEXPECT_FAIL the http proxy was the only one. That's no longer true after fixing the SOCKS proxy, so let's make the condition more specific. Change-Id: I1eaa5117d5d0219e04cbd091ec54e522fe7b5509 Reviewed-by: Dimitrios Apostolou Reviewed-by: Timur Pocheptsov --- tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index c500c6b3c38..1bb25aa653b 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -865,7 +865,8 @@ void tst_QTcpSocket::hostNotFound() QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); #ifdef QT_TEST_SERVER QFETCH_GLOBAL(bool, setProxy); - if (setProxy) { + QFETCH_GLOBAL(int, proxyType); + if (setProxy && (proxyType & HttpProxy) == HttpProxy) { QEXPECT_FAIL("", "QTBUG-73953: The version of Squid in the docker container behaves " "differently to the one in the network testing server, returning 503 " "when we expect 404", Continue); From 6b26b2ee03bd67fbda4cd343c461560d9c376321 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 4 Jul 2019 11:10:44 +0900 Subject: [PATCH 159/172] Fix build without features.action Change-Id: Ia776cdcb36d07bb89f39c631029458adf2187d90 Reviewed-by: Volker Hilsheimer --- src/widgets/styles/qwindowsstyle.cpp | 1 + src/widgets/widgets/qmdisubwindow.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 1d5934e3f73..c13f6e637d5 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -84,6 +84,7 @@ #include #include #include +#include #include #if QT_CONFIG(animation) diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 77692930fce..474cce983cf 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1986,7 +1986,7 @@ void QMdiSubWindowPrivate::updateActions() for (int i = 0; i < NumWindowStateActions; ++i) setVisible(WindowStateAction(i), false); -#ifdef Q_OS_MACOS +#if defined(Q_OS_MACOS) && QT_CONFIG(action) if (q_func()->style()->inherits("QMacStyle")) for (int i = 0; i < NumWindowStateActions; ++i) if (QAction *action = actions[i]) From 5d79f38370a22443bccd271dea89a4344dcbc2e6 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 5 Jul 2019 07:51:28 +0900 Subject: [PATCH 160/172] Fix build without features.library Change-Id: I3ce4a8e4c6488737115f2f16bfd8f0e1fc5fc4fa Reviewed-by: Volker Hilsheimer --- src/network/ssl/qsslsocket_opensslpre11.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/network/ssl/qsslsocket_opensslpre11.cpp b/src/network/ssl/qsslsocket_opensslpre11.cpp index f5aab821ea1..2af437f0faa 100644 --- a/src/network/ssl/qsslsocket_opensslpre11.cpp +++ b/src/network/ssl/qsslsocket_opensslpre11.cpp @@ -67,7 +67,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE From e36247754e9a1f1f6626fa042d03a9751fcf2167 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 5 Jul 2019 07:50:24 +0900 Subject: [PATCH 161/172] Fix build without features.mimetype Change-Id: I8c5521c5cfbc6c13c78d2bc8805fa5a021675b6c Reviewed-by: Simon Hausmann --- src/widgets/widgets/qtextbrowser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index bee1021950a..2f992b1cff4 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -57,7 +57,6 @@ #endif #include #include -#include QT_BEGIN_NAMESPACE From a393ea072982fa706bb6585295ed6c22e7cbca06 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 5 Jul 2019 06:13:07 +0900 Subject: [PATCH 162/172] Fix build without features.itemmodel Change-Id: I1235bed395a47438bc18571e2331a3432e274dec Reviewed-by: Christian Ehrlicher Reviewed-by: Shawn Rutledge --- src/gui/text/qtextmarkdownwriter.cpp | 5 +++++ src/gui/text/qtextmarkdownwriter_p.h | 5 ++++- src/testlib/qtest.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index f351c8d20b8..cbfb092485f 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -47,6 +47,9 @@ #include "qtextcursor.h" #include "qtextimagehandler_p.h" #include "qloggingcategory.h" +#if QT_CONFIG(itemmodel) +#include "qabstractitemmodel.h" +#endif QT_BEGIN_NAMESPACE @@ -70,6 +73,7 @@ bool QTextMarkdownWriter::writeAll(const QTextDocument *document) return true; } +#if QT_CONFIG(itemmodel) void QTextMarkdownWriter::writeTable(const QAbstractItemModel *table) { QVector tableColumnWidths(table->columnCount()); @@ -101,6 +105,7 @@ void QTextMarkdownWriter::writeTable(const QAbstractItemModel *table) } m_listInfo.clear(); } +#endif void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) { diff --git a/src/gui/text/qtextmarkdownwriter_p.h b/src/gui/text/qtextmarkdownwriter_p.h index 90310250ac7..c3076155d06 100644 --- a/src/gui/text/qtextmarkdownwriter_p.h +++ b/src/gui/text/qtextmarkdownwriter_p.h @@ -56,16 +56,19 @@ #include "qtextdocument_p.h" #include "qtextdocumentwriter.h" -#include "QAbstractTableModel" QT_BEGIN_NAMESPACE +class QAbstractItemModel; + class Q_GUI_EXPORT QTextMarkdownWriter { public: QTextMarkdownWriter(QTextStream &stream, QTextDocument::MarkdownFeatures features); bool writeAll(const QTextDocument *document); +#if QT_CONFIG(itemmodel) void writeTable(const QAbstractItemModel *table); +#endif int writeBlock(const QTextBlock &block, bool table, bool ignoreFormat, bool ignoreEmpty); void writeFrame(const QTextFrame *frame); diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 89abc616d9d..7affdcb8b49 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -51,7 +51,9 @@ #include #include #include +#if QT_CONFIG(itemmodel) #include +#endif #include #include #include @@ -129,12 +131,14 @@ template<> inline char *toString(const QChar &c) return qstrdup(qPrintable(QString::fromLatin1("QChar: '%1' (0x%2)").arg(c).arg(QString::number(static_cast(c.unicode()), 16)))); } +#if QT_CONFIG(itemmodel) template<> inline char *toString(const QModelIndex &idx) { char msg[128]; qsnprintf(msg, sizeof(msg), "QModelIndex(%d,%d,%p,%p)", idx.row(), idx.column(), idx.internalPointer(), idx.model()); return qstrdup(msg); } +#endif template<> inline char *toString(const QPoint &p) { From 95310aac6d38f222da5ce0ca2bd52b4afa261f13 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 23:41:40 +0200 Subject: [PATCH 163/172] Short live QRecursiveMutex! Move the recursive mutex use case out of QMutex into a separate class, unsurprisingly called QRecursiveMutex. As an immediate benefit, 90% of the QMutex users now enjoy a constexpr QMutex ctor. This change prepares for a real split in Qt 6, so that both use-cases are no longer bundled up in one class. [ChangeLog][QtCore][QMutex] Added QRecursiveMutex as a replacement of QMutex(QMutex::Recursive). Change-Id: I79b8724e8a8ee65e4bd0f06acd76103fe4197b8c Reviewed-by: Volker Hilsheimer --- src/corelib/thread/qmutex.cpp | 100 ++++++++++++++++-- src/corelib/thread/qmutex.h | 34 +++++- .../auto/corelib/thread/qmutex/tst_qmutex.cpp | 9 +- 3 files changed, 127 insertions(+), 16 deletions(-) diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index bd3a0fa7ba9..9e52f286eeb 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -147,7 +147,7 @@ public: It is constructed and destroyed with almost no overhead, which means it is fine to have many mutexes as part of other classes. - \sa QMutexLocker, QReadWriteLock, QSemaphore, QWaitCondition + \sa QRecursiveMutex, QMutexLocker, QReadWriteLock, QSemaphore, QWaitCondition */ /*! @@ -156,12 +156,19 @@ public: \value Recursive In this mode, a thread can lock the same mutex multiple times and the mutex won't be unlocked until a corresponding number of unlock() calls - have been made. + have been made. You should use QRecursiveMutex + for this use-case. \value NonRecursive In this mode, a thread may only lock a mutex once. - \sa QMutex() + \sa QMutex(), QRecursiveMutex +*/ + +/*! + \fn QMutex::QMutex() + + Constructs a new mutex. The mutex is created in an unlocked state. */ /*! @@ -205,13 +212,15 @@ QMutex::~QMutex() } /*! \fn void QMutex::lock() + \fn QRecursiveMutex::lock() + Locks the mutex. If another thread has locked the mutex then this call will block until that thread has unlocked it. Calling this function multiple times on the same mutex from the same thread is allowed if this mutex is a - \l{QMutex::Recursive}{recursive mutex}. If this mutex is a - \l{QMutex::NonRecursive}{non-recursive mutex}, this function will + \l{QRecursiveMutex}{recursive mutex}. If this mutex is a + \l{QMutex}{non-recursive mutex}, this function will \e dead-lock when the mutex is locked recursively. \sa unlock() @@ -228,6 +237,7 @@ void QMutex::lock() QT_MUTEX_LOCK_NOEXCEPT } /*! \fn bool QMutex::tryLock(int timeout) + \fn bool QRecursiveMutex::tryLock(int timeout) Attempts to lock the mutex. This function returns \c true if the lock was obtained; otherwise it returns \c false. If another thread has @@ -243,8 +253,8 @@ void QMutex::lock() QT_MUTEX_LOCK_NOEXCEPT Calling this function multiple times on the same mutex from the same thread is allowed if this mutex is a - \l{QMutex::Recursive}{recursive mutex}. If this mutex is a - \l{QMutex::NonRecursive}{non-recursive mutex}, this function will + \l{QRecursiveMutex}{recursive mutex}. If this mutex is a + \l{QMutex}{non-recursive mutex}, this function will \e always return false when attempting to lock the mutex recursively. @@ -262,6 +272,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT } /*! \fn bool QMutex::try_lock() + \fn bool QRecursiveMutex::try_lock() \since 5.8 Attempts to lock the mutex. This function returns \c true if the lock @@ -275,6 +286,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT */ /*! \fn template bool QMutex::try_lock_for(std::chrono::duration duration) + \fn template bool QRecursiveMutex::try_lock_for(std::chrono::duration duration) \since 5.8 Attempts to lock the mutex. This function returns \c true if the lock @@ -290,8 +302,8 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT Calling this function multiple times on the same mutex from the same thread is allowed if this mutex is a - \l{QMutex::Recursive}{recursive mutex}. If this mutex is a - \l{QMutex::NonRecursive}{non-recursive mutex}, this function will + \l{QRecursiveMutex}{recursive mutex}. If this mutex is a + \l{QMutex}{non-recursive mutex}, this function will \e always return false when attempting to lock the mutex recursively. @@ -299,6 +311,7 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT */ /*! \fn template bool QMutex::try_lock_until(std::chrono::time_point timePoint) + \fn template bool QRecursiveMutex::try_lock_until(std::chrono::time_point timePoint) \since 5.8 Attempts to lock the mutex. This function returns \c true if the lock @@ -314,8 +327,8 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT Calling this function multiple times on the same mutex from the same thread is allowed if this mutex is a - \l{QMutex::Recursive}{recursive mutex}. If this mutex is a - \l{QMutex::NonRecursive}{non-recursive mutex}, this function will + \l{QRecursiveMutex}{recursive mutex}. If this mutex is a + \l{QMutex}{non-recursive mutex}, this function will \e always return false when attempting to lock the mutex recursively. @@ -323,6 +336,8 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT */ /*! \fn void QMutex::unlock() + \fn void QRecursiveMutex::unlock() + Unlocks the mutex. Attempting to unlock a mutex in a different thread to the one that locked it results in an error. Unlocking a mutex that is not locked results in undefined behavior. @@ -363,6 +378,58 @@ bool QBasicMutex::isRecursive() const noexcept return QT_PREPEND_NAMESPACE(isRecursive)(d_ptr.loadAcquire()); } +/*! + \class QRecursiveMutex + \inmodule QtCore + \since 5.14 + \brief The QRecursiveMutex class provides access serialization between threads. + + \threadsafe + + \ingroup thread + + The QRecursiveMutex class is a mutex, like QMutex, with which it is + API-compatible. It differs from QMutex by accepting lock() calls from + the same thread any number of times. QMutex would deadlock in this situation. + + QRecursiveMutex is much more expensive to construct and operate on, so + use a plain QMutex whenever you can. Sometimes, one public function, + however, calls another public function, and they both need to lock the + same mutex. In this case, you have two options: + + \list + \li Factor the code that needs mutex protection into private functions, + which assume that the mutex is held when they are called, and lock a + plain QMutex in the public functions before you call the private + implementation ones. + \li Or use a recursive mutex, so it doesn't matter that the first public + function has already locked the mutex when the second one wishes to do so. + \endlist + + \sa QMutex, QMutexLocker, QReadWriteLock, QSemaphore, QWaitCondition +*/ + +/*! + Constructs a new recursive mutex. The mutex is created in an unlocked state. + + \sa lock(), unlock() +*/ +QRecursiveMutex::QRecursiveMutex() + : QMutex() +{ + d_ptr.storeRelaxed(new QRecursiveMutexPrivate); +} + +/*! + Destroys the mutex. + + \warning Destroying a locked mutex may result in undefined behavior. +*/ +QRecursiveMutex::~QRecursiveMutex() +{ + delete static_cast(d_ptr.fetchAndStoreAcquire(nullptr)); +} + /*! \class QMutexLocker \inmodule QtCore @@ -426,6 +493,17 @@ bool QBasicMutex::isRecursive() const noexcept \sa QMutex::lock() */ +/*! + \fn QMutexLocker::QMutexLocker(QRecursiveMutex *mutex) + \since 5.14 + + Constructs a QMutexLocker and locks \a mutex. The mutex will be + unlocked (unlock() called) when the QMutexLocker is destroyed. + If \a mutex is \nullptr, QMutexLocker does nothing. + + \sa QMutex::lock() +*/ + /*! \fn QMutexLocker::~QMutexLocker() diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 0de0869cb22..c693ff65d80 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -62,6 +62,8 @@ QT_BEGIN_NAMESPACE # define QT_MUTEX_LOCK_NOEXCEPT #endif +class QMutex; +class QRecursiveMutex; class QMutexData; class Q_CORE_EXPORT QBasicMutex @@ -120,14 +122,20 @@ private: } friend class QMutex; + friend class QRecursiveMutex; friend class QMutexData; }; class Q_CORE_EXPORT QMutex : public QBasicMutex { public: +#if defined(Q_COMPILER_CONSTEXPR) + constexpr QMutex() = default; +#else + QMutex() { d_ptr.storeRelaxed(nullptr); } +#endif enum RecursionMode { NonRecursive, Recursive }; - explicit QMutex(RecursionMode mode = NonRecursive); + explicit QMutex(RecursionMode mode); ~QMutex(); // BasicLockable concept @@ -164,6 +172,7 @@ public: private: Q_DISABLE_COPY(QMutex) friend class QMutexLocker; + friend class QRecursiveMutex; friend class ::tst_QMutex; #if QT_HAS_INCLUDE() @@ -192,6 +201,24 @@ private: #endif }; +class QRecursiveMutex : private QMutex +{ + // ### Qt 6: make it independent of QMutex + friend class QMutexLocker; +public: + Q_CORE_EXPORT QRecursiveMutex(); + Q_CORE_EXPORT ~QRecursiveMutex(); + + using QMutex::lock; + using QMutex::tryLock; + using QMutex::unlock; + using QMutex::try_lock; +#if QT_HAS_INCLUDE() + using QMutex::try_lock_for; + using QMutex::try_lock_until; +#endif +}; + class Q_CORE_EXPORT QMutexLocker { public: @@ -207,8 +234,11 @@ public: val |= 1; } } + explicit QMutexLocker(QRecursiveMutex *m) QT_MUTEX_LOCK_NOEXCEPT + : QMutexLocker{static_cast(m)} {} #else QMutexLocker(QMutex *) { } + QMutexLocker(QRecursiveMutex *) {} #endif inline ~QMutexLocker() { unlock(); } @@ -285,6 +315,8 @@ private: Q_DISABLE_COPY(QMutex) }; +class QRecursiveMutex : public QMutex {}; + class Q_CORE_EXPORT QMutexLocker { public: diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index 37c5874c024..749aa45916b 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -69,7 +69,8 @@ private slots: static const int iterations = 100; QAtomicInt lockCount(0); -QMutex normalMutex, recursiveMutex(QMutex::Recursive); +QMutex normalMutex; +QRecursiveMutex recursiveMutex; QSemaphore testsTurn; QSemaphore threadsTurn; @@ -993,9 +994,9 @@ public: QMutex mutex; QWaitCondition cond; - QMutex &test_mutex; + QRecursiveMutex &test_mutex; - inline rmutex_Thread(QMutex &m) : test_mutex(m) { } + inline rmutex_Thread(QRecursiveMutex &m) : test_mutex(m) { } void run() { @@ -1024,7 +1025,7 @@ void tst_QMutex::lock_unlock_locked_tryLock() QMutex mutex; mutex_Thread thread(mutex); - QMutex rmutex(QMutex::Recursive); + QRecursiveMutex rmutex; rmutex_Thread rthread(rmutex); for (int i = 0; i < iterations; ++i) { From cd113d0dcb5e6ff71300ed67af5e296dc6f5dccf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Jun 2019 15:47:16 +0200 Subject: [PATCH 164/172] Port some trivial cases from QMutex to QRecursiveMutex In all of these cases, the effect of the change is local to one file. Change-Id: I3bda3aadee3b42e7797183c2330183390b92d1f2 Reviewed-by: Thiago Macieira --- src/corelib/io/qresource.cpp | 4 ++-- src/corelib/kernel/qcoreapplication.cpp | 2 +- src/corelib/plugin/qfactoryloader.cpp | 2 +- src/opengl/qgl.cpp | 7 +------ .../fontdatabases/freetype/qfontengine_ft_p.h | 4 ++-- src/plugins/platforms/android/androidjnimenu.cpp | 4 ++-- .../auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp | 6 +----- tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp | 2 +- 8 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index d143f7fda3b..fcc5b69179b 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -197,13 +197,13 @@ Q_DECLARE_TYPEINFO(QResourceRoot, Q_MOVABLE_TYPE); typedef QList ResourceList; struct QResourceGlobalData { - QMutex resourceMutex{QMutex::Recursive}; + QRecursiveMutex resourceMutex; ResourceList resourceList; QStringList resourceSearchPaths; }; Q_GLOBAL_STATIC(QResourceGlobalData, resourceGlobalData) -static inline QMutex *resourceMutex() +static inline QRecursiveMutex *resourceMutex() { return &resourceGlobalData->resourceMutex; } static inline ResourceList *resourceList() diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 9d8da70e471..87dae896fa2 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2657,7 +2657,7 @@ QString QCoreApplication::applicationVersion() #if QT_CONFIG(library) -Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive)) +Q_GLOBAL_STATIC(QRecursiveMutex, libraryPathMutex) /*! Returns a list of paths that the application will search when diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 8e349f23ce0..6737aeccd27 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -170,7 +170,7 @@ public: Q_GLOBAL_STATIC(QList, qt_factory_loaders) -Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_factoryloader_mutex, (QMutex::Recursive)) +Q_GLOBAL_STATIC(QRecursiveMutex, qt_factoryloader_mutex) QFactoryLoaderPrivate::~QFactoryLoaderPrivate() { diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 2b4af3ef9f6..2c5a40a992a 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1667,11 +1667,6 @@ bool operator!=(const QGLFormat& a, const QGLFormat& b) } struct QGLContextGroupList { - QGLContextGroupList() - : m_mutex(QMutex::Recursive) - { - } - void append(QGLContextGroup *group) { QMutexLocker locker(&m_mutex); m_list.append(group); @@ -1683,7 +1678,7 @@ struct QGLContextGroupList { } QList m_list; - QMutex m_mutex; + QRecursiveMutex m_mutex; }; Q_GLOBAL_STATIC(QGLContextGroupList, qt_context_groups) diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h b/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h index 2d1d5e6572a..2765db29469 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h @@ -116,11 +116,11 @@ private: friend class QFontEngineFT; friend class QtFreetypeData; friend struct QScopedPointerDeleter; - QFreetypeFace() : _lock(QMutex::Recursive) {} + QFreetypeFace() = default; ~QFreetypeFace() {} void cleanup(); QAtomicInt ref; - QMutex _lock; + QRecursiveMutex _lock; QByteArray fontData; QFontEngine::Holder hbFace; diff --git a/src/plugins/platforms/android/androidjnimenu.cpp b/src/plugins/platforms/android/androidjnimenu.cpp index 6f548aba528..f51a3920b8a 100644 --- a/src/plugins/platforms/android/androidjnimenu.cpp +++ b/src/plugins/platforms/android/androidjnimenu.cpp @@ -60,12 +60,12 @@ namespace QtAndroidMenu { static QList pendingContextMenus; static QAndroidPlatformMenu *visibleMenu = 0; - static QMutex visibleMenuMutex(QMutex::Recursive); + static QRecursiveMutex visibleMenuMutex; static QSet menuBars; static QAndroidPlatformMenuBar *visibleMenuBar = 0; static QWindow *activeTopLevelWindow = 0; - static QMutex menuBarMutex(QMutex::Recursive); + static QRecursiveMutex menuBarMutex; static jmethodID openContextMenuMethodID = 0; diff --git a/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp b/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp index 67db5d14589..c83e186ca7b 100644 --- a/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp +++ b/tests/auto/corelib/thread/qmutexlocker/tst_qmutexlocker.cpp @@ -36,7 +36,7 @@ class tst_QMutexLockerThread : public QThread { public: - QMutex mutex; + QRecursiveMutex mutex; QSemaphore semaphore, testSemaphore; void waitForTest() @@ -45,10 +45,6 @@ public: testSemaphore.acquire(); } - tst_QMutexLockerThread() - : mutex(QMutex::Recursive) - { - } }; class tst_QMutexLocker : public QObject diff --git a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp index d27884197a0..3826fa148ea 100644 --- a/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/qthreadonce.cpp @@ -32,7 +32,7 @@ #include "qmutex.h" -Q_GLOBAL_STATIC_WITH_ARGS(QMutex, onceInitializationMutex, (QMutex::Recursive)) +Q_GLOBAL_STATIC(QRecursiveMutex, onceInitializationMutex) enum QOnceExtra { MustRunCode = 0x01, From 5de9dedbc739aeb43546f23b45061231e34b184e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Jun 2019 19:21:42 +0200 Subject: [PATCH 165/172] QtNetwork: bearer: port from QMutex::Recursive to QRecursiveMutex Change-Id: I691ecbaf9ea0796decbb48fd62b25d0a2941d979 Reviewed-by: Thiago Macieira Reviewed-by: Timur Pocheptsov --- src/network/bearer/qbearerengine.cpp | 2 +- src/network/bearer/qbearerengine_p.h | 2 +- src/network/bearer/qnetworkconfigmanager_p.cpp | 2 +- src/network/bearer/qnetworkconfigmanager_p.h | 2 +- src/network/bearer/qnetworkconfiguration_p.h | 3 +-- src/network/bearer/qnetworksession_p.h | 4 ++-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp index dbcf1e530e2..a7c139fe639 100644 --- a/src/network/bearer/qbearerengine.cpp +++ b/src/network/bearer/qbearerengine.cpp @@ -62,7 +62,7 @@ static bool hasUsedConfiguration(const QHash snapConfigurations; QHash userChoiceConfigurations; - mutable QMutex mutex; + mutable QRecursiveMutex mutex; }; QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index a903ecda5fe..91ea063af11 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() - : QObject(), pollTimer(0), mutex(QMutex::Recursive), + : QObject(), pollTimer(0), loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")), forcedPolling(0), firstUpdate(true) { diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 380e25c22f7..4819c2027c0 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -117,7 +117,7 @@ private: QThread *bearerThread; private: - mutable QMutex mutex; + mutable QRecursiveMutex mutex; QFactoryLoader loader; QList sessionEngines; diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h index 2213d2ae141..96854fe8313 100644 --- a/src/network/bearer/qnetworkconfiguration_p.h +++ b/src/network/bearer/qnetworkconfiguration_p.h @@ -65,7 +65,6 @@ class QNetworkConfigurationPrivate : public QSharedData { public: QNetworkConfigurationPrivate() : - mutex(QMutex::Recursive), type(QNetworkConfiguration::Invalid), purpose(QNetworkConfiguration::UnknownPurpose), bearerType(QNetworkConfiguration::BearerUnknown), @@ -73,7 +72,7 @@ public: timeout(DefaultTimeout) {} - mutable QMutex mutex; + mutable QRecursiveMutex mutex; QString name; QString id; diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h index 661587603c7..7c1ff63b68a 100644 --- a/src/network/bearer/qnetworksession_p.h +++ b/src/network/bearer/qnetworksession_p.h @@ -68,7 +68,7 @@ class Q_NETWORK_EXPORT QNetworkSessionPrivate : public QObject public: QNetworkSessionPrivate() : QObject(), - state(QNetworkSession::Invalid), isOpen(false), mutex(QMutex::Recursive) + state(QNetworkSession::Invalid), isOpen(false) {} virtual ~QNetworkSessionPrivate() {} @@ -147,7 +147,7 @@ protected: QNetworkSession::State state; bool isOpen; - QMutex mutex; + QRecursiveMutex mutex; }; QT_END_NAMESPACE From aadf64f08486766bb6d40bcaae47e9b4d6411c28 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Jun 2019 19:01:31 +0200 Subject: [PATCH 166/172] QtGui: port from QMutex::Recursive to QRecursiveMutex Change-Id: I1ce4fcfa1bfb9a89fe3ebe61d049b9b3100fd700 Reviewed-by: Thiago Macieira --- src/gui/kernel/qopenglcontext.cpp | 3 +-- src/gui/kernel/qopenglcontext_p.h | 5 ++--- src/gui/text/qfont.cpp | 2 +- src/gui/text/qfontdatabase.cpp | 6 +++--- src/gui/util/qdesktopservices.cpp | 4 ++-- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index a3b2ea5f86b..326d2823eb3 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -1610,8 +1610,7 @@ void QOpenGLSharedResourceGuard::freeResource(QOpenGLContext *context) QOpenGLMultiGroupSharedResource instance. */ QOpenGLMultiGroupSharedResource::QOpenGLMultiGroupSharedResource() - : active(0), - m_mutex(QMutex::Recursive) + : active(0) { #ifdef QT_GL_CONTEXT_RESOURCE_DEBUG qDebug("Creating context group resource object %p.", this); diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index c6ad893ee6e..833cfb20c35 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -132,7 +132,6 @@ class Q_GUI_EXPORT QOpenGLContextGroupPrivate : public QObjectPrivate public: QOpenGLContextGroupPrivate() : m_context(nullptr) - , m_mutex(QMutex::Recursive) , m_refs(0) { } @@ -147,7 +146,7 @@ public: QOpenGLContext *m_context; QList m_shares; - QMutex m_mutex; + QRecursiveMutex m_mutex; QHash m_resources; QAtomicInt m_refs; @@ -186,7 +185,7 @@ public: private: QAtomicInt active; QList m_groups; - QMutex m_mutex; + QRecursiveMutex m_mutex; }; class QPaintEngineEx; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 2a1d207702e..97e73f07235 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -208,7 +208,7 @@ QFontPrivate::~QFontPrivate() scFont = 0; } -extern QMutex *qt_fontdatabase_mutex(); +extern QRecursiveMutex *qt_fontdatabase_mutex(); #define QT_FONT_ENGINE_FROM_DATA(data, script) data->engines[script] diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 562ee3e2b1e..ce6bb0c3473 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -705,7 +705,7 @@ static QStringList familyList(const QFontDef &req) } Q_GLOBAL_STATIC(QFontDatabasePrivate, privateDb) -Q_GLOBAL_STATIC_WITH_ARGS(QMutex, fontDatabaseMutex, (QMutex::Recursive)) +Q_GLOBAL_STATIC(QRecursiveMutex, fontDatabaseMutex) // used in qguiapplication.cpp void qt_cleanupFontDatabase() @@ -717,8 +717,8 @@ void qt_cleanupFontDatabase() } } -// used in qfontengine_x11.cpp -QMutex *qt_fontdatabase_mutex() +// used in qfont.cpp +QRecursiveMutex *qt_fontdatabase_mutex() { return fontDatabaseMutex(); } diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 8c7cf8682c0..ee0ff4c6ef0 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -60,9 +60,9 @@ class QOpenUrlHandlerRegistry : public QObject { Q_OBJECT public: - inline QOpenUrlHandlerRegistry() : mutex(QMutex::Recursive) {} + QOpenUrlHandlerRegistry() = default; - QMutex mutex; + QRecursiveMutex mutex; struct Handler { From 619b92385ead871d1a220bf4bed5a6d2dd09a4fc Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Jun 2019 19:24:49 +0200 Subject: [PATCH 167/172] QtNetwork: port remaining uses of QMutex::Recursive to QRecursiveMutex In one case, added NSDMI to avoid churning the ctor-init-list. Change-Id: I5587d5cb7e393f60ad29cb5186127304d27d1d46 Reviewed-by: Thiago Macieira --- src/network/access/qnetworkaccessbackend.cpp | 4 ++-- src/network/kernel/qhostinfo.cpp | 2 +- src/network/kernel/qhostinfo_p.h | 2 +- src/network/kernel/qnetworkproxy.cpp | 5 ++--- src/network/socket/qsocks5socketengine.cpp | 6 ++---- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 848fc84de7b..566e4100514 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE class QNetworkAccessBackendFactoryData: public QList { public: - QNetworkAccessBackendFactoryData() : mutex(QMutex::Recursive) + QNetworkAccessBackendFactoryData() { valid.ref(); } @@ -68,7 +68,7 @@ public: valid.deref(); } - QMutex mutex; + QRecursiveMutex mutex; //this is used to avoid (re)constructing factory data from destructors of other global classes static QBasicAtomicInt valid; }; diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 9374728244d..25ff8733078 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -891,7 +891,7 @@ void QHostInfoRunnable::run() // thread goes back to QThreadPool } -QHostInfoLookupManager::QHostInfoLookupManager() : mutex(QMutex::Recursive), wasDeleted(false) +QHostInfoLookupManager::QHostInfoLookupManager() : wasDeleted(false) { moveToThread(QCoreApplicationPrivate::mainThread()); #if QT_CONFIG(thread) diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 3c0ee2a0d82..7df3f5414c3 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -252,7 +252,7 @@ protected: #if QT_CONFIG(thread) QThreadPool threadPool; #endif - QMutex mutex; + QRecursiveMutex mutex; bool wasDeleted; diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 2f840e9e13d..110550c4236 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -254,8 +254,7 @@ class QGlobalNetworkProxy { public: QGlobalNetworkProxy() - : mutex(QMutex::Recursive) - , applicationLevelProxy(0) + : applicationLevelProxy(0) , applicationLevelProxyFactory(0) #if QT_CONFIG(socks5) , socks5SocketEngineHandler(0) @@ -338,7 +337,7 @@ public: QList proxyForQuery(const QNetworkProxyQuery &query); private: - QMutex mutex; + QRecursiveMutex mutex; QNetworkProxy *applicationLevelProxy; QNetworkProxyFactory *applicationLevelProxyFactory; #if QT_CONFIG(socks5) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 0457d771119..8a030601dce 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -322,8 +322,8 @@ public: protected: void timerEvent(QTimerEvent * event) override; - QMutex mutex; - int sweepTimerId; + QRecursiveMutex mutex; + int sweepTimerId = -1; //socket descriptor, data, timestamp QHash store; }; @@ -331,8 +331,6 @@ protected: Q_GLOBAL_STATIC(QSocks5BindStore, socks5BindStore) QSocks5BindStore::QSocks5BindStore() - : mutex(QMutex::Recursive) - , sweepTimerId(-1) { QCoreApplication *app = QCoreApplication::instance(); if (app && app->thread() != thread()) From eea99e1e8f3eb67fda35dd3a656fe9b5a9be84f2 Mon Sep 17 00:00:00 2001 From: Andreas Hartmetz Date: Mon, 10 Jun 2019 14:39:04 +0200 Subject: [PATCH 168/172] Fontconfig font database: Short-circuit matching by filename If the filename matches, no other matching is necessary. Fontconfig doesn't have a fast path for that, so implement one here. Fontconfig is unlikely to add that fast path, see here: https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/103 With -O1 builds of Qt and KDE stack, 358 fonts installed according to KDE systemsetting, on a Ryzen 1800X, startup time of kwrite decreases as following according to perf stat: msec task-clock: ~480 ms to ~455 ms cycles: ~1.73e9 to ~1.65e9 Change-Id: I630a80e4bed2647d5bbd95247005aab7d0cb0363 Reviewed-by: Allan Sandfeld Jensen --- .../fontconfig/qfontconfigdatabase.cpp | 76 +++++++++++++------ 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 7abf2957820..e28b40c2401 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -927,38 +927,66 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef antialias = antialiasingEnabled - 1; } - QFontEngine::GlyphFormat format; - // try and get the pattern + // try to find a match for fid + const QFontEngine::FaceId fid = engine->faceId(); FcPattern *pattern = FcPatternCreate(); + FcPattern *match = nullptr; - FcValue value; - value.type = FcTypeString; - QByteArray cs = fontDef.family.toUtf8(); - value.u.s = (const FcChar8 *)cs.data(); - FcPatternAdd(pattern,FC_FAMILY,value,true); - - QFontEngine::FaceId fid = engine->faceId(); - - if (!fid.filename.isEmpty()) { - value.u.s = (const FcChar8 *)fid.filename.data(); - FcPatternAdd(pattern,FC_FILE,value,true); - - value.type = FcTypeInteger; - value.u.i = fid.index; - FcPatternAdd(pattern,FC_INDEX,value,true); + // try a trivial match by filename - FC_FILE is highest priority, so if it matches, FcFontMatch + // will just find the file (fine) and spend a millisecond or so doing unnecessary work (bad). + if (!fid.filename.isEmpty() && QFile::exists(QString::fromUtf8(fid.filename))) { + FcBlanks *blanks = FcConfigGetBlanks(nullptr); + int count = 0; + FcPattern *fileMatch = FcFreeTypeQuery((const FcChar8 *)fid.filename.data(), fid.index, + blanks, &count); + if (fileMatch) { + // Apply Fontconfig configuration - FcFreeTypeQuery only returns information stored in + // the font file, we also want to respect system and user settings. + FcConfigSubstitute(0, pattern, FcMatchPattern); + FcDefaultSubstitute(pattern); + match = FcFontRenderPrepare(0, pattern, fileMatch); + FcPatternDestroy(fileMatch); + } } - if (fontDef.pixelSize > 0.1) - FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontDef.pixelSize); + if (!match) { + FcValue value; - FcResult result; + // Fontconfig rules might process this information for arbitrary purposes, so add it, + // even though we already know that it doesn't match an existing file. + if (!fid.filename.isEmpty()) { + value.type = FcTypeString; + value.u.s = (const FcChar8 *)fid.filename.data(); + FcPatternAdd(pattern, FC_FILE, value, true); - FcConfigSubstitute(0, pattern, FcMatchPattern); - FcDefaultSubstitute(pattern); + value.type = FcTypeInteger; + value.u.i = fid.index; + FcPatternAdd(pattern, FC_INDEX, value, true); + } - FcPattern *match = FcFontMatch(0, pattern, &result); + const QByteArray cs = fontDef.family.toUtf8(); + value.type = FcTypeString; + value.u.s = (const FcChar8 *)cs.data(); + FcPatternAdd(pattern, FC_FAMILY, value, true); + + if (fontDef.pixelSize > 0.1) { + value.type = FcTypeDouble; + value.u.d = fontDef.pixelSize; + FcPatternAdd(pattern, FC_PIXEL_SIZE, value, true); + } + + FcResult result; + + FcConfigSubstitute(0, pattern, FcMatchPattern); + FcDefaultSubstitute(pattern); + + match = FcFontMatch(0, pattern, &result); + } + + QFontEngine::GlyphFormat format; if (match) { - engine->setDefaultHintStyle(defaultHintStyleFromMatch((QFont::HintingPreference)fontDef.hintingPreference, match, useXftConf)); + engine->setDefaultHintStyle(defaultHintStyleFromMatch( + (QFont::HintingPreference)fontDef.hintingPreference, match, useXftConf)); FcBool fc_autohint; if (FcPatternGetBool(match, FC_AUTOHINT,0, &fc_autohint) == FcResultMatch) From 3a1f9dec7cdc0f6504eed8157f6fcb0a9638c109 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 1 Jul 2019 20:55:46 +0200 Subject: [PATCH 169/172] Q_ARRAY_LITERAL: protect the check for literal types Some compilers (hello, MSVC) do not produce literal types in Qt because their constexpr support has been blacklisted. Therefore, amend the check for literal types in Q_ARRAY_LITERAL: only do the check if the compiler supports constexpr. Change-Id: I7cffe00dde447d975aa6a7d02248df9c351508ff Reviewed-by: Marc Mutz --- src/corelib/tools/qarraydata.h | 8 +++++++- .../auto/corelib/tools/qarraydata/tst_qarraydata.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 074072b9877..dcd95924c17 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -323,8 +323,14 @@ struct QArrayDataPointerRef }()) \ /**/ +#ifdef Q_COMPILER_CONSTEXPR +#define Q_ARRAY_LITERAL_CHECK_LITERAL_TYPE(Type) Q_STATIC_ASSERT(std::is_literal_type::value) +#else +#define Q_ARRAY_LITERAL_CHECK_LITERAL_TYPE(Type) do {} while (0) +#endif + #define Q_ARRAY_LITERAL_IMPL(Type, ...) \ - Q_STATIC_ASSERT(std::is_literal_type::value); \ + Q_ARRAY_LITERAL_CHECK_LITERAL_TYPE(Type); \ \ /* Portable compile-time array size computation */ \ Q_CONSTEXPR Type data[] = { __VA_ARGS__ }; Q_UNUSED(data); \ diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 7db7d71b1fd..25e2f21d031 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -1625,6 +1625,18 @@ void tst_QArrayData::literals() QCOMPARE(const_(v)[i], char('A' + i)); QCOMPARE(const_(v)[10], char('\0')); } + + { + struct LiteralType { + int value; + Q_DECL_CONSTEXPR LiteralType(int v = 0) : value(v) {} + }; + + QArrayDataPointer d = Q_ARRAY_LITERAL(LiteralType, LiteralType(0), LiteralType(1), LiteralType(2)); + QCOMPARE(d->size, 3); + for (int i = 0; i < 3; ++i) + QCOMPARE(d->data()[i].value, i); + } } // Variadic Q_ARRAY_LITERAL need to be available in the current configuration. From 777c98ad9f3700ea259ea88faba872d1f974880a Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 11 Jun 2019 09:21:30 +0200 Subject: [PATCH 170/172] QDBusConnectionInterface: Add activatableServiceNames This allows to query all names that can be activated on the bus. Change-Id: I8f894bf858eb18b67a074ca666ad3200ed99c373 Reviewed-by: Thiago Macieira --- src/dbus/qdbusconnectioninterface.cpp | 12 ++++++++++++ src/dbus/qdbusconnectioninterface.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp index ebb38034893..a2335a1795a 100644 --- a/src/dbus/qdbusconnectioninterface.cpp +++ b/src/dbus/qdbusconnectioninterface.cpp @@ -198,6 +198,18 @@ QDBusReply QDBusConnectionInterface::registeredServiceNames() const return internalConstCall(QDBus::AutoDetect, QLatin1String("ListNames")); } +/*! + \property QDBusConnectionInterface::activatableServiceNames + \brief holds the activatable service names + \since 5.14 + + Lists all names that can be activated on the bus. +*/ +QDBusReply QDBusConnectionInterface::activatableServiceNames() const +{ + return internalConstCall(QDBus::AutoDetect, QLatin1String("ListActivatableNames")); +} + /*! Returns \c true if the service name \a serviceName has is currently registered. diff --git a/src/dbus/qdbusconnectioninterface.h b/src/dbus/qdbusconnectioninterface.h index c7b15737226..d19e116c537 100644 --- a/src/dbus/qdbusconnectioninterface.h +++ b/src/dbus/qdbusconnectioninterface.h @@ -68,6 +68,7 @@ class Q_DBUS_EXPORT QDBusConnectionInterface: public QDBusAbstractInterface ~QDBusConnectionInterface(); Q_PROPERTY(QDBusReply registeredServiceNames READ registeredServiceNames) + Q_PROPERTY(QDBusReply activatableServiceNames READ activatableServiceNames) public: enum ServiceQueueOptions { @@ -90,6 +91,7 @@ public: public Q_SLOTS: QDBusReply registeredServiceNames() const; + QDBusReply activatableServiceNames() const; QDBusReply isServiceRegistered(const QString &serviceName) const; QDBusReply serviceOwner(const QString &name) const; QDBusReply unregisterService(const QString &serviceName); From 07553d03534e66b13602bf41937e9221020e70d9 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Sat, 6 Jul 2019 13:13:42 +0200 Subject: [PATCH 171/172] QTextBrowser: assume Markdown is UTF-8 That's how CommonMark specifies it. The HTML codec-guessing algorithm was making it fall back to Latin1 in practice, which was screwing up any Unicode characters found in the markdown source. Change-Id: I4021adc4a68591ecfd56ef24971af53ce3e9c96d Reviewed-by: Gatis Paeglis --- src/widgets/widgets/qtextbrowser.cpp | 12 +++++--- .../qtextbrowser/quotesAndFractions.md | 1 + .../widgets/qtextbrowser/tst_qtextbrowser.cpp | 28 +++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 2f992b1cff4..7a77f86de2c 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -312,13 +312,17 @@ void QTextBrowserPrivate::setSource(const QUrl &url, QTextDocument::ResourceType if (data.type() == QVariant::String) { txt = data.toString(); } else if (data.type() == QVariant::ByteArray) { + if (type == QTextDocument::HtmlResource) { #if QT_CONFIG(textcodec) - QByteArray ba = data.toByteArray(); - QTextCodec *codec = Qt::codecForHtml(ba); - txt = codec->toUnicode(ba); + QByteArray ba = data.toByteArray(); + QTextCodec *codec = Qt::codecForHtml(ba); + txt = codec->toUnicode(ba); #else - txt = data.toString(); + txt = data.toString(); #endif + } else { + txt = QString::fromUtf8(data.toByteArray()); + } } if (Q_UNLIKELY(txt.isEmpty())) qWarning("QTextBrowser: No document for %s", url.toString().toLatin1().constData()); diff --git a/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md b/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md new file mode 100644 index 00000000000..6bad9cb95b3 --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/quotesAndFractions.md @@ -0,0 +1 @@ +you’ll hope to see ❝quotes❞ ﹠1½ ⅔ ¼ ⅗ ⅚ ⅝ some “vulgar” fractions (pardon my «French») diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp index 083e297941b..27bf0ce7bea 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp @@ -94,6 +94,8 @@ private slots: void urlEncoding(); void sourceType_data(); void sourceType(); + void unicode_data(); + void unicode(); private: TestBrowser *browser; @@ -721,5 +723,31 @@ void tst_QTextBrowser::sourceType() QCOMPARE(maxHeadingLevel, expectedMaxHeadingLevel); } +void tst_QTextBrowser::unicode_data() +{ + QTest::addColumn("sourceFile"); + QTest::addColumn("sourceType"); + QTest::addColumn("expectedText"); + +#if QT_CONFIG(textmarkdownreader) + QTest::newRow("markdown with quotes and fractions") << "quotesAndFractions.md" << QTextDocument::MarkdownResource << + "you\u2019ll hope to see \u275Dquotes\u275E \uFE601\u00BD \u2154 \u00BC \u2157 \u215A \u215D some \u201Cvulgar\u201D fractions (pardon my \u00ABFrench\u00BB)"; +#endif +} + +void tst_QTextBrowser::unicode() +{ + QFETCH(QString, sourceFile); + QFETCH(QTextDocument::ResourceType, sourceType); + QFETCH(QString, expectedText); + browser->setSource(QUrl::fromLocalFile(QFINDTESTDATA(sourceFile)), sourceType); + QTextFrame::iterator iterator = browser->document()->rootFrame()->begin(); + while (!iterator.atEnd()) { + QString blockText = iterator++.currentBlock().text(); + if (!blockText.isEmpty()) + QCOMPARE(blockText, expectedText); + } +} + QTEST_MAIN(tst_QTextBrowser) #include "tst_qtextbrowser.moc" From c39910993eaf6a7d68fbbe366d990f3f972533ca Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 8 Jul 2019 10:21:46 +0900 Subject: [PATCH 172/172] Fix build without features.textmarkdownwriter Change-Id: I30b39bb6ac4c24281c7fc87573936f62512ce015 Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qwidgettextcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index ccf02da219f..70e1c148a1e 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -3175,7 +3175,7 @@ QString QWidgetTextControl::toHtml() const } #endif -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(textmarkdownwriter) QString QWidgetTextControl::toMarkdown(QTextDocument::MarkdownFeatures features) const { return document()->toMarkdown(features);