From 92f6bd3a155c2d68dd84be8e42a5147a75cbe38c Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 4 May 2011 17:40:15 +0200 Subject: [PATCH 01/59] Use OpenSSL X509_NAME_ENTRY API to parse UTF8 subjectName/issuerName ... to be able to display non-ASCII names from subject and issuerInfo. Task-number: QTBUG-7912 Merge-request: 922 Reviewed-by: Peter Hartmann (cherry picked from commit e5d94256be2525c24a8b61edd771662b7f2b8be3) --- src/network/ssl/qsslcertificate.cpp | 47 ++++++------------- .../ssl/qsslsocket_openssl_symbols.cpp | 12 ++++- .../ssl/qsslsocket_openssl_symbols_p.h | 6 ++- 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index a5cdf011aac..988743852c3 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE // forward declaration -static QMap _q_mapFromOnelineName(char *name); +static QMap _q_mapFromX509Name(X509_NAME *name); /*! Constructs a QSslCertificate by reading \a format encoded data @@ -324,7 +324,7 @@ QString QSslCertificate::issuerInfo(SubjectInfo info) const // lazy init if (d->issuerInfo.isEmpty() && d->x509) d->issuerInfo = - _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(d->x509), 0, 0)); + _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); return d->issuerInfo.value(_q_SubjectInfoToString(info)); } @@ -341,7 +341,7 @@ QString QSslCertificate::issuerInfo(const QByteArray &tag) const // lazy init if (d->issuerInfo.isEmpty() && d->x509) d->issuerInfo = - _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(d->x509), 0, 0)); + _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); return d->issuerInfo.value(QString::fromLatin1(tag)); } @@ -360,7 +360,7 @@ QString QSslCertificate::subjectInfo(SubjectInfo info) const // lazy init if (d->subjectInfo.isEmpty() && d->x509) d->subjectInfo = - _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(d->x509), 0, 0)); + _q_mapFromX509Name(q_X509_get_subject_name(d->x509)); return d->subjectInfo.value(_q_SubjectInfoToString(info)); } @@ -376,7 +376,7 @@ QString QSslCertificate::subjectInfo(const QByteArray &tag) const // lazy init if (d->subjectInfo.isEmpty() && d->x509) d->subjectInfo = - _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(d->x509), 0, 0)); + _q_mapFromX509Name(q_X509_get_subject_name(d->x509)); return d->subjectInfo.value(QString::fromLatin1(tag)); } @@ -666,37 +666,18 @@ QByteArray QSslCertificatePrivate::QByteArray_from_X509(X509 *x509, QSsl::Encodi return BEGINCERTSTRING "\n" + tmp + ENDCERTSTRING "\n"; } -static QMap _q_mapFromOnelineName(char *name) +static QMap _q_mapFromX509Name(X509_NAME *name) { QMap info; - QString infoStr = QString::fromLocal8Bit(name); - q_CRYPTO_free(name); - - // ### The right-hand encoding seems to allow hex (Regulierungsbeh\xC8orde) - //entry.replace(QLatin1String("\\x"), QLatin1String("%")); - //entry = QUrl::fromPercentEncoding(entry.toLatin1()); - // ### See RFC-4630 for more details! - - QRegExp rx(QLatin1String("/([A-Za-z]+)=(.+)")); - - int pos = 0; - while ((pos = rx.indexIn(infoStr, pos)) != -1) { - const QString name = rx.cap(1); - - QString value = rx.cap(2); - const int valuePos = rx.pos(2); - - const int next = rx.indexIn(value); - if (next == -1) { - info.insert(name, value); - break; - } - - value = value.left(next); - info.insert(name, value); - pos = valuePos + value.length(); + for( int i = 0; i < q_X509_NAME_entry_count(name); ++i ) + { + X509_NAME_ENTRY *e = q_X509_NAME_get_entry( name, i ); + const char *obj = q_OBJ_nid2sn( q_OBJ_obj2nid( q_X509_NAME_ENTRY_get_object( e ) ) ); + unsigned char *data = 0; + int size = q_ASN1_STRING_to_UTF8( &data, q_X509_NAME_ENTRY_get_data( e ) ); + info[QString::fromUtf8( obj )] = QString::fromUtf8( (char*)data, size ); + q_CRYPTO_free( data ); } - return info; } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index b1310ccb8d0..6cb4794559c 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -101,6 +101,7 @@ DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return) DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return) DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return) +DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return); DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return) DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return) DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return) @@ -248,7 +249,10 @@ DEFINEFUNC4(void *, X509_get_ext_d2i, X509 *a, a, int b, b, int *c, c, int *d, d DEFINEFUNC(X509_NAME *, X509_get_issuer_name, X509 *a, a, return 0, return) DEFINEFUNC(X509_NAME *, X509_get_subject_name, X509 *a, a, return 0, return) DEFINEFUNC(int, X509_verify_cert, X509_STORE_CTX *a, a, return -1, return) -DEFINEFUNC3(char *, X509_NAME_oneline, X509_NAME *a, a, char *b, b, int c, c, return 0, return) +DEFINEFUNC(int, X509_NAME_entry_count, X509_NAME *a, a, return 0, return) +DEFINEFUNC2(X509_NAME_ENTRY *, X509_NAME_get_entry, X509_NAME *a, a, int b, b, return 0, return) +DEFINEFUNC(ASN1_STRING *, X509_NAME_ENTRY_get_data, X509_NAME_ENTRY *a, a, return 0, return) +DEFINEFUNC(ASN1_OBJECT *, X509_NAME_ENTRY_get_object, X509_NAME_ENTRY *a, a, return 0, return) DEFINEFUNC(EVP_PKEY *, X509_PUBKEY_get, X509_PUBKEY *a, a, return 0, return) DEFINEFUNC(void, X509_STORE_free, X509_STORE *a, a, return, DUMMYARG) DEFINEFUNC(X509_STORE *, X509_STORE_new, DUMMYARG, DUMMYARG, return 0, return) @@ -647,6 +651,7 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(ASN1_INTEGER_get) RESOLVEFUNC(ASN1_STRING_data) RESOLVEFUNC(ASN1_STRING_length) + RESOLVEFUNC(ASN1_STRING_to_UTF8) RESOLVEFUNC(BIO_ctrl) RESOLVEFUNC(BIO_free) RESOLVEFUNC(BIO_new) @@ -736,7 +741,10 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(SSLv3_server_method) RESOLVEFUNC(SSLv23_server_method) RESOLVEFUNC(TLSv1_server_method) - RESOLVEFUNC(X509_NAME_oneline) + RESOLVEFUNC(X509_NAME_entry_count) + RESOLVEFUNC(X509_NAME_get_entry) + RESOLVEFUNC(X509_NAME_ENTRY_get_data) + RESOLVEFUNC(X509_NAME_ENTRY_get_object) RESOLVEFUNC(X509_PUBKEY_get) RESOLVEFUNC(X509_STORE_free) RESOLVEFUNC(X509_STORE_new) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index 49830acc1e9..ceff57d9d86 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -204,6 +204,7 @@ bool q_resolveOpenSslSymbols(); long q_ASN1_INTEGER_get(ASN1_INTEGER *a); unsigned char * q_ASN1_STRING_data(ASN1_STRING *a); int q_ASN1_STRING_length(ASN1_STRING *a); +int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b); long q_BIO_ctrl(BIO *a, int b, long c, void *d); int q_BIO_free(BIO *a); BIO *q_BIO_new(BIO_METHOD *a); @@ -360,7 +361,10 @@ void *q_X509_get_ext_d2i(X509 *a, int b, int *c, int *d); X509_NAME *q_X509_get_issuer_name(X509 *a); X509_NAME *q_X509_get_subject_name(X509 *a); int q_X509_verify_cert(X509_STORE_CTX *ctx); -char *q_X509_NAME_oneline(X509_NAME *a, char *b, int c); +int q_X509_NAME_entry_count(X509_NAME *a); +X509_NAME_ENTRY *q_X509_NAME_get_entry(X509_NAME *a,int b); +ASN1_STRING *q_X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *a); +ASN1_OBJECT *q_X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *a); EVP_PKEY *q_X509_PUBKEY_get(X509_PUBKEY *a); void q_X509_STORE_free(X509_STORE *store); X509_STORE *q_X509_STORE_new(); From fe54165149f4220eb983ac7f75747bcd99d8b68d Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Tue, 1 Feb 2011 11:29:13 +0100 Subject: [PATCH 02/59] fix coding style for merge request re. utf8 characters in SSL certs fixes minor coding issues for "Use OpenSSL X509_NAME_ENTRY API to parse UTF8 subjectName/issuerName" Task-number: QTBUG-7912 Reviewed-by: Peter Hartmann (cherry picked from commit 2e8d206fd9f656cd88b797c059ef83ed3df32881) --- src/network/ssl/qsslcertificate.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 988743852c3..3a70327020f 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -669,14 +669,13 @@ QByteArray QSslCertificatePrivate::QByteArray_from_X509(X509 *x509, QSsl::Encodi static QMap _q_mapFromX509Name(X509_NAME *name) { QMap info; - for( int i = 0; i < q_X509_NAME_entry_count(name); ++i ) - { - X509_NAME_ENTRY *e = q_X509_NAME_get_entry( name, i ); - const char *obj = q_OBJ_nid2sn( q_OBJ_obj2nid( q_X509_NAME_ENTRY_get_object( e ) ) ); + for (int i = 0; i < q_X509_NAME_entry_count(name); ++i) { + X509_NAME_ENTRY *e = q_X509_NAME_get_entry(name, i); + const char *obj = q_OBJ_nid2sn(q_OBJ_obj2nid(q_X509_NAME_ENTRY_get_object(e))); unsigned char *data = 0; - int size = q_ASN1_STRING_to_UTF8( &data, q_X509_NAME_ENTRY_get_data( e ) ); - info[QString::fromUtf8( obj )] = QString::fromUtf8( (char*)data, size ); - q_CRYPTO_free( data ); + int size = q_ASN1_STRING_to_UTF8(&data, q_X509_NAME_ENTRY_get_data(e)); + info[QString::fromUtf8(obj)] = QString::fromUtf8((char*)data, size); + q_CRYPTO_free(data); } return info; } From a89436fd9df78a73ff1619fab17cff49e2fd3dd3 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Mon, 21 Mar 2011 18:15:01 +0100 Subject: [PATCH 03/59] add auto test for SSL certificates containing utf8 characters Task-number: QTBUG-7912 Reviewed-by: Peter Hartmann (cherry picked from commit 19c77b5e5e5fefedafcfbd587c3fbb4114d7c641) --- .../certificates/cert-ss-san-utf8.pem | 16 ++++++++++ .../certificates/cert-ss-san-utf8.pem.san | 5 +++ .../certificates/gencertificates.sh | 10 ++++++ .../qsslcertificate/tst_qsslcertificate.cpp | 32 ++++++++++++++++--- 4 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem create mode 100644 tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san diff --git a/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem new file mode 100644 index 00000000000..e1b731d69bd --- /dev/null +++ b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICkTCCAfqgAwIBAgIJAL1nF+PLAF2KMA0GCSqGSIb3DQEBBQUAMGkxKzApBgNV +BAoMIkjElcSCxrLDvyDKjeG6v8qI4bq34bi7IFLDqWPDtnJkxZ0xFTATBgNVBAsM +DOOIp0HjiYHvvatCQzEWMBQGA1UEAwwNSm9obm55IEd1aXRhcjELMAkGA1UEBhMC +Tk8wHhcNMTEwNTA1MDgxMzEwWhcNMTEwNjA0MDgxMzEwWjBpMSswKQYDVQQKDCJI +xJXEgsayw78gyo3hur/KiOG6t+G4uyBSw6ljw7ZyZMWdMRUwEwYDVQQLDAzjiKdB +44mB772rQkMxFjAUBgNVBAMMDUpvaG5ueSBHdWl0YXIxCzAJBgNVBAYTAk5PMIGf +MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2zSxS17I6596dJE/VAmGz+06D9S8n +3C0hnIGNVu+LwbgDJTvOw0SzNj4UP72UGgd3UI1KLBg5XWIsRNmE3COJMMh6syjI +L1Ept+tVXxGL6n4gl+0nZ7dkUyxJmeFtigYrL+qCH1yd5rmf3sC3jO4IosuAiG66 +IDkJEVo64NT8ZQIDAQABo0EwPzA9BgNVHREENjA0gQ9hcm5lQGZvb2Jhci5vcmeC +Dnd3dy5mb29iYXIub3JngRFiamFybmVAZm9vYmFyLm9yZzANBgkqhkiG9w0BAQUF +AAOBgQAqVhbC0/EUFdnKlYV3PrknwGX1dPEPGJuIQHa0KpoicvNiOhs1HxBDYbzc +F6wcAMEynq4YwGKhcQLZOs2mo0LreAjA9rU/yBnqrnUW/4gxtUUvmJKK+62IjfLp +eO1L+1NcEMJiaZf8fip4VXhXdOYUhgE8WUZ1UJRC6w3T/yAgcQ== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san new file mode 100644 index 00000000000..f46a637da4f --- /dev/null +++ b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san @@ -0,0 +1,5 @@ +[subj_alt_name] +subjectAltName=\ + email:arne@foobar.org,\ + DNS:www.foobar.org,\ + email:bjarne@foobar.org diff --git a/tests/auto/qsslcertificate/certificates/gencertificates.sh b/tests/auto/qsslcertificate/certificates/gencertificates.sh index e705785d409..c8a5db65700 100755 --- a/tests/auto/qsslcertificate/certificates/gencertificates.sh +++ b/tests/auto/qsslcertificate/certificates/gencertificates.sh @@ -90,5 +90,15 @@ openssl req -x509 -in req-san.pem -out $outname -key rsa-pri-1024.pem \ -config san.cnf -extensions subj_alt_name /bin/cp san.cnf $outname.san +#--- Non-ASCII Subject --------------------------------------------------------------------- +echo -e "\n generating self signed root cert. with Subject containing UTF-8 characters ..." +outname=cert-ss-san-utf8.pem +#subject="/O=HĕĂƲÿ ʍếʈặḻ Récördŝ/OU=㈧A㉁ォBC/CN=Johnny Guitar/C=NO" +subject=$'/O=H\xc4\x95\xc4\x82\xc6\xb2\xc3\xbf \xca\x8d\xe1\xba\xbf\xca\x88\xe1\xba\xb7\xe1\xb8\xbb R\xc3\xa9c\xc3\xb6rd\xc5\x9d/OU=\xe3\x88\xa7A\xe3\x89\x81\xef\xbd\xabBC/CN=Johnny Guitar/C=NO' +openssl req -out req-san.pem -new -key rsa-pri-1024.pem -utf8 -subj "$subject" +openssl req -x509 -in req-san.pem -out $outname -key rsa-pri-1024.pem \ + -config san.cnf -extensions subj_alt_name -nameopt multiline,utf8,-esc_msb +/bin/cp san.cnf $outname.san + echo -e "\n cleaning up ..." /bin/rm rsa-pri-1024.pem rsa-pub-1024.* req*.pem diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 57f2fa8c049..a91bf0f80e9 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -96,6 +96,7 @@ private slots: void digest_data(); void digest(); void alternateSubjectNames_data(); + void utf8SubjectNames(); void alternateSubjectNames(); void publicKey_data(); void publicKey(); @@ -407,6 +408,27 @@ void tst_QSslCertificate::alternateSubjectNames() } } +void tst_QSslCertificate::utf8SubjectNames() +{ + QSslCertificate cert = QSslCertificate::fromPath("certificates/cert-ss-san-utf8.pem", QSsl::Pem, + QRegExp::FixedString).first(); + QVERIFY(!cert.isNull()); + + // O is "Heavy Metal Records" with heavy use of "decorations" like accents, umlauts etc., + // OU uses arabian / asian script letters near codepoint 64K. + // strings split where the compiler would otherwise find three-digit hex numbers + static const char *o = "H\xc4\x95\xc4\x82\xc6\xb2\xc3\xbf \xca\x8d\xe1\xba\xbf\xca\x88\xe1\xba" + "\xb7\xe1\xb8\xbb R\xc3\xa9" "c" "\xc3\xb6rd\xc5\x9d"; + static const char *ou = "\xe3\x88\xa7" "A" "\xe3\x89\x81\xef\xbd\xab" "BC"; + + // the following two tests should help find "\x"-literal encoding bugs in the test itself + QCOMPARE(cert.subjectInfo("O").length(), QString::fromUtf8(o).length()); + QCOMPARE (cert.subjectInfo("O").toUtf8().toHex(), QByteArray(o).toHex()); + + QCOMPARE(cert.subjectInfo("O"), QString::fromUtf8(o)); + QCOMPARE(cert.subjectInfo("OU"), QString::fromUtf8(ou)); +} + void tst_QSslCertificate::publicKey_data() { QTest::addColumn("certFilePath"); @@ -519,13 +541,13 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"certificates/*\" fixed der") << QString("certificates/*") << int(QRegExp::FixedString) << false << 0; QTest::newRow("\"certificates/*\" regexp pem") << QString("certificates/*") << int(QRegExp::RegExp) << true << 0; QTest::newRow("\"certificates/*\" regexp der") << QString("certificates/*") << int(QRegExp::RegExp) << false << 0; - QTest::newRow("\"certificates/*\" wildcard pem") << QString("certificates/*") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("\"certificates/*\" wildcard pem") << QString("certificates/*") << int(QRegExp::Wildcard) << true << 5; QTest::newRow("\"certificates/*\" wildcard der") << QString("certificates/*") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"c*/c*.pem\" fixed pem") << QString("c*/c*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"c*/c*.pem\" fixed der") << QString("c*/c*.pem") << int(QRegExp::FixedString) << false << 0; QTest::newRow("\"c*/c*.pem\" regexp pem") << QString("c*/c*.pem") << int(QRegExp::RegExp) << true << 0; QTest::newRow("\"c*/c*.pem\" regexp der") << QString("c*/c*.pem") << int(QRegExp::RegExp) << false << 0; - QTest::newRow("\"c*/c*.pem\" wildcard pem") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("\"c*/c*.pem\" wildcard pem") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << true << 5; QTest::newRow("\"c*/c*.pem\" wildcard der") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"d*/c*.pem\" fixed pem") << QString("d*/c*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"d*/c*.pem\" fixed der") << QString("d*/c*.pem") << int(QRegExp::FixedString) << false << 0; @@ -535,7 +557,7 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"d*/c*.pem\" wildcard der") << QString("d*/c*.pem") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"c.*/c.*.pem\" fixed pem") << QString("c.*/c.*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"c.*/c.*.pem\" fixed der") << QString("c.*/c.*.pem") << int(QRegExp::FixedString) << false << 0; - QTest::newRow("\"c.*/c.*.pem\" regexp pem") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << true << 4; + QTest::newRow("\"c.*/c.*.pem\" regexp pem") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << true << 5; QTest::newRow("\"c.*/c.*.pem\" regexp der") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << false << 0; QTest::newRow("\"c.*/c.*.pem\" wildcard pem") << QString("c.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0; QTest::newRow("\"c.*/c.*.pem\" wildcard der") << QString("c.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0; @@ -546,7 +568,7 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0; QTest::newRow("\"d.*/c.*.pem\" wildcard der") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0; #ifdef Q_OS_LINUX - QTest::newRow("absolute path wildcard pem") << QString(QDir::currentPath() + "/certificates/*.pem") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("absolute path wildcard pem") << QString(QDir::currentPath() + "/certificates/*.pem") << int(QRegExp::Wildcard) << true << 5; #endif QTest::newRow("trailing-whitespace") << QString("more-certificates/trailing-whitespace.pem") << int(QRegExp::FixedString) << true << 1; @@ -769,7 +791,7 @@ void tst_QSslCertificate::nulInCN() QString cn = cert.subjectInfo(QSslCertificate::CommonName); QVERIFY(cn != "www.bank.com"); - static const char realCN[] = "www.bank.com\\x00.badguy.com"; + static const char realCN[] = "www.bank.com\0.badguy.com"; QCOMPARE(cn, QString::fromLatin1(realCN, sizeof realCN - 1)); } From 6c72eb845657b670af5435ef8084ae91e5dfbbdd Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 24 May 2011 10:29:01 +0200 Subject: [PATCH 04/59] fix Symbian ordinals for merge request re. utf8 characters in SSL certs Task-number: QTBUG-7912 (cherry picked from commit 83c37059df7f23be482d4ecb2c54603a3665a33d) --- src/network/ssl/qsslsocket_openssl_symbols.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 6cb4794559c..a940fcde517 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -522,6 +522,7 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(ASN1_INTEGER_get, 48, libs.second ) RESOLVEFUNC(ASN1_STRING_data, 71, libs.second ) RESOLVEFUNC(ASN1_STRING_length, 76, libs.second ) + RESOLVEFUNC(ASN1_STRING_to_UTF8, 86, libs.second ) RESOLVEFUNC(BIO_ctrl, 184, libs.second ) RESOLVEFUNC(BIO_free, 209, libs.second ) RESOLVEFUNC(BIO_new, 222, libs.second ) @@ -612,7 +613,10 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(SSLv23_server_method, 191, libs.first ) RESOLVEFUNC(TLSv1_server_method, 200, libs.first ) RESOLVEFUNC(SSL_CTX_load_verify_locations, 34, libs.first ) - RESOLVEFUNC(X509_NAME_oneline, 1830, libs.second ) + RESOLVEFUNC(X509_NAME_entry_count, 1821, libs.second ) + RESOLVEFUNC(X509_NAME_get_entry, 1823, libs.second ) + RESOLVEFUNC(X509_NAME_ENTRY_get_data, 1808, libs.second ) + RESOLVEFUNC(X509_NAME_ENTRY_get_object, 1809, libs.second ) RESOLVEFUNC(X509_PUBKEY_get, 1844, libs.second ) RESOLVEFUNC(X509_STORE_free, 1939, libs.second ) RESOLVEFUNC(X509_STORE_new, 1942, libs.second ) From 093a92fb03e7c163882d1ba5fbdaf9fabb5bd969 Mon Sep 17 00:00:00 2001 From: Robert Hogan Date: Tue, 24 May 2011 11:04:27 +0200 Subject: [PATCH 05/59] Add QUrl::topLevelDomain() and move TLD table from QtNetwork to QtCore Move Qt's copy of the Mozilla public suffix list from QtNetwork to QtCore and use it to expose a new API function QUrl::topLevelDomain(). This function returns the section of the url that is a registrar-controlled top level domain. QtCore now exports a couple of functions to the other Qt modules: qTopLevelDomain, a helper function for QUrl::topLevelDomain(); and qIsEffectiveTLD(), a helper function for QNetworkCookeieJar. The motivation for this new API is to allow QtWebKit implement a Third-Party Cookie blocking policy. For this QtWebKit needs to know the element of the url that is the registry-controlled TLD. Without this knowledge it would end up blocking third-party cookies per host rather than per registry-controlled domain. See also https://bugs.webkit.org/show_bug.cgi?id=45455 Merge-request: 1205 Task-number: QTBUG-13601 Reviewed-by: Peter Hartmann (cherry picked from commit 154402f56dcf8303a6ce601a52215226af8d31ba) --- src/corelib/io/io.pri | 3 + src/corelib/io/qtldurl.cpp | 117 ++++++++++++++++++ src/corelib/io/qtldurl_p.h | 66 ++++++++++ src/corelib/io/qurl.cpp | 19 ++- src/corelib/io/qurl.h | 3 + .../io/qurltlds_p.h} | 10 +- .../io/qurltlds_p.h.INFO} | 0 src/network/access/access.pri | 1 - src/network/access/qnetworkcookiejar.cpp | 43 +------ src/network/access/qnetworkcookiejar_p.h | 3 - .../tst_qnetworkcookiejar.cpp | 4 +- tests/auto/qurl/tst_qurl.cpp | 26 ++++ .../qurl-generateTLDs}/main.cpp | 4 +- .../qurl-generateTLDs/qurl-generateTLDs.pro} | 0 14 files changed, 244 insertions(+), 55 deletions(-) create mode 100644 src/corelib/io/qtldurl.cpp create mode 100644 src/corelib/io/qtldurl_p.h rename src/{network/access/qnetworkcookiejartlds_p.h => corelib/io/qurltlds_p.h} (99%) rename src/{network/access/qnetworkcookiejartlds_p.h.INFO => corelib/io/qurltlds_p.h.INFO} (100%) rename util/{network/cookiejar-generateTLDs => corelib/qurl-generateTLDs}/main.cpp (97%) rename util/{network/cookiejar-generateTLDs/cookiejar-generateTLDs.pro => corelib/qurl-generateTLDs/qurl-generateTLDs.pro} (100%) diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index f67600d7509..e411f8f643d 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -24,6 +24,8 @@ HEADERS += \ io/qresource_p.h \ io/qresource_iterator_p.h \ io/qurl.h \ + io/qurltlds_p.h \ + io/qtldurl_p.h \ io/qsettings.h \ io/qsettings_p.h \ io/qfsfileengine.h \ @@ -41,6 +43,7 @@ SOURCES += \ io/qbuffer.cpp \ io/qdatastream.cpp \ io/qdataurl.cpp \ + io/qtldurl.cpp \ io/qdebug.cpp \ io/qdir.cpp \ io/qdiriterator.cpp \ diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp new file mode 100644 index 00000000000..7db4bbddd5a --- /dev/null +++ b/src/corelib/io/qtldurl.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatformdefs.h" +#include "qurl.h" +#include "private/qurltlds_p.h" +#include "private/qtldurl_p.h" +#include "QtCore/qstringlist.h" + +QT_BEGIN_NAMESPACE + +static bool containsTLDEntry(const QString &entry) +{ + int index = qHash(entry) % tldCount; + int currentDomainIndex = tldIndices[index]; + while (currentDomainIndex < tldIndices[index+1]) { + QString currentEntry = QString::fromUtf8(tldData + currentDomainIndex); + if (currentEntry == entry) + return true; + currentDomainIndex += qstrlen(tldData + currentDomainIndex) + 1; // +1 for the ending \0 + } + return false; +} + +/*! + \internal + + Return the top-level-domain per Qt's copy of the Mozilla public suffix list of + \a domain. +*/ + +Q_CORE_EXPORT QString qTopLevelDomain(const QString &domain) +{ + QStringList sections = domain.toLower().split(QLatin1Char('.'), QString::SkipEmptyParts); + if (sections.isEmpty()) + return QString(); + + QString level, tld; + for (int j = sections.count() - 1; j >= 0; --j) { + level.prepend(QLatin1Char('.') + sections.at(j)); + if (qIsEffectiveTLD(level.right(level.size() - 1))) + tld = level; + } + return tld; +} + +/*! + \internal + + Return true if \a domain is a top-level-domain per Qt's copy of the Mozilla public suffix list. +*/ + +Q_CORE_EXPORT bool qIsEffectiveTLD(const QString &domain) +{ + // for domain 'foo.bar.com': + // 1. return if TLD table contains 'foo.bar.com' + if (containsTLDEntry(domain)) + return true; + + if (domain.contains(QLatin1Char('.'))) { + int count = domain.size() - domain.indexOf(QLatin1Char('.')); + QString wildCardDomain; + wildCardDomain.reserve(count + 1); + wildCardDomain.append(QLatin1Char('*')); + wildCardDomain.append(domain.right(count)); + // 2. if table contains '*.bar.com', + // test if table contains '!foo.bar.com' + if (containsTLDEntry(wildCardDomain)) { + QString exceptionDomain; + exceptionDomain.reserve(domain.size() + 1); + exceptionDomain.append(QLatin1Char('!')); + exceptionDomain.append(domain); + return (! containsTLDEntry(exceptionDomain)); + } + } + return false; +} + +QT_END_NAMESPACE diff --git a/src/corelib/io/qtldurl_p.h b/src/corelib/io/qtldurl_p.h new file mode 100644 index 00000000000..152ffa0f635 --- /dev/null +++ b/src/corelib/io/qtldurl_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTLDURL_P_H +#define QTLDURL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qDecodeDataUrl. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtCore/qurl.h" +#include "QtCore/qstring.h" + +QT_BEGIN_NAMESPACE + +Q_CORE_EXPORT QString qTopLevelDomain(const QString &domain); +Q_CORE_EXPORT bool qIsEffectiveTLD(const QString &domain); + +QT_END_NAMESPACE + +#endif // QDATAURL_P_H diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index efd3f45ef02..c433d3519ce 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -192,7 +192,9 @@ #if defined QT3_SUPPORT #include "qfileinfo.h" #endif - +#ifndef QT_BOOTSTRAPPED +#include "qtldurl_p.h" +#endif #if defined(Q_OS_WINCE_WM) #pragma optimize("g", off) #endif @@ -5592,6 +5594,21 @@ bool QUrl::hasFragment() const return d->hasFragment; } +/*! + \since 4.8 + + Returns the TLD (Top-Level Domain) of the URL, (e.g. .co.uk, .net). + Note that the return value is prefixed with a '.' unless the + URL does not contain a valid TLD, in which case the function returns + an empty string. +*/ +#ifndef QT_BOOTSTRAPPED +QString QUrl::topLevelDomain() const +{ + return qTopLevelDomain(host()); +} +#endif + /*! Returns the result of the merge of this URL with \a relative. This URL is used as a base to convert \a relative to an absolute URL. diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 7534b8d4746..07b0b4e68da 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -181,6 +181,9 @@ public: void setEncodedFragment(const QByteArray &fragment); QByteArray encodedFragment() const; bool hasFragment() const; +#ifndef QT_BOOTSTRAPPED + QString topLevelDomain() const; +#endif QUrl resolved(const QUrl &relative) const; diff --git a/src/network/access/qnetworkcookiejartlds_p.h b/src/corelib/io/qurltlds_p.h similarity index 99% rename from src/network/access/qnetworkcookiejartlds_p.h rename to src/corelib/io/qurltlds_p.h index b06d881131b..f4f525ced77 100644 --- a/src/network/access/qnetworkcookiejartlds_p.h +++ b/src/corelib/io/qurltlds_p.h @@ -38,15 +38,15 @@ // the terms of any one of the MPL, the GPL or the LGPL. // -#ifndef QNETWORKCOOKIEJARTLD_P_H -#define QNETWORKCOOKIEJARTLD_P_H +#ifndef QURLTLD_P_H +#define QURLTLD_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of the Network Access framework. This header file may change from +// of the Network Access and Core framework. This header file may change from // version to version without notice, or even be removed. // // We mean it. @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE // note to maintainer: // this file should be updated before each release -> // for instructions see the program at -// util/network/cookiejar-generateTLDs +// util/corelib/qurl-generateTLDs static const quint16 tldCount = 3949; static const quint16 tldIndices[] = { @@ -6478,4 +6478,4 @@ static const char tldData[] = { QT_END_NAMESPACE -#endif // QNETWORKCOOKIEJARTLD_P_H +#endif // QURLTLD_P_H diff --git a/src/network/access/qnetworkcookiejartlds_p.h.INFO b/src/corelib/io/qurltlds_p.h.INFO similarity index 100% rename from src/network/access/qnetworkcookiejartlds_p.h.INFO rename to src/corelib/io/qurltlds_p.h.INFO diff --git a/src/network/access/access.pri b/src/network/access/access.pri index 0f901b873d9..3d5558d3343 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -21,7 +21,6 @@ HEADERS += \ access/qnetworkcookie_p.h \ access/qnetworkcookiejar.h \ access/qnetworkcookiejar_p.h \ - access/qnetworkcookiejartlds_p.h \ access/qnetworkrequest.h \ access/qnetworkrequest_p.h \ access/qnetworkreply.h \ diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index 53fab9f0c4f..f2b17140024 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -40,12 +40,12 @@ ****************************************************************************/ #include "qnetworkcookiejar.h" -#include "qnetworkcookiejartlds_p.h" #include "qnetworkcookiejar_p.h" #include "QtNetwork/qnetworkcookie.h" #include "QtCore/qurl.h" #include "QtCore/qdatetime.h" +#include "private/qtldurl_p.h" QT_BEGIN_NAMESPACE @@ -216,7 +216,7 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList &cookieLis // the check for effective TLDs makes the "embedded dot" rule from RFC 2109 section 4.3.2 // redundant; the "leading dot" rule has been relaxed anyway, see above // we remove the leading dot for this check - if (QNetworkCookieJarPrivate::isEffectiveTLD(domain.remove(0, 1))) + if (qIsEffectiveTLD(domain.remove(0, 1))) continue; // not accepted } @@ -304,43 +304,4 @@ QList QNetworkCookieJar::cookiesForUrl(const QUrl &url) const return result; } -bool QNetworkCookieJarPrivate::isEffectiveTLD(const QString &domain) -{ - // for domain 'foo.bar.com': - // 1. return if TLD table contains 'foo.bar.com' - if (containsTLDEntry(domain)) - return true; - - if (domain.contains(QLatin1Char('.'))) { - int count = domain.size() - domain.indexOf(QLatin1Char('.')); - QString wildCardDomain; - wildCardDomain.reserve(count + 1); - wildCardDomain.append(QLatin1Char('*')); - wildCardDomain.append(domain.right(count)); - // 2. if table contains '*.bar.com', - // test if table contains '!foo.bar.com' - if (containsTLDEntry(wildCardDomain)) { - QString exceptionDomain; - exceptionDomain.reserve(domain.size() + 1); - exceptionDomain.append(QLatin1Char('!')); - exceptionDomain.append(domain); - return (! containsTLDEntry(exceptionDomain)); - } - } - return false; -} - -bool QNetworkCookieJarPrivate::containsTLDEntry(const QString &entry) -{ - int index = qHash(entry) % tldCount; - int currentDomainIndex = tldIndices[index]; - while (currentDomainIndex < tldIndices[index+1]) { - QString currentEntry = QString::fromUtf8(tldData + currentDomainIndex); - if (currentEntry == entry) - return true; - currentDomainIndex += qstrlen(tldData + currentDomainIndex) + 1; // +1 for the ending \0 - } - return false; -} - QT_END_NAMESPACE diff --git a/src/network/access/qnetworkcookiejar_p.h b/src/network/access/qnetworkcookiejar_p.h index d6dc45057c2..ce5a87a98c8 100644 --- a/src/network/access/qnetworkcookiejar_p.h +++ b/src/network/access/qnetworkcookiejar_p.h @@ -63,9 +63,6 @@ class QNetworkCookieJarPrivate: public QObjectPrivate public: QList allCookies; - static bool Q_AUTOTEST_EXPORT isEffectiveTLD(const QString &domain); - static bool containsTLDEntry(const QString &entry); - Q_DECLARE_PUBLIC(QNetworkCookieJar) }; diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 178f6d8a640..1f7c2693df4 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -42,7 +42,7 @@ #include #include -#include "private/qnetworkcookiejar_p.h" +#include "private/qtldurl_p.h" class tst_QNetworkCookieJar: public QObject { @@ -438,7 +438,7 @@ void tst_QNetworkCookieJar::effectiveTLDs() #endif QFETCH(QString, domain); QFETCH(bool, isTLD); - QCOMPARE(QNetworkCookieJarPrivate::isEffectiveTLD(domain), isTLD); + QCOMPARE(qIsEffectiveTLD(domain), isTLD); } QTEST_MAIN(tst_QNetworkCookieJar) diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 336ee365844..85aae1fd6e3 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -49,6 +49,7 @@ #include #include #include +#include "private/qtldurl_p.h" // For testsuites #define IDNA_ACE_PREFIX "xn--" @@ -88,6 +89,8 @@ public slots: void init(); void cleanup(); private slots: + void effectiveTLDs_data(); + void effectiveTLDs(); void getSetCheck(); void constructing(); void assignment(); @@ -4005,5 +4008,28 @@ void tst_QUrl::taskQTBUG_8701() QCOMPARE(foo_uni_bar, QUrl(foo_uni_bar, QUrl::StrictMode).toString()); } +void tst_QUrl::effectiveTLDs_data() +{ + QTest::addColumn("domain"); + QTest::addColumn("TLD"); + + QTest::newRow("yes0") << QUrl::fromEncoded("http://test.co.uk") << ".co.uk"; + QTest::newRow("yes1") << QUrl::fromEncoded("http://test.com") << ".com"; + QTest::newRow("yes2") << QUrl::fromEncoded("http://www.test.de") << ".de"; + QTest::newRow("yes3") << QUrl::fromEncoded("http://test.ulm.museum") << ".ulm.museum"; + QTest::newRow("yes4") << QUrl::fromEncoded("http://www.com.krodsherad.no") << ".krodsherad.no"; + QTest::newRow("yes5") << QUrl::fromEncoded("http://www.co.uk.1.bg") << ".1.bg"; + QTest::newRow("yes6") << QUrl::fromEncoded("http://www.com.com.cn") << ".com.cn"; + QTest::newRow("yes7") << QUrl::fromEncoded("http://www.test.org.ws") << ".org.ws"; + QTest::newRow("yes9") << QUrl::fromEncoded("http://www.com.co.uk.wallonie.museum") << ".wallonie.museum"; +} + +void tst_QUrl::effectiveTLDs() +{ + QFETCH(QUrl, domain); + QFETCH(QString, TLD); + QCOMPARE(domain.topLevelDomain(), TLD); +} + QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" diff --git a/util/network/cookiejar-generateTLDs/main.cpp b/util/corelib/qurl-generateTLDs/main.cpp similarity index 97% rename from util/network/cookiejar-generateTLDs/main.cpp rename to util/corelib/qurl-generateTLDs/main.cpp index 5cdc97cd0c0..baaf25632cf 100644 --- a/util/network/cookiejar-generateTLDs/main.cpp +++ b/util/corelib/qurl-generateTLDs/main.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) { printf(" wget http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1 -O effective_tld_names.dat\n"); printf(" grep '^[^\\/\\/]' effective_tld_names.dat > effective_tld_names.dat.trimmed\n"); printf(" %s effective_tld_names.dat.trimmed effective_tld_names.dat.qt\n\n", argv[0]); - printf("Now copy the data from effective_tld_names.dat.qt to the file src/network/access/qnetworkcookiejartlds_p.h in your Qt repo\n\n"); + printf("Now copy the data from effective_tld_names.dat.qt to the file src/corelib/io/qurltlds_p.h in your Qt repo\n\n"); exit(1); } QFile file(argv[1]); @@ -156,6 +156,6 @@ int main(int argc, char **argv) { outFile.write(outDataBufferBA); outFile.write("};\n"); outFile.close(); - printf("data generated to %s . Now copy the data from this file to src/network/access/qnetworkcookiejartlds_p.h in your Qt repo\n", argv[2]); + printf("data generated to %s . Now copy the data from this file to src/corelib/io/qurltlds_p.h in your Qt repo\n", argv[2]); exit(0); } diff --git a/util/network/cookiejar-generateTLDs/cookiejar-generateTLDs.pro b/util/corelib/qurl-generateTLDs/qurl-generateTLDs.pro similarity index 100% rename from util/network/cookiejar-generateTLDs/cookiejar-generateTLDs.pro rename to util/corelib/qurl-generateTLDs/qurl-generateTLDs.pro From e63026dcbd8499ea80739be3c3ae6c0c91429b9e Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 24 May 2011 12:05:10 +0200 Subject: [PATCH 06/59] QUrl TLD: fix documentation file for "Add QUrl::topLevelDomain() ..." see previous commit Task-number: QTBUG-13601 (cherry picked from commit 9face4b88de2db6f552149d2f96257620e971a59) --- src/corelib/io/qurltlds_p.h.INFO | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qurltlds_p.h.INFO b/src/corelib/io/qurltlds_p.h.INFO index 57a8d0e0cc7..5781c2c6784 100644 --- a/src/corelib/io/qurltlds_p.h.INFO +++ b/src/corelib/io/qurltlds_p.h.INFO @@ -1,15 +1,15 @@ -The file qnetworkcookiejartlds_p.h is generated from the Public Suffix +The file qurltlds_p.h is generated from the Public Suffix List (see [1] and [2]), by the program residing at -util/network/cookiejar-generateTLDs in the Qt source tree. +util/corelib/qurl-generateTLDs in the Qt source tree. That program generates a character array and an index array from the list to provide fast lookups of elements within C++. -Those arrays in qnetworkcookiejartlds_p.h are derived from the Public +Those arrays in qurltlds_p.h are derived from the Public Suffix List ([2]), which was originally provided by Jo Hermans . -The file qnetworkcookiejartlds_p.h was last generated Friday, +The file qurltlds_p.h was last generated Friday, November 19th 15:24 2010. ---- From eb44ca51f19a2218cfef3481429eb571e1fc46e5 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 24 May 2011 13:34:03 +0200 Subject: [PATCH 07/59] QUrl auto test: include core-private headers ... for the newly introduced TLD test. Task-number: QTBUG-13601 --- tests/auto/qurl/qurl.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qurl/qurl.pro b/tests/auto/qurl/qurl.pro index a5c39a5a98a..a43a57e002c 100644 --- a/tests/auto/qurl/qurl.pro +++ b/tests/auto/qurl/qurl.pro @@ -1,5 +1,5 @@ load(qttest_p4) SOURCES += tst_qurl.cpp -QT = core +QT = core core-private symbian: TARGET.CAPABILITY = NetworkServices CONFIG += parallel_test From 4d10065c54f9b277f44ed042f4e18858dafdd1df Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 28 Apr 2011 19:04:16 +0200 Subject: [PATCH 08/59] Fixed line endings. Conflicts: examples/widgets/applicationicon/applicationicon.svg examples/widgets/applicationicon/main.cpp examples/widgets/elidedlabel/elidedlabel.cpp examples/widgets/elidedlabel/elidedlabel.h examples/widgets/elidedlabel/main.cpp examples/widgets/elidedlabel/testwidget.cpp examples/widgets/elidedlabel/testwidget.h (cherry picked from commit 1b555a91f05b68c697b6985d1b672dc0fba5fc5a) (cherry picked from commit c0e0bfdd451f42b10051e8064153b811080ffa0e) --- .../applicationicon/applicationicon.svg | 22 ++++ examples/widgets/applicationicon/main.cpp | 14 ++ examples/widgets/elidedlabel/elidedlabel.cpp | 71 ++++++++++ examples/widgets/elidedlabel/elidedlabel.h | 36 +++++ examples/widgets/elidedlabel/main.cpp | 13 ++ examples/widgets/elidedlabel/testwidget.cpp | 124 ++++++++++++++++++ examples/widgets/elidedlabel/testwidget.h | 36 +++++ 7 files changed, 316 insertions(+) create mode 100644 examples/widgets/applicationicon/applicationicon.svg create mode 100644 examples/widgets/applicationicon/main.cpp create mode 100644 examples/widgets/elidedlabel/elidedlabel.cpp create mode 100644 examples/widgets/elidedlabel/elidedlabel.h create mode 100644 examples/widgets/elidedlabel/main.cpp create mode 100644 examples/widgets/elidedlabel/testwidget.cpp create mode 100644 examples/widgets/elidedlabel/testwidget.h diff --git a/examples/widgets/applicationicon/applicationicon.svg b/examples/widgets/applicationicon/applicationicon.svg new file mode 100644 index 00000000000..aa2835b08fd --- /dev/null +++ b/examples/widgets/applicationicon/applicationicon.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/widgets/applicationicon/main.cpp b/examples/widgets/applicationicon/main.cpp new file mode 100644 index 00000000000..099bdac2180 --- /dev/null +++ b/examples/widgets/applicationicon/main.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QLabel label(QObject::tr("Hello, world!")); +#if defined(Q_WS_S60) + label.showMaximized(); +#else + label.show(); +#endif + return a.exec(); +} diff --git a/examples/widgets/elidedlabel/elidedlabel.cpp b/examples/widgets/elidedlabel/elidedlabel.cpp new file mode 100644 index 00000000000..4f3ac5e8434 --- /dev/null +++ b/examples/widgets/elidedlabel/elidedlabel.cpp @@ -0,0 +1,71 @@ +#include "elidedlabel.h" + +#include +#include +#include + +//! [0] +ElidedLabel::ElidedLabel(const QString &text, QWidget *parent) + : QFrame(parent) + , elided(false) + , content(text) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); +} +//! [0] + +//! [1] +void ElidedLabel::setText(const QString &newText) +{ + content = newText; + update(); +} +//! [1] + +//! [2] +void ElidedLabel::paintEvent(QPaintEvent *event) +{ + QFrame::paintEvent(event); + + QPainter painter(this); + QFontMetrics fontMetrics = painter.fontMetrics(); + + bool didElide = false; + int lineSpacing = fontMetrics.lineSpacing(); + int y = 0; + + QTextLayout textLayout(content, painter.font()); + textLayout.beginLayout(); + forever { + QTextLine line = textLayout.createLine(); + + if (!line.isValid()) + break; + + line.setLineWidth(width()); + int nextLineY = y + lineSpacing; + + if (height() >= nextLineY + lineSpacing) { + line.draw(&painter, QPoint(0, y)); + y = nextLineY; + //! [2] + //! [3] + } else { + QString lastLine = content.mid(line.textStart()); + QString elidedLastLine = fontMetrics.elidedText(lastLine, Qt::ElideRight, width()); + painter.drawText(QPoint(0, y + fontMetrics.ascent()), elidedLastLine); + line = textLayout.createLine(); + didElide = line.isValid(); + break; + } + } + textLayout.endLayout(); + //! [3] + + //! [4] + if (didElide != elided) { + elided = didElide; + emit elisionChanged(didElide); + } +} +//! [4] diff --git a/examples/widgets/elidedlabel/elidedlabel.h b/examples/widgets/elidedlabel/elidedlabel.h new file mode 100644 index 00000000000..b68f6052482 --- /dev/null +++ b/examples/widgets/elidedlabel/elidedlabel.h @@ -0,0 +1,36 @@ +#ifndef ELIDEDLABEL_H +#define ELIDEDLABEL_H + +#include +#include +#include +#include +#include + +//! [0] +class ElidedLabel : public QFrame +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(bool isElided READ isElided) + +public: + ElidedLabel(const QString &text, QWidget *parent = 0); + + void setText(const QString &text); + const QString & text() const { return content; } + bool isElided() const { return elided; } + +protected: + void paintEvent(QPaintEvent *event); + +signals: + void elisionChanged(bool elided); + +private: + bool elided; + QString content; +}; +//! [0] + +#endif // TEXTWRAPPINGWIDGET_H diff --git a/examples/widgets/elidedlabel/main.cpp b/examples/widgets/elidedlabel/main.cpp new file mode 100644 index 00000000000..1346d25e246 --- /dev/null +++ b/examples/widgets/elidedlabel/main.cpp @@ -0,0 +1,13 @@ +#include "testwidget.h" + +#include + +//! [0] +int main( int argc, char *argv[] ) +{ + QApplication application( argc, argv ); + TestWidget w; + w.showFullScreen(); + return application.exec(); +} +//! [0] diff --git a/examples/widgets/elidedlabel/testwidget.cpp b/examples/widgets/elidedlabel/testwidget.cpp new file mode 100644 index 00000000000..d3bf5218324 --- /dev/null +++ b/examples/widgets/elidedlabel/testwidget.cpp @@ -0,0 +1,124 @@ +#include "testwidget.h" +#include "elidedlabel.h" + +#include +#include +#include +#include + +//! [0] +TestWidget::TestWidget(QWidget *parent): + QWidget(parent) +{ + const QString romeo = tr( + "But soft, what light through yonder window breaks? / " + "It is the east, and Juliet is the sun. / " + "Arise, fair sun, and kill the envious moon, / " + "Who is already sick and pale with grief / " + "That thou, her maid, art far more fair than she." + ); + + const QString macbeth = tr( + "To-morrow, and to-morrow, and to-morrow, / " + "Creeps in this petty pace from day to day, / " + "To the last syllable of recorded time; / " + "And all our yesterdays have lighted fools / " + "The way to dusty death. Out, out, brief candle! / " + "Life's but a walking shadow, a poor player, / " + "That struts and frets his hour upon the stage, / " + "And then is heard no more. It is a tale / " + "Told by an idiot, full of sound and fury, / " + "Signifying nothing." + ); + + const QString harry = tr("Feeling lucky, punk?"); + + textSamples << romeo << macbeth << harry; + //! [0] + + //! [1] + sampleIndex = 0; + elidedText = new ElidedLabel(textSamples[sampleIndex], this); + elidedText->setFrameStyle(QFrame::Box); + //! [1] + + //! [2] + QPushButton *switchButton = new QPushButton(tr("Switch text")); + connect(switchButton, SIGNAL(clicked(bool)), this, SLOT(switchText())); + + QPushButton *exitButton = new QPushButton(tr("Exit")); + connect(exitButton, SIGNAL(clicked(bool)), this, SLOT(close())); + + QLabel *label = new QLabel(tr("Elided")); + label->setVisible(elidedText->isElided()); + connect(elidedText, SIGNAL(elisionChanged(bool)), label, SLOT(setVisible(bool))); + //! [2] + + //! [3] + widthSlider = new QSlider(Qt::Horizontal); + widthSlider->setMinimum(0); + connect(widthSlider, SIGNAL(valueChanged(int)), this, SLOT(onWidthChanged(int))); + + heightSlider = new QSlider(Qt::Vertical); + heightSlider->setInvertedAppearance(true); + heightSlider->setMinimum(0); + connect(heightSlider, SIGNAL(valueChanged(int)), this, SLOT(onHeightChanged(int))); + //! [3] + + //! [4] + QGridLayout *layout = new QGridLayout(); + layout->addWidget(label, 0, 1, Qt::AlignCenter); + layout->addWidget(switchButton, 0, 2); + layout->addWidget(exitButton, 0, 3); + layout->addWidget(widthSlider, 1, 1, 1, 3); + layout->addWidget(heightSlider, 2, 0); + layout->addWidget(elidedText, 2, 1, 1, 3, Qt::AlignTop | Qt::AlignLeft); + + setLayout(layout); + //! [4] + + //! [5] +#ifdef Q_WS_MAEMO_5 + setAttribute(Qt::WA_Maemo5AutoOrientation, true); +#endif +} +//! [5] + +//! [6] +void TestWidget::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event) + + int maxWidth = widthSlider->width(); + widthSlider->setMaximum(maxWidth); + widthSlider->setValue(maxWidth / 2); + + int maxHeight = heightSlider->height(); + heightSlider->setMaximum(maxHeight); + heightSlider->setValue(maxHeight / 2); + + elidedText->setFixedSize(widthSlider->value(), heightSlider->value()); +} +//! [6] + +//! [7] +void TestWidget::switchText() +{ + sampleIndex = (sampleIndex + 1) % textSamples.size(); + elidedText->setText(textSamples.at(sampleIndex)); +} +//! [7] + +//! [8] +void TestWidget::onWidthChanged(int width) +{ + elidedText->setFixedWidth(width); +} + +void TestWidget::onHeightChanged(int height) +{ + elidedText->setFixedHeight(height); +} +//! [8] + + diff --git a/examples/widgets/elidedlabel/testwidget.h b/examples/widgets/elidedlabel/testwidget.h new file mode 100644 index 00000000000..ed4de951075 --- /dev/null +++ b/examples/widgets/elidedlabel/testwidget.h @@ -0,0 +1,36 @@ +#ifndef TESTWIDGET_H +#define TESTWIDGET_H + +#include +#include +#include +#include + +class ElidedLabel; + +//! [0] +class TestWidget : public QWidget +{ + Q_OBJECT + +public: + TestWidget(QWidget *parent = 0); + +protected: + void resizeEvent(QResizeEvent *event); + +private slots: + void switchText(); + void onWidthChanged(int width); + void onHeightChanged(int height); + +private: + int sampleIndex; + QStringList textSamples; + ElidedLabel *elidedText; + QSlider *heightSlider; + QSlider *widthSlider; +}; +//! [0] + +#endif // TESTWIDGET_H From b4b100fb8f42e2368196135b129af1906cffa6fa Mon Sep 17 00:00:00 2001 From: Lincoln Ramsay Date: Wed, 25 May 2011 12:40:25 +1000 Subject: [PATCH 09/59] Fix -nomake tests. It now means "don't run qmake", not just "don't build". This is consistent with -nomake demos and -nomake examples Reviewed-by: Rohan Mcgovern --- qtbase.pro | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qtbase.pro b/qtbase.pro index 375308a5cc4..9b140025bb2 100644 --- a/qtbase.pro +++ b/qtbase.pro @@ -10,7 +10,7 @@ cross_compile: CONFIG += nostrip module_qtbase_tests.subdir = tests module_qtbase_tests.target = module-qtbase-tests module_qtbase_tests.depends = module_qtbase_src -module_qtbase_tests.CONFIG = no_default_target no_default_install +module_qtbase_tests.CONFIG = no_default_install #process the projects for(PROJECT, $$list($$lower($$unique(QT_BUILD_PARTS)))) { @@ -19,7 +19,7 @@ for(PROJECT, $$list($$lower($$unique(QT_BUILD_PARTS)))) { } else:isEqual(PROJECT, demos) { SUBDIRS += demos } else:isEqual(PROJECT, tests) { - module_qtbase_tests.CONFIG -= no_default_target + SUBDIRS += module_qtbase_tests } else:isEqual(PROJECT, libs) { include(src/src.pro) } else:isEqual(PROJECT, qmake) { @@ -29,8 +29,6 @@ for(PROJECT, $$list($$lower($$unique(QT_BUILD_PARTS)))) { } } -SUBDIRS += module_qtbase_tests - !symbian: confclean.depends += clean confclean.commands = unix:!symbian { From 0056cc0ced64c842d94cefb9e4d0d101f4106706 Mon Sep 17 00:00:00 2001 From: Lincoln Ramsay Date: Wed, 25 May 2011 15:55:53 +1000 Subject: [PATCH 10/59] Do not continue if syncqt fails. If the user has set QTDIR to something other than the location of the qtbase build directory, syncqt will fail. This change prevents the build from continuing. Ideally, the system should ignore the user-set QTDIR value or give an appropriate error. Reviewed-by: Rohan McGovern --- mkspecs/features/default_pre.prf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/default_pre.prf b/mkspecs/features/default_pre.prf index adcdbb73e92..d451d29f7cf 100644 --- a/mkspecs/features/default_pre.prf +++ b/mkspecs/features/default_pre.prf @@ -26,7 +26,11 @@ exists($$_PRO_FILE_PWD_/sync.profile) { message("Running syncqt for $$PRO_BASENAME in $$OUT_PWD") qtPrepareTool(QMAKE_SYNCQT, syncqt) - system("$$QMAKE_SYNCQT $$QTFWD -outdir $$OUT_PWD $$_PRO_FILE_PWD_") + system("$$QMAKE_SYNCQT $$QTFWD -outdir $$OUT_PWD $$_PRO_FILE_PWD_") { + # success! Nothing to do + } else { + error("Failed to run: $$QMAKE_SYNCQT $$QTFWD -outdir $$OUT_PWD $$_PRO_FILE_PWD_") + } unset(QTFWD) unset(PRO_BASENAME) } From 1be4b50bacda6301f64f62e796562a91f03bc199 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Wed, 25 May 2011 09:08:09 +0200 Subject: [PATCH 11/59] Compile. Change 0748751c brought in an extra copy of this function. --- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index e2539aaaf16..f5a93d98d26 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -199,19 +199,6 @@ QT_END_NAMESPACE [super setInitialFirstResponder:view]; } -- (void)setInitialFirstResponder:(NSView *)view -{ - // This method is called the first time the window is placed on screen and - // is the earliest point in time we can connect OpenGL contexts to NSViews. - QWidget *qwidget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; - if (qwidget) { - qt_event_request_window_change(qwidget); - qt_mac_send_posted_gl_updates(qwidget); - } - - [super setInitialFirstResponder:view]; -} - - (BOOL)makeFirstResponder:(NSResponder *)responder { // For some reason Cocoa wants to flip the first responder From ef913833245f8401b9652a4f58bbb26735526180 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 25 May 2011 14:29:28 +0200 Subject: [PATCH 12/59] Doc: Fixing typo Change-Id: Icd73646a9562af5fd6ae56e36ca268719d32471c Reviewed-on: http://codereview.qt.nokia.com/112 Reviewed-by: Sergio Ahumada --- src/corelib/global/qnamespace.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 9f59c6e8e9b..09611e67f44 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1121,7 +1121,7 @@ \value WA_X11NetWmWindowTypeToolBar Adds _NET_WM_WINDOW_TYPE_TOOLBAR to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automaticaly sets this + has no effect on non-X11 platforms. \note Qt automatically sets this attribute for QToolBar. \value WA_X11NetWmWindowTypeMenu Adds _NET_WM_WINDOW_TYPE_MENU to the @@ -2593,7 +2593,7 @@ \value ImhFormattedNumbersOnly Only number input is allowed. This includes decimal point and minus sign. \value ImhUppercaseOnly Only upper case letter input is allowed. \value ImhLowercaseOnly Only lower case letter input is allowed. - \value ImhDialableCharactersOnly Only characters suitable for phone dialling are allowed. + \value ImhDialableCharactersOnly Only characters suitable for phone dialing are allowed. \value ImhEmailCharactersOnly Only characters suitable for email addresses are allowed. \value ImhUrlCharactersOnly Only characters suitable for URLs are allowed. From 6fe12b0e80b95775b1daa201ea601e537c600286 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 25 May 2011 11:21:53 +0200 Subject: [PATCH 13/59] Fix QFontEngineX11FT compilation xglyph_format is only available when XRender is present. Reviewed-by: Fabien Freling (cherry picked from commit a6642e4659b3d45ffa94f9a3c6413124d49f2b91) Change-Id: Ibd767c5055c8fb4a7d28ace141f6713f4367d1ba Reviewed-on: http://codereview.qt.nokia.com/113 Reviewed-by: Paul Olav Tvete --- src/gui/text/qfontengine_x11.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/text/qfontengine_x11.cpp b/src/gui/text/qfontengine_x11.cpp index 099704894c3..e3bfa5df461 100644 --- a/src/gui/text/qfontengine_x11.cpp +++ b/src/gui/text/qfontengine_x11.cpp @@ -1205,7 +1205,9 @@ QFontEngine *QFontEngineX11FT::cloneWithSize(qreal pixelSize) const delete fe; return 0; } else { +#ifndef QT_NO_XRENDER fe->xglyph_format = xglyph_format; +#endif return fe; } } From 1909e038823f8dff9d18882b64e637b15234f837 Mon Sep 17 00:00:00 2001 From: Lasse Holmstedt Date: Wed, 25 May 2011 11:24:37 +0200 Subject: [PATCH 14/59] Add authentication token support for wayland windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For compositors that support it, the wayland clients can associate themselves with an auth token, specified by WL_AUTHENTICATION_TOKEN env var, or by directly specifying it in the wayland client plugin. Change-Id: I74a50a27c7c61c2b2cf1e09868618f36edc94cb1 Reviewed-by: Samuel Rødal Reviewed-on: http://codereview.qt.nokia.com/116 Reviewed-by: Paul Olav Tvete --- .../platforms/wayland/qwaylanddisplay.cpp | 9 +++-- .../platforms/wayland/qwaylandwindow.cpp | 1 + .../qwaylandwindowmanager-client-protocol.h | 40 ++++++++++++++++--- .../qwaylandwindowmanagerintegration.cpp | 13 ++++-- .../qwaylandwindowmanagerintegration.h | 1 + .../wayland-windowmanager-protocol.c | 3 +- 6 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 13ee87f7963..83516e9b4e3 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -140,6 +140,11 @@ QWaylandDisplay::QWaylandDisplay(void) #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); #endif + +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT + mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this); +#endif + blockingReadEvents(); qRegisterMetaType("uint32_t"); @@ -148,10 +153,6 @@ QWaylandDisplay::QWaylandDisplay(void) mEglIntegration->initialize(); #endif -#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT - mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this); -#endif - connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); mFd = wl_display_get_fd(mDisplay, sourceUpdate, this); diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 3169b361ffb..333a953b299 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -67,6 +67,7 @@ QWaylandWindow::QWaylandWindow(QWidget *window) #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid()); + mDisplay->windowManagerIntegration()->authenticateWithToken(); #endif mSurface = mDisplay->createSurface(this); diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h index ec776c5f87c..73673aef6f5 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h @@ -36,16 +36,37 @@ struct wl_client; struct wl_windowmanager; +struct wl_proxy; + +extern void +wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...); +extern struct wl_proxy * +wl_proxy_create(struct wl_proxy *factory, + const struct wl_interface *interface); +extern struct wl_proxy * +wl_proxy_create_for_id(struct wl_display *display, + const struct wl_interface *interface, uint32_t id); +extern void +wl_proxy_destroy(struct wl_proxy *proxy); + +extern int +wl_proxy_add_listener(struct wl_proxy *proxy, + void (**implementation)(void), void *data); + +extern void +wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data); + +extern void * +wl_proxy_get_user_data(struct wl_proxy *proxy); + extern const struct wl_interface wl_windowmanager_interface; -#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0 +#define wl_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0 +#define wl_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1 static inline struct wl_windowmanager * -wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t /*version*/) +wl_windowmanager_create(struct wl_display *display, uint32_t id) { - // ### does not run without latest wayland. must be enabled later - //wl_display_bind(display, id, "wl_windowmanager", version); - return (struct wl_windowmanager *) wl_proxy_create_for_id(display, &wl_windowmanager_interface, id); } @@ -72,7 +93,14 @@ static inline void wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid) { wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, - WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid); + wl_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid); +} + +static inline void +wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *wl_authentication_token) +{ + wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, + wl_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, wl_authentication_token); } #ifdef __cplusplus diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp index bf8342308ed..4236f395cb8 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp @@ -68,12 +68,11 @@ struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const return mWaylandWindowManager; } -void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, - uint32_t version, void *data) +void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) { if (strcmp(interface, "wl_windowmanager") == 0) { QWaylandWindowManagerIntegration *integration = static_cast(data); - integration->mWaylandWindowManager = wl_windowmanager_create(display,id, version); + integration->mWaylandWindowManager = wl_windowmanager_create(display, id); } } @@ -83,3 +82,11 @@ void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId) wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId); } +void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &token) +{ + QByteArray authToken = token; + if (authToken.isEmpty()) + authToken = qgetenv("WL_AUTHENTICATION_TOKEN"); + if (mWaylandWindowManager) + wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData()); +} diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h index 01b814f22ac..0e3781dbe2a 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h @@ -56,6 +56,7 @@ public: void mapSurfaceToProcess(struct wl_surface *surface, long long processId); void mapClientToProcess(long long processId); + void authenticateWithToken(const QByteArray &token = QByteArray()); private: static void wlHandleListenerGlobal(wl_display *display, uint32_t id, diff --git a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c index 48049d8571c..0250801b1f2 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c +++ b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c @@ -26,7 +26,8 @@ #include "wayland-util.h" static const struct wl_message wl_windowmanager_requests[] = { - { "map_client_to_process", "u", NULL }, + { "map_client_to_process", "u" }, + { "authenticate_with_token", "s" }, }; WL_EXPORT const struct wl_interface wl_windowmanager_interface = { From ffc19505914e774e067217f5d7149af032312bb7 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 16 May 2011 10:20:54 +0200 Subject: [PATCH 15/59] Workaround a bug in Core Text to select Light fonts Currently in Core Text there is not proper way to select fonts with Light weight, for example: QFont font("Helvetica"); font.setWeight(QFont::Light); will give you Helvetica-Light, as with: QFont font("Helvetica"); font.setWeight(QFont::Normal); because of a bug in Core Text, applying 0 symbolic traits with CTFontCreateCopyWithSymbolicTraits will always return the Light variant of that font family. Thus, we should only do this unless symbolicTraits is not 0 or font.weight is not Normal (Light is not a symbolic trait, but CT doesn't support selecting Light weight numerically). Reviewed-by: Eskil (cherry picked from commit 4d5b8f66d82e9087d9d58a4e76e6b46ce7bb53cc) Change-Id: I37a970aba5019a13b9f3bc43b7fb594b74a1aa37 Reviewed-on: http://codereview.qt.nokia.com/124 Reviewed-by: Jiang Jiang --- src/gui/text/qfontengine_coretext.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index 24bd750e801..737edc3a8c9 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -100,7 +100,12 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const QCFString &name, const QCFType descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize); QCFType baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform); - ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits); + ctfont = NULL; + // There is a side effect in Core Text: if we apply 0 as symbolic traits to a font in normal weight, + // we will get the light version of that font (while the way supposed to work doesn't: + // setting kCTFontWeightTrait to some value between -1.0 to 0.0 has no effect on font selection) + if (fontDef.weight != QFont::Normal || symbolicTraits) + ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits); // CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does // not exist for the given font. (for example italic) From 635af8d700087b24bd8c212b14cf644e0f71a6fc Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 11 May 2011 16:56:24 +0200 Subject: [PATCH 16/59] Fix QGLWidget::renderPixmap for raster engine on Mac The QPixmap buffer is backed by QRasterPixmapData instead of QMacPixmapData for the raster engine, thus we have to update qt_mac_pixmap_get_base() and qt_mac_pixmap_get_bytes_per_line(), so that QGLWidget can locate the offscreen buffer from a QPixmap. Reviewed-by: Fabien Freling (cherry picked from commit c5846314dfd80e7f7f32ba737f1884dcccbbd80d) Change-Id: I2414222f8a59e02c778177d52ad9a6e0ff68668d Reviewed-on: http://codereview.qt.nokia.com/123 Reviewed-by: Jiang Jiang --- src/gui/image/qpixmap_mac.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 7e31f5b80b9..cb3016177dd 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -73,12 +74,18 @@ static int qt_pixmap_serial = 0; Q_GUI_EXPORT quint32 *qt_mac_pixmap_get_base(const QPixmap *pix) { - return static_cast(pix->data.data())->pixels; + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) + return reinterpret_cast(static_cast(pix->data.data())->buffer()->bits()); + else + return static_cast(pix->data.data())->pixels; } Q_GUI_EXPORT int qt_mac_pixmap_get_bytes_per_line(const QPixmap *pix) { - return static_cast(pix->data.data())->bytesPerRow; + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) + return static_cast(pix->data.data())->buffer()->bytesPerLine(); + else + return static_cast(pix->data.data())->bytesPerRow; } void qt_mac_cgimage_data_free(void *info, const void *memoryToFree, size_t) From dea9ca8b7a4166e1c3d3fc374621ad02c1220d3a Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 25 May 2011 17:03:59 +0200 Subject: [PATCH 17/59] Fix for compiling and running cube example on Windows. Change-Id: I0bf933fe81e332c03a81874cb371fa423634621b Reviewed-on: http://codereview.qt.nokia.com/125 Reviewed-by: David Boddie --- examples/opengl/cube/geometryengine.cpp | 2 ++ examples/opengl/cube/mainwidget.cpp | 2 ++ examples/opengl/cube/mainwidget.h | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/opengl/cube/geometryengine.cpp b/examples/opengl/cube/geometryengine.cpp index 2f6f65948d3..01a33f3bb7f 100644 --- a/examples/opengl/cube/geometryengine.cpp +++ b/examples/opengl/cube/geometryengine.cpp @@ -21,6 +21,8 @@ GeometryEngine::~GeometryEngine() void GeometryEngine::init() { + initializeGLFunctions(); + //! [0] // Generate 2 VBOs glGenBuffers(2, vboIds); diff --git a/examples/opengl/cube/mainwidget.cpp b/examples/opengl/cube/mainwidget.cpp index bead5f79ed0..682ce5c9e78 100644 --- a/examples/opengl/cube/mainwidget.cpp +++ b/examples/opengl/cube/mainwidget.cpp @@ -78,6 +78,8 @@ void MainWidget::timerEvent(QTimerEvent *e) void MainWidget::initializeGL() { + initializeGLFunctions(); + qglClearColor(Qt::black); qDebug() << "Initializing shaders..."; diff --git a/examples/opengl/cube/mainwidget.h b/examples/opengl/cube/mainwidget.h index 595173b65d6..75d069d2f62 100644 --- a/examples/opengl/cube/mainwidget.h +++ b/examples/opengl/cube/mainwidget.h @@ -2,6 +2,7 @@ #define MAINWIDGET_H #include +#include #include #include @@ -12,7 +13,7 @@ class QGLShaderProgram; class GeometryEngine; -class MainWidget : public QGLWidget +class MainWidget : public QGLWidget, protected QGLFunctions { Q_OBJECT public: From 0ed16a1c5570014abefcc24a8caace3b0967a9b3 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 23 May 2011 17:08:04 +1000 Subject: [PATCH 18/59] Remove the redundant QTEST_ACCESSIBILITY define. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QTEST_ACCESSIBILITY was always defined and only used in one autotest. Code that uses accessibility features should be excluded if Qt was built without accessibility rather than based on a define in the test framework. Change-Id: I3a517a579a51f536a0983b43bd99e86292026552 Reviewed-by: pending Reviewed-on: http://codereview.qt.nokia.com/129 Reviewed-by: Morten Johan Sørvig Reviewed-by: Rohan McGovern --- src/testlib/qtestaccessible.h | 6 ++---- tests/auto/qaccessibility/tst_qaccessibility.cpp | 13 ------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index d304a6fc39f..9cec1a6bbe1 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -49,8 +49,6 @@ #ifndef QT_NO_ACCESSIBILITY -#define QTEST_ACCESSIBILITY - #define QVERIFY_EVENT(object, child, event) \ QVERIFY(QTestAccessibility::verifyEvent(object, child, (int)event)) @@ -131,9 +129,9 @@ private: if (object) { QApplication* app = qobject_cast(object); if ( !app ) - qWarning("QTEST_ACCESSIBILITY: root Object is not a QApplication!"); + qWarning("%s: root Object is not a QApplication!", Q_FUNC_INFO); } else { - qWarning("QTEST_ACCESSIBILITY: root Object called with 0 pointer"); + qWarning("%s: root Object called with 0 pointer", Q_FUNC_INFO); } } diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 6c0e2611c01..03b2d79bba1 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -947,21 +947,16 @@ void tst_QAccessibility::doAction() void tst_QAccessibility::applicationTest() { -#ifdef QTEST_ACCESSIBILITY QLatin1String name = QLatin1String("My Name"); qApp->setApplicationName(name); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(qApp); QCOMPARE(interface->text(QAccessible::Name, 0), name); QCOMPARE(interface->role(0), QAccessible::Application); delete interface; -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::mainWindowTest() { -#ifdef QTEST_ACCESSIBILITY QMainWindow mw; mw.resize(300, 200); mw.show(); // triggers layout @@ -974,10 +969,6 @@ void tst_QAccessibility::mainWindowTest() QCOMPARE(interface->text(QAccessible::Name, 0), name); QCOMPARE(interface->role(0), QAccessible::Window); delete interface; - -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } class CounterButton : public QPushButton { @@ -1295,7 +1286,6 @@ void tst_QAccessibility::tabTest() void tst_QAccessibility::tabWidgetTest() { -#ifdef QTEST_ACCESSIBILITY QTabWidget *tabWidget = new QTabWidget(); tabWidget->show(); @@ -1381,9 +1371,6 @@ void tst_QAccessibility::tabWidgetTest() delete interface; delete tabWidget; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::menuTest() From c1e372a5a3a2decb3c63e28819e601d5e86ff6ea Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 26 May 2011 09:19:38 +1000 Subject: [PATCH 19/59] Fixed ordering problem when configuring with `-make ' Prior to this change, running configure with the `-make' option would affect the order in which parts of Qt are built. This is unintuitive and would easily cause build failures. For example, configuring with `./configure -make demos' would attempt to build demos before building libs, which, of course, would fail. Refactor the code so that the result is the same regardless of the order of `-make' options. Change-Id: Idfa61834a0f01d0628a9a1ae27ece94ae3647e6d Reviewed-on: http://codereview.qt.nokia.com/128 Reviewed-by: Lincoln Ramsay Reviewed-by: Oswald Buddenhagen --- qtbase.pro | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/qtbase.pro b/qtbase.pro index 9b140025bb2..95f497fef4b 100644 --- a/qtbase.pro +++ b/qtbase.pro @@ -13,20 +13,30 @@ module_qtbase_tests.depends = module_qtbase_src module_qtbase_tests.CONFIG = no_default_install #process the projects -for(PROJECT, $$list($$lower($$unique(QT_BUILD_PARTS)))) { - isEqual(PROJECT, examples) { - SUBDIRS += examples - } else:isEqual(PROJECT, demos) { - SUBDIRS += demos - } else:isEqual(PROJECT, tests) { - SUBDIRS += module_qtbase_tests - } else:isEqual(PROJECT, libs) { - include(src/src.pro) - } else:isEqual(PROJECT, qmake) { -# SUBDIRS += qmake - } else { - message(Unknown PROJECT: $$PROJECT) - } +PROJECTS=$$eval($$list($$lower($$unique(QT_BUILD_PARTS)))) +# note that the order matters for these blocks! +contains(PROJECTS, qmake) { + PROJECTS -= qmake + # nothing to be done +} +contains(PROJECTS, libs) { + PROJECTS -= libs + include(src/src.pro) +} +contains(PROJECTS, examples) { + PROJECTS -= examples + SUBDIRS += examples +} +contains(PROJECTS, demos) { + PROJECTS -= demos + SUBDIRS += demos +} +contains(PROJECTS, tests) { + PROJECTS -= tests + SUBDIRS += module_qtbase_tests +} +!isEmpty(PROJECTS) { + message(Unknown PROJECTS: $$PROJECTS) } !symbian: confclean.depends += clean From 8c9deffcb38eb0a75b876c37613d02eb14c2c0f6 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 26 May 2011 11:52:31 +0200 Subject: [PATCH 20/59] Add private header support to the EGLFS platform plugin. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several of the QPA headers include private headers in the Core, Gui and OpenGL modules and with the new modularized Qt, we need to opt-in for these. Change-Id: Ib7a81f7843ef89e3c5c5218f790287bb6c00e4cb Reviewed-on: http://codereview.qt.nokia.com/133 Reviewed-by: Samuel Rødal --- src/plugins/platforms/eglfs/eglfs.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index 3692e38e1b5..471cf63dd8e 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -2,7 +2,7 @@ TARGET = qeglfs TEMPLATE = lib CONFIG += plugin -QT += opengl +QT += opengl core-private gui-private opengl-private DESTDIR = $$QT.gui.plugins/platforms From 56f030b9947485b87399432d2bb9b8dcf9d562de Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 25 May 2011 12:31:23 -0500 Subject: [PATCH 21/59] Add QtTools' include/QtDesigner as well as QtCore's include/QtDesigner In modularization QT+=uilib adds the QtCore specific include/QtDesigner, while QT += designer adds the QtTools specific one. Using !isEmpty(QT..name) is the proper way to check for module/library existance in modularized Qt. Change-Id: If1fe5d192129fd1cdbf43183b52327d7fa9c57ec Reviewed-on: http://codereview.qt.nokia.com/126 Reviewed-by: Oliver Wolff Reviewed-by: Friedemann Kleint --- mkspecs/features/designer.prf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mkspecs/features/designer.prf b/mkspecs/features/designer.prf index 63a7e76a346..843a118a9ae 100644 --- a/mkspecs/features/designer.prf +++ b/mkspecs/features/designer.prf @@ -1,7 +1,6 @@ -QT += xml -contains(QT_CONFIG, script): QT += script +QT += xml uilib +!isEmpty(QT.script.name): QT += script +!isEmpty(QT.designer.name): QT += designer qt:load(qt) plugin:DEFINES += QDESIGNER_EXPORT_WIDGETS - -qtAddLibrary(QtDesigner, true) From a78e1848118b16cbf517d14926663d175e3fb927 Mon Sep 17 00:00:00 2001 From: shiroki Date: Wed, 25 May 2011 11:11:51 +0200 Subject: [PATCH 22/59] fix "Host" header of ipv6 URLs in QNAM Change-Id: I6bf3320e5ab285e3d1f4d72bd1ef0a0e42813e5b Reviewed-on: http://codereview.qt.nokia.com/115 Reviewed-by: Markus Goetz --- src/network/access/qhttpnetworkconnection.cpp | 12 +++++++++++- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 18 +++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 33124fdd676..d950af4ee29 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -261,7 +261,17 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) // set the host value = request.headerField("host"); if (value.isEmpty()) { - QByteArray host = QUrl::toAce(hostName); + QHostAddress add; + QByteArray host; + if (add.setAddress(hostName)) { + if (add.protocol() == QAbstractSocket::IPv6Protocol) + host = "[" + hostName.toAscii() + "]";//format the ipv6 in the standard way + else + host = hostName.toAscii(); + + } else { + host = QUrl::toAce(hostName); + } int port = request.url().port(); if (port != -1) { diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 4f5bd193c52..67b6e5c5b45 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -457,9 +457,9 @@ public: : client(0), dataToTransmit(data), doClose(true), doSsl(ssl), ipv6(useipv6), multiple(false), totalConnections(0) { - if( useipv6 ){ + if (useipv6) { listen(QHostAddress::AnyIPv6); - }else{ + } else { listen(); } if (thread) { @@ -2338,8 +2338,9 @@ void tst_QNetworkReply::connectToIPv6Address_data() QTest::addColumn("url"); QTest::addColumn("error"); QTest::addColumn("dataToSend"); - QTest::addColumn("serverVerifyData"); - QTest::newRow("localhost") << QUrl(QByteArray("http://[::1]")) << QNetworkReply::NoError<< QByteArray("localhost") << QByteArray("\r\nHost: [::1]\r\n"); + QTest::addColumn("hostfield"); + QTest::newRow("localhost") << QUrl(QByteArray("http://[::1]")) << QNetworkReply::NoError<< QByteArray("localhost") << QByteArray("[::1]"); + //QTest::newRow("ipv4localhost") << QUrl(QByteArray("http://127.0.0.1")) << QNetworkReply::NoError<< QByteArray("ipv4localhost") << QByteArray("127.0.0.1"); //to add more test data here } @@ -2348,7 +2349,7 @@ void tst_QNetworkReply::connectToIPv6Address() QFETCH(QUrl, url); QFETCH(QNetworkReply::NetworkError, error); QFETCH(QByteArray, dataToSend); - QFETCH(QByteArray, serverVerifyData); + QFETCH(QByteArray, hostfield); QByteArray httpResponse = QByteArray("HTTP/1.0 200 OK\r\nContent-Length: "); httpResponse += QByteArray::number(dataToSend.size()); @@ -2366,10 +2367,9 @@ void tst_QNetworkReply::connectToIPv6Address() QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QByteArray content = reply->readAll(); - if( !serverVerifyData.isEmpty()){ - //qDebug() << server.receivedData; - //QVERIFY(server.receivedData.contains(serverVerifyData)); //got a bug here - } + //qDebug() << server.receivedData; + QByteArray hostinfo = "\r\nHost: " + hostfield + ":" + QByteArray::number(server.serverPort()) + "\r\n"; + QVERIFY(server.receivedData.contains(hostinfo)); QVERIFY(content == dataToSend); QCOMPARE(reply->url(), request.url()); QVERIFY(reply->error() == error); From dd4b997c58143c63a45e6ff22f18d9cf07f29923 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 18 May 2011 15:08:53 +0100 Subject: [PATCH 23/59] Update qhostinfo autotest to expect RFC5952 formatted ipv6 addresses Test required updating due to ebc134db484eee31491836b619aad1ee86e3070e Reviewed-by: Martin Petersson (cherry picked from commit e46e32644720f0ddeb553b8a658c1711a4b5cdfb) Change-Id: Idf3df633534a0d914bd22fd589a8c521eb426bc8 Reviewed-on: http://codereview.qt.nokia.com/139 Reviewed-by: Markus Goetz --- tests/auto/qhostinfo/tst_qhostinfo.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index 74b71ad4554..93c08cdc6be 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -316,16 +316,16 @@ void tst_QHostInfo::lookupIPv6_data() QTest::addColumn("addresses"); QTest::addColumn("err"); - QTest::newRow("ipv6-net") << "www.ipv6-net.org" << "62.93.217.177 2001:618:1401:0:0:0:0:4" << int(QHostInfo::NoError); - QTest::newRow("ipv6-test") << "ipv6-test.dev.troll.no" << "2001:638:a00:2:0:0:0:2" << int(QHostInfo::NoError); - QTest::newRow("dns6-test") << "dns6-test-dev.troll.no" << "2001:470:1f01:115:0:0:0:10" << int(QHostInfo::NoError); - QTest::newRow("multi-dns6") << "multi-dns6-test-dev.troll.no" << "2001:470:1f01:115:0:0:0:11 2001:470:1f01:115:0:0:0:12" << int(QHostInfo::NoError); - QTest::newRow("dns46-test") << "dns46-test-dev.troll.no" << "10.3.4.90 2001:470:1f01:115:0:0:0:13" << int(QHostInfo::NoError); + QTest::newRow("ipv6-net") << "www.ipv6-net.org" << "62.93.217.177 2001:618:1401::4" << int(QHostInfo::NoError); + QTest::newRow("ipv6-test") << "ipv6-test.dev.troll.no" << "2001:638:a00:2::2" << int(QHostInfo::NoError); + QTest::newRow("dns6-test") << "dns6-test-dev.troll.no" << "2001:470:1f01:115::10" << int(QHostInfo::NoError); + QTest::newRow("multi-dns6") << "multi-dns6-test-dev.troll.no" << "2001:470:1f01:115::11 2001:470:1f01:115::12" << int(QHostInfo::NoError); + QTest::newRow("dns46-test") << "dns46-test-dev.troll.no" << "10.3.4.90 2001:470:1f01:115::13" << int(QHostInfo::NoError); // avoid using real IPv6 addresses here because this will do a DNS query // real addresses are between 2000:: and 3fff:ffff:ffff:ffff:ffff:ffff:ffff QTest::newRow("literal_ip6") << "f001:6b0:1:ea:202:a5ff:fecd:13a6" << "f001:6b0:1:ea:202:a5ff:fecd:13a6" << int(QHostInfo::NoError); - QTest::newRow("literal_shortip6") << "f001:618:1401::4" << "f001:618:1401:0:0:0:0:4" << int(QHostInfo::NoError); + QTest::newRow("literal_shortip6") << "f001:618:1401::4" << "f001:618:1401::4" << int(QHostInfo::NoError); } void tst_QHostInfo::lookupIPv6() From 785905a1f4b46f7278653e2e50604f23d359a848 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 13 May 2011 16:19:18 +0100 Subject: [PATCH 24/59] Fix thread safety regression of QNetworkConfigurationManager Changes in 4.8 led to a timer being created in the wrong thread. I have restored the invokeMethod used to call startPolling() to solve this problem. Reviewed-By: mread (cherry picked from commit e9e95f75e7c1e8325c2acce0087ff8677d773779) Change-Id: I8b89fa89766679beb2d469f9bbd1f5e2233f061b Reviewed-on: http://codereview.qt.nokia.com/138 Reviewed-by: Markus Goetz --- src/network/bearer/qnetworkconfigmanager_p.cpp | 2 +- src/network/bearer/qnetworkconfigmanager_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 338cf59c02b..54cd898c67f 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -488,7 +488,7 @@ void QNetworkConfigurationManagerPrivate::enablePolling() ++forcedPolling; if (forcedPolling == 1) - startPolling(); + QMetaObject::invokeMethod(this, "startPolling"); } void QNetworkConfigurationManagerPrivate::disablePolling() diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 02e00b9a955..04cce202c5c 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -107,7 +107,7 @@ private Q_SLOTS: void pollEngines(); private: - void startPolling(); + Q_INVOKABLE void startPolling(); QTimer *pollTimer; private: From 8bcf0f55346a52336a925239cbb9a0305357a070 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 13 May 2011 16:32:58 +0100 Subject: [PATCH 25/59] Fix instability in QNetworkConfigurationManager autotest QThread::isFinished() can return false after the finished() signal is emitted, so test the event loop's timeout() function instead. Don't compare prescan configurations, as these may be cached by the OS. It was causing the test to fail on linux if run before any other network test. Reviewed-by: mread (cherry picked from commit e2320ec17446dc6e851fcf4ea2d998177b0d8049) Change-Id: I35d67294871a35e2e63619f4acb0c3c32caa5eea Reviewed-on: http://codereview.qt.nokia.com/137 Reviewed-by: Markus Goetz --- .../tst_qnetworkconfigurationmanager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 2b11219aa4a..d29ef773474 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -357,7 +357,7 @@ void tst_QNetworkConfigurationManager::usedInThread() connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); thread.start(); QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY could take ~90 seconds to time out in the thread - QVERIFY(thread.isFinished()); + QVERIFY(!QTestEventLoop::instance().timeout()); qDebug() << "prescan:" << thread.preScanConfigs.count(); qDebug() << "postscan:" << thread.configs.count(); @@ -368,7 +368,9 @@ void tst_QNetworkConfigurationManager::usedInThread() QTRY_VERIFY(spy.count() == 1); //wait for scan to complete QList configs = manager.allConfigurations(); QCOMPARE(thread.configs, configs); - QCOMPARE(thread.preScanConfigs, preScanConfigs); + //Don't compare pre scan configs, because these may be cached and therefore give different results + //which makes the test unstable. The post scan results should have all configurations every time + //QCOMPARE(thread.preScanConfigs, preScanConfigs); #endif } From 6794d0883cb3255d76ab6d4fe911a43b0ed6c013 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 18 May 2011 17:55:43 +0200 Subject: [PATCH 26/59] Tests for QtConcurrent::map using lambdas Also disable tests with std::vector in c++0x as they do not compile Reviewed-by: Joao (cherry picked from commit 38d1b31006ecc83811bbb13e5a4182eac593a970) Change-Id: I837f18f043b18410c1d93b9f1156acf729dad510 Reviewed-on: http://codereview.qt.nokia.com/144 Reviewed-by: Olivier Goffart --- .../qtconcurrentmap/tst_qtconcurrentmap.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp index 74ffff2db7e..74a254cbf4a 100644 --- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -146,6 +146,15 @@ void tst_QtConcurrentMap::map() QCOMPARE(numberList, QList() << 2 << 4 << 6); QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); QCOMPARE(numberList, QList() << 4 << 8 << 12); + +#ifdef Q_COMPILER_LAMBDA + // lambda + QtConcurrent::map(list, [](int &x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList() << 128 << 256 << 384); + QtConcurrent::map(list.begin(), list.end(), [](int &x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList() << 256 << 512 << 768); +#endif + } // functors don't take arguments by reference, making these no-ops @@ -170,6 +179,14 @@ void tst_QtConcurrentMap::map() QCOMPARE(list, QList() << 1 << 2 << 3); QtConcurrent::map(list.begin(), list.end(), multiplyBy2Immutable).waitForFinished(); QCOMPARE(list, QList() << 1 << 2 << 3); + +#ifdef Q_COMPILER_LAMBDA + // lambda + QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList() << 1 << 2 << 3); + QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList() << 1 << 2 << 3); +#endif } // Linked lists and forward iterators @@ -2303,6 +2320,10 @@ void tst_QtConcurrentMap::stlContainers() { #ifdef QT_NO_STL QSKIP("Qt compiled without STL support", SkipAll); +#elif defined(Q_COMPILER_RVALUE_REFS) + //mapped uses &Container::push_back, but in c++0x, std::vector has two overload of it + // meaning it is not possible to take the address of that function anymore. + QSKIP("mapped do not work with c++0x stl vector", SkipAll); #else std::vector vector; vector.push_back(1); From 83291e6a07a9b6dc6c2d05b4fd4492df79796bbf Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 19 May 2011 14:43:53 +0200 Subject: [PATCH 27/59] Add QtPrivate::QEnableIf Needed for QtConcurrent. Like the new std::enable_if (in c++0x) Reviewed-by: Joao (cherry picked from commit 837f18f043b18410c1d93b9f1156acf729dad510) Change-Id: I837f18f043b18410c1d93b9f1156acf729dad510 Reviewed-on: http://codereview.qt.nokia.com/141 Reviewed-by: Olivier Goffart --- src/corelib/global/qglobal.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 3cc12aaf822..445b65ba0d7 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2790,6 +2790,12 @@ QT_LICENSED_MODULE(Sensors) # define QT_NO_RAWFONT #endif +namespace QtPrivate { +//like std::enable_if +template struct QEnableIf; +template struct QEnableIf { typedef T Type; }; +} + QT_END_NAMESPACE QT_END_HEADER From d3e5fc0220e57d5a9bba35780915c53790ff249f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 18 Apr 2011 14:07:32 +0200 Subject: [PATCH 28/59] Support of lambdas in QtConcurrent::run Reviewed-by: Joao (cherry picked from commit 917f2ff617209bcc283eb3590b422bcf239c0537) Change-Id: I837f18f043b18410c1d93b9f1156acf729dad510 Reviewed-on: http://codereview.qt.nokia.com/142 Reviewed-by: Olivier Goffart --- .../concurrent/qtconcurrentcompilertest.h | 14 +++ .../concurrent/qtconcurrentfunctionwrappers.h | 11 +- src/corelib/concurrent/qtconcurrentrun.h | 75 +++++++++++-- .../qtconcurrentstoredfunctioncall.h | 105 ++++++++---------- src/corelib/global/qglobal.h | 3 + .../qtconcurrentrun/tst_qtconcurrentrun.cpp | 67 +++++++++++ 6 files changed, 194 insertions(+), 81 deletions(-) diff --git a/src/corelib/concurrent/qtconcurrentcompilertest.h b/src/corelib/concurrent/qtconcurrentcompilertest.h index 884badbfbda..c139c7a8b2d 100644 --- a/src/corelib/concurrent/qtconcurrentcompilertest.h +++ b/src/corelib/concurrent/qtconcurrentcompilertest.h @@ -57,6 +57,20 @@ QT_MODULE(Core) # define QT_TYPENAME typename #endif +namespace QtPrivate { + +template +class HasResultType { + typedef char Yes; + typedef void *No; + template static Yes test(int, const typename U::result_type * = 0); + template static No test(double); +public: + enum { Value = (sizeof(test(0)) == sizeof(Yes)) }; +}; + +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h index a79ad1c305f..4bf2736e6cb 100644 --- a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h +++ b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h @@ -195,17 +195,10 @@ QtConcurrent::ConstMemberFunctionWrapper createFunctionWrapper(T (C::*func return QtConcurrent::ConstMemberFunctionWrapper(func); } - -template -void *lazyResultType_helper(int, typename T::result_type * = 0); -template -char lazyResultType_helper(double); - -template (0)) != sizeof(void*)> +template ::Value> struct LazyResultType { typedef typename Functor::result_type Type; }; template -struct LazyResultType { typedef void Type; }; - +struct LazyResultType { typedef void Type; }; template struct ReduceResultType; diff --git a/src/corelib/concurrent/qtconcurrentrun.h b/src/corelib/concurrent/qtconcurrentrun.h index 8611fba3613..ef51b2adcbe 100644 --- a/src/corelib/concurrent/qtconcurrentrun.h +++ b/src/corelib/concurrent/qtconcurrentrun.h @@ -71,63 +71,114 @@ namespace QtConcurrent { template QFuture run(T (*functionPointer)()) { - return (new QT_TYPENAME SelectStoredFunctorCall0::type(functionPointer))->start(); + return (new StoredFunctorCall0(functionPointer))->start(); } template QFuture run(T (*functionPointer)(Param1), const Arg1 &arg1) { - return (new QT_TYPENAME SelectStoredFunctorCall1::type(functionPointer, arg1))->start(); + return (new StoredFunctorCall1(functionPointer, arg1))->start(); } template QFuture run(T (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) { - return (new QT_TYPENAME SelectStoredFunctorCall2::type(functionPointer, arg1, arg2))->start(); + return (new StoredFunctorCall2(functionPointer, arg1, arg2))->start(); } template QFuture run(T (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return (new QT_TYPENAME SelectStoredFunctorCall3::type(functionPointer, arg1, arg2, arg3))->start(); + return (new StoredFunctorCall3(functionPointer, arg1, arg2, arg3))->start(); } template QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return (new QT_TYPENAME SelectStoredFunctorCall4::type(functionPointer, arg1, arg2, arg3, arg4))->start(); + return (new StoredFunctorCall4(functionPointer, arg1, arg2, arg3, arg4))->start(); } template QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) { - return (new QT_TYPENAME SelectStoredFunctorCall5::type(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(); + return (new StoredFunctorCall5(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(); } +#ifdef Q_COMPILER_DECLTYPE + +template +auto run(Functor functor) -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor()) result_type; + return (new StoredFunctorCall0(functor))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1)) result_type; + return (new StoredFunctorCall1(functor, arg1))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1, arg2)) result_type; + return (new StoredFunctorCall2(functor, arg1, arg2))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1, arg2, arg3)) result_type; + return (new StoredFunctorCall3(functor, arg1, arg2, arg3))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type; + return (new StoredFunctorCall4(functor, arg1, arg2, arg3, arg4))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type; + return (new StoredFunctorCall5(functor, arg1, arg2, arg3, arg4, arg5))->start(); +} + +#endif + template QFuture run(FunctionObject functionObject) { - return (new QT_TYPENAME SelectStoredFunctorCall0::type(functionObject))->start(); + return (new StoredFunctorCall0(functionObject))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1) { - return (new QT_TYPENAME SelectStoredFunctorCall1::type(functionObject, arg1))->start(); + return (new StoredFunctorCall1(functionObject, arg1))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2) { - return (new QT_TYPENAME SelectStoredFunctorCall2::type(functionObject, arg1, arg2))->start(); + return (new StoredFunctorCall2(functionObject, arg1, arg2))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return (new QT_TYPENAME SelectStoredFunctorCall3::type(functionObject, arg1, arg2, arg3))->start(); + return (new StoredFunctorCall3(functionObject, arg1, arg2, arg3))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return (new QT_TYPENAME SelectStoredFunctorCall4::type(functionObject, arg1, arg2, arg3, arg4))->start(); + return (new StoredFunctorCall4(functionObject, arg1, arg2, arg3, arg4))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) { - return (new QT_TYPENAME SelectStoredFunctorCall5::type(functionObject, arg1, arg2, arg3, arg4, arg5))->start(); + return (new StoredFunctorCall5(functionObject, arg1, arg2, arg3, arg4, arg5))->start(); } template diff --git a/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h b/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h index c61f9b80140..9beb0b9c352 100644 --- a/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h +++ b/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h @@ -66,23 +66,16 @@ struct StoredFunctorCall0: public RunFunctionTask }; -template -struct VoidStoredFunctorCall0: public RunFunctionTask +template +struct StoredFunctorCall0: public RunFunctionTask { - inline VoidStoredFunctorCall0(FunctionPointer _function) + inline StoredFunctorCall0(FunctionPointer _function) : function(_function) {} void runFunctor() { function(); } FunctionPointer function; }; -template -struct SelectStoredFunctorCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall0 >::type type; -}; template struct StoredFunctorPointerCall0: public RunFunctionTask { @@ -276,23 +269,16 @@ struct StoredFunctorCall1: public RunFunctionTask Arg1 arg1; }; -template -struct VoidStoredFunctorCall1: public RunFunctionTask +template +struct StoredFunctorCall1: public RunFunctionTask { - inline VoidStoredFunctorCall1(FunctionPointer _function, const Arg1 &_arg1) + inline StoredFunctorCall1(FunctionPointer _function, const Arg1 &_arg1) : function(_function), arg1(_arg1) {} void runFunctor() { function(arg1); } FunctionPointer function; Arg1 arg1; }; -template -struct SelectStoredFunctorCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall1 >::type type; -}; template struct StoredFunctorPointerCall1: public RunFunctionTask { @@ -486,23 +472,16 @@ struct StoredFunctorCall2: public RunFunctionTask Arg1 arg1; Arg2 arg2; }; -template -struct VoidStoredFunctorCall2: public RunFunctionTask +template +struct StoredFunctorCall2: public RunFunctionTask { - inline VoidStoredFunctorCall2(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2) + inline StoredFunctorCall2(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2) : function(_function), arg1(_arg1), arg2(_arg2) {} void runFunctor() { function(arg1, arg2); } FunctionPointer function; Arg1 arg1; Arg2 arg2; }; -template -struct SelectStoredFunctorCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall2 >::type type; -}; template struct StoredFunctorPointerCall2: public RunFunctionTask { @@ -696,23 +675,16 @@ struct StoredFunctorCall3: public RunFunctionTask Arg1 arg1; Arg2 arg2; Arg3 arg3; }; -template -struct VoidStoredFunctorCall3: public RunFunctionTask +template +struct StoredFunctorCall3: public RunFunctionTask { - inline VoidStoredFunctorCall3(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) + inline StoredFunctorCall3(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3) {} void runFunctor() { function(arg1, arg2, arg3); } FunctionPointer function; Arg1 arg1; Arg2 arg2; Arg3 arg3; }; -template -struct SelectStoredFunctorCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall3 >::type type; -}; template struct StoredFunctorPointerCall3: public RunFunctionTask { @@ -906,23 +878,16 @@ struct StoredFunctorCall4: public RunFunctionTask Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; }; -template -struct VoidStoredFunctorCall4: public RunFunctionTask +template +struct StoredFunctorCall4: public RunFunctionTask { - inline VoidStoredFunctorCall4(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) + inline StoredFunctorCall4(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4) {} void runFunctor() { function(arg1, arg2, arg3, arg4); } FunctionPointer function; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; }; -template -struct SelectStoredFunctorCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall4 >::type type; -}; template struct StoredFunctorPointerCall4: public RunFunctionTask { @@ -1116,23 +1081,16 @@ struct StoredFunctorCall5: public RunFunctionTask Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; -template -struct VoidStoredFunctorCall5: public RunFunctionTask +template +struct StoredFunctorCall5: public RunFunctionTask { - inline VoidStoredFunctorCall5(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) + inline StoredFunctorCall5(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5) {} void runFunctor() { function(arg1, arg2, arg3, arg4, arg5); } FunctionPointer function; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; -template -struct SelectStoredFunctorCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall5 >::type type; -}; template struct StoredFunctorPointerCall5: public RunFunctionTask { @@ -1316,6 +1274,33 @@ struct SelectStoredConstMemberFunctionPointerCall5 Type, VoidStoredConstMemberFunctionPointerCall5 >::type type; }; + +template +class StoredFunctorCall : public RunFunctionTask +{ +public: + StoredFunctorCall(const Functor &f) : functor(f) { } + void runFunctor() + { + this->result = functor(); + } +private: + Functor functor; +}; +template +class StoredFunctorCall : public RunFunctionTask +{ +public: + StoredFunctorCall(const Functor &f) : functor(f) { } + void runFunctor() + { + functor(); + } +private: + Functor functor; +}; + + } //namespace QtConcurrent #endif // qdoc diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 445b65ba0d7..32823903542 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -428,6 +428,7 @@ namespace QT_NAMESPACE {} # define Q_COMPILER_INITIALIZER_LISTS # define Q_COMPILER_AUTO_TYPE # define Q_COMPILER_LAMBDA +# define Q_COMPILER_DECLTYPE //# define Q_COMPILER_VARIADIC_TEMPLATES //# define Q_COMPILER_CLASS_ENUM //# define Q_COMPILER_DEFAULT_DELETE_MEMBERS @@ -524,6 +525,7 @@ namespace QT_NAMESPACE {} # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 /* C++0x features supported in GCC 4.3: */ # define Q_COMPILER_RVALUE_REFS +# define Q_COMPILER_DECLTYPE # endif # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 /* C++0x features supported in GCC 4.4: */ @@ -791,6 +793,7 @@ namespace QT_NAMESPACE {} # if __INTEL_COMPILER >= 1100 # define Q_COMPILER_RVALUE_REFS # define Q_COMPILER_EXTERN_TEMPLATES +# define Q_COMPILER_DECLTYPE # elif __INTEL_COMPILER >= 1200 # define Q_COMPILER_VARIADIC_TEMPLATES # define Q_COMPILER_AUTO_TYPE diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp index e4e9479a132..cacb09aae19 100644 --- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -67,6 +67,8 @@ private slots: #if 0 void createFunctor(); #endif + void functor(); + void lambda(); }; #if 0 @@ -444,6 +446,71 @@ void tst_QtConcurrentRun::createFunctor() } #endif +struct Functor { + int operator()() { return 42; } + double operator()(double a, double b) { return a/b; } + int operator()(int a, int b) { return a/b; } + void operator()(int) { } + void operator()(int, int, int) { } + void operator()(int, int, int, int) { } + void operator()(int, int, int, int, int) { } + void operator()(int, int, int, int, int, int) { } +}; + +void tst_QtConcurrentRun::functor() +{ + //this test functor without result_type, decltype need to be supported by the compiler +#ifndef Q_COMPILER_DECLTYPE + QSKIP("Compiler do not suport decltype", SkipAll); +#else + Functor f; + { + QFuture fut = QtConcurrent::run(f); + QCOMPARE(fut.result(), 42); + } + { + QFuture fut = QtConcurrent::run(f, 8.5, 1.8); + QCOMPARE(fut.result(), (8.5/1.8)); + } + { + QFuture fut = QtConcurrent::run(f, 19, 3); + QCOMPARE(fut.result(), int(19/3)); + } + { + QtConcurrent::run(f, 1).waitForFinished(); + QtConcurrent::run(f, 1,2).waitForFinished(); + QtConcurrent::run(f, 1,2,3).waitForFinished(); + QtConcurrent::run(f, 1,2,3,4).waitForFinished(); + QtConcurrent::run(f, 1,2,3,4,5).waitForFinished(); + } +#endif +} + + +void tst_QtConcurrentRun::lambda() +{ +#ifndef Q_COMPILER_LAMBDA + QSKIP("Compiler do not suport lambda", SkipAll); +#else + + QCOMPARE(QtConcurrent::run([](){ return 45; }).result(), 45); + QCOMPARE(QtConcurrent::run([](int a){ return a+15; }, 12).result(), 12+15); + QCOMPARE(QtConcurrent::run([](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); + QCOMPARE(QtConcurrent::run([](int a , int, int, int, int b){ return a + b; }, 1, 2, 3, 4, 5).result(), 1 + 5); + +#ifdef Q_COMPILER_INITIALIZER_LISTS + { + QString str { "Hello World Foo" }; + QFuture f1 = QtConcurrent::run([&](){ return str.split(' '); }); + auto r = f1.result(); + QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); + } +#endif + +#endif +} + + #include "tst_qtconcurrentrun.moc" #else From cc6faee69e48fb81a1cb8d9d2102997106914f82 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 20 Apr 2011 13:49:19 +0200 Subject: [PATCH 29/59] MSVC do not really support initilizer_list std::initializer_list exists, but it is not possible to do bracket initialisation Reviewed-by: Joao (cherry picked from commit a09f5c425079405e72078813bdb7b103c29a5221) Change-Id: I837f18f043b18410c1d93b9f1156acf729dad510 Reviewed-on: http://codereview.qt.nokia.com/143 Reviewed-by: Olivier Goffart --- src/corelib/global/qglobal.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 32823903542..b3eeff78f87 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -425,15 +425,11 @@ namespace QT_NAMESPACE {} #if defined(Q_CC_MSVC) && _MSC_VER >= 1600 # define Q_COMPILER_RVALUE_REFS -# define Q_COMPILER_INITIALIZER_LISTS # define Q_COMPILER_AUTO_TYPE # define Q_COMPILER_LAMBDA # define Q_COMPILER_DECLTYPE -//# define Q_COMPILER_VARIADIC_TEMPLATES -//# define Q_COMPILER_CLASS_ENUM -//# define Q_COMPILER_DEFAULT_DELETE_MEMBERS -//# define Q_COMPILER_UNICODE_STRINGS -//# define Q_COMPILER_EXTERN_TEMPLATES +// MSCV has std::initilizer_list, but do not support the braces initilization +//# define Q_COMPILER_INITIALIZER_LISTS # endif From bc7ea289ea84dcff22aeea78c01a5447ccf076f7 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 25 May 2011 15:05:35 +0200 Subject: [PATCH 30/59] Added some of my Qt 4.8 changes to the changelog Change-Id: I8913c88e5bd68145e0587d51ee9896fd5d21054a Reviewed-on: http://codereview.qt.nokia.com/140 Reviewed-by: Olivier Goffart --- dist/changes-4.8.0 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index b8cc62600ec..170363352d6 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -39,12 +39,29 @@ QtCore - Removed support for QT_NO_THREAD define for QHostInfo. - Optimized plugin loading on ELF platforms. Print failure reason at runtime with QT_DEBUG_PLUGINS=1 in environment. + - QMutexLocker: improved performence of the non contended case by inlining some function + - QThreadStorage: Added possibility to store object by value instead of by pointer [QTBUG-15033] + - QThread: fixed few race conditions [QTBUG-17257, QTBUG-15030] + - QtConcurrent: added support for c++0x lambda in few functions + - QObject: Improved performence of the signal activation + - QObject: added ways to connect signals using QMetaMethod + - QObject: deprecated qFindChild and qFindChildren + - QObject: optimize constructions and destruction of objects + - QObject: Qt::BlockingQueuedConnection can handle the return value [QTBUG-10440] + - QList/QVector/QStringList: added C++0x initilizer lists constructors. + - QVarLenghtArray: added method for consistency with QVector + - QStringBuilder: added support for QByteArray + - qSwap now uses std::swap, specialized std::swap for our container to work better with stl algoritms + - QVariant: deprecated global function qVariantSetValue, qVariantValue, qVariantCanConvert, qVariantFromValue QtGui ----- - QTabBar: reduced minimumSizeHint if ElideMode is set. - QComboBox: Fixed a color propagation issue with the lineedit. [QTBUG-5950] + - Deprecate qGenericMatrixFromMatrix4x4 and qGenericMatrixToMatrix4x4 + - QListView diverses optimisations [QTBUG-11438] + - QTreeWidget/QListWidget: use localeAwareCompare for string comparisons [QTBUG-10839] QtOpenGL -------- @@ -54,6 +71,10 @@ QtGui - Including will not work in combination with GLEW, as QGLFunctions will undefine GLEW's defines. +QtScript +-------- + - Deprecated qScriptValueFromQMetaObject, qScriptValueToValue, qScriptValueFromValue + **************************************************************************** * Database Drivers * @@ -136,6 +157,7 @@ Qt for Windows CE - qtconfig + * removed Qt3support dependency - qt3to4 From bbbea1fa966525ae8417297ce5579c5f2011ad2c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 20 May 2011 09:31:16 +0200 Subject: [PATCH 31/59] Fix typo in comment (cherry picked from commit c8a3c427e96ee11907592f5c7f72046795c027ed) Change-Id: I837f18f043b18410c1d93b9f1156acf729dad510 Reviewed-on: http://codereview.qt.nokia.com/145 Reviewed-by: Olivier Goffart Reviewed-by: axis --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index b3eeff78f87..64baf3a0265 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -428,7 +428,7 @@ namespace QT_NAMESPACE {} # define Q_COMPILER_AUTO_TYPE # define Q_COMPILER_LAMBDA # define Q_COMPILER_DECLTYPE -// MSCV has std::initilizer_list, but do not support the braces initilization +// MSCV has std::initilizer_list, but do not support the braces initialization //# define Q_COMPILER_INITIALIZER_LISTS # endif From d49973f834fb73c534275f5b1d508329638e2823 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 26 May 2011 15:12:48 +0200 Subject: [PATCH 32/59] Fix infinite recursion when changing geometry on Mac Some complex widgets might get a negatively sized rectangle when calling QWidgetPrivate:setGeometry_sys_helper(), triggering a infinite recursion. Normalizing the rectangle size before checking for size change is enough to break this infinite recursion. Task-number: QTBUG-17333 Change-Id: I4682c3088ea53fb9f28f746c8264f573b5284825 Reviewed-on: http://codereview.qt.nokia.com/156 Reviewed-by: Olivier Goffart --- src/gui/kernel/qwidget_mac.mm | 12 +++++------- tests/auto/qwidget/tst_qwidget.cpp | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 9a873f32ac5..3a025e92372 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4541,6 +4541,11 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM QPoint oldp = q->pos(); QSize olds = q->size(); + // Apply size restrictions, applicable for Windows & Widgets. + if (QWExtra *extra = extraData()) { + w = qBound(extra->minw, w, extra->maxw); + h = qBound(extra->minh, h, extra->maxh); + } const bool isResize = (olds != QSize(w, h)); if (!realWindow && !isResize && QPoint(x, y) == oldp) @@ -4550,13 +4555,6 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM data.window_state = data.window_state & ~Qt::WindowMaximized; const bool visible = q->isVisible(); - // Apply size restrictions, applicable for Windows & Widgets. - if (QWExtra *extra = extraData()) { - w = qMin(w, extra->maxw); - h = qMin(h, extra->maxh); - w = qMax(w, extra->minw); - h = qMax(h, extra->minh); - } data.crect = QRect(x, y, w, h); if (realWindow) { diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index f070d24ec32..eb110a246e2 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -403,6 +404,7 @@ private slots: void taskQTBUG_11373(); #endif // QT_MAC_USE_COCOA #endif + void taskQTBUG_17333_ResizeInfiniteRecursion(); void nativeChildFocus(); @@ -10464,6 +10466,18 @@ void tst_QWidget::taskQTBUG_11373() #endif // QT_MAC_USE_COCOA #endif +void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion() +{ + QTableView tb; + const char *s = "border: 1px solid;"; + tb.setStyleSheet(s); + tb.show(); + + QTest::qWaitForWindowShown(&tb); + tb.setGeometry(QRect(100, 100, 0, 100)); + // No crash, it works. +} + void tst_QWidget::nativeChildFocus() { QWidget w; From a6973e22ff3ec047875d296182c2ac4d106e2ddf Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 27 May 2011 13:20:52 +1000 Subject: [PATCH 33/59] Use "QT += testlib" consistently If a project uses "load(qttest_p4)" it doesn't need to add testlib to the CONFIG or QT variables. If a project does not use "load(qttest_p4)", it should add "testlib" to the QT variable. Change-Id: If28353713ccdfe13612682e3e88dadebe2f2eefd Reviewed-on: http://codereview.qt.nokia.com/159 Reviewed-by: Rohan McGovern --- examples/qtestlib/tutorial1/tutorial1.pro | 2 +- examples/qtestlib/tutorial2/tutorial2.pro | 2 +- examples/qtestlib/tutorial3/tutorial3.pro | 2 +- examples/qtestlib/tutorial4/tutorial4.pro | 2 +- examples/qtestlib/tutorial5/tutorial5.pro | 2 +- tests/auto/qcompleter/qcompleter.pro | 8 -------- tests/auto/qerrormessage/qerrormessage.pro | 7 ------- tests/auto/qlocalsocket/lackey/lackey.pro | 6 +----- tests/auto/qmessagebox/qmessagebox.pro | 4 ---- tests/auto/qtipc/lackey/lackey.pro | 7 +------ tests/auto/uic/uic.pro | 1 - 11 files changed, 7 insertions(+), 36 deletions(-) diff --git a/examples/qtestlib/tutorial1/tutorial1.pro b/examples/qtestlib/tutorial1/tutorial1.pro index fdbf2fc3659..6da372bcbba 100644 --- a/examples/qtestlib/tutorial1/tutorial1.pro +++ b/examples/qtestlib/tutorial1/tutorial1.pro @@ -1,5 +1,5 @@ SOURCES = testqstring.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial1 diff --git a/examples/qtestlib/tutorial2/tutorial2.pro b/examples/qtestlib/tutorial2/tutorial2.pro index 647ddd75ae9..06cf30fae90 100644 --- a/examples/qtestlib/tutorial2/tutorial2.pro +++ b/examples/qtestlib/tutorial2/tutorial2.pro @@ -1,5 +1,5 @@ SOURCES = testqstring.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial2 diff --git a/examples/qtestlib/tutorial3/tutorial3.pro b/examples/qtestlib/tutorial3/tutorial3.pro index 887fc9a592b..ff39bd40bda 100644 --- a/examples/qtestlib/tutorial3/tutorial3.pro +++ b/examples/qtestlib/tutorial3/tutorial3.pro @@ -1,5 +1,5 @@ SOURCES = testgui.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial3 diff --git a/examples/qtestlib/tutorial4/tutorial4.pro b/examples/qtestlib/tutorial4/tutorial4.pro index 082a3a3caad..ae84726b834 100644 --- a/examples/qtestlib/tutorial4/tutorial4.pro +++ b/examples/qtestlib/tutorial4/tutorial4.pro @@ -1,5 +1,5 @@ SOURCES = testgui.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial4 diff --git a/examples/qtestlib/tutorial5/tutorial5.pro b/examples/qtestlib/tutorial5/tutorial5.pro index 4f70284309b..085dfd8b675 100644 --- a/examples/qtestlib/tutorial5/tutorial5.pro +++ b/examples/qtestlib/tutorial5/tutorial5.pro @@ -1,5 +1,5 @@ SOURCES = benchmarking.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial5 diff --git a/tests/auto/qcompleter/qcompleter.pro b/tests/auto/qcompleter/qcompleter.pro index 39b5dd717ec..bd352d819c8 100644 --- a/tests/auto/qcompleter/qcompleter.pro +++ b/tests/auto/qcompleter/qcompleter.pro @@ -1,16 +1,8 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 26 13:53:24 2006 -###################################################################### load(qttest_p4) TEMPLATE = app TARGET = tst_qcompleter DEPENDPATH += . INCLUDEPATH += . .. -CONFIG += console qtestlib - # Input SOURCES += tst_qcompleter.cpp - - - diff --git a/tests/auto/qerrormessage/qerrormessage.pro b/tests/auto/qerrormessage/qerrormessage.pro index 0db361081bc..1c24aa83cb7 100644 --- a/tests/auto/qerrormessage/qerrormessage.pro +++ b/tests/auto/qerrormessage/qerrormessage.pro @@ -1,15 +1,8 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 26 13:53:24 2006 -###################################################################### load(qttest_p4) TEMPLATE = app TARGET = tst_qerrormessage DEPENDPATH += . INCLUDEPATH += . -CONFIG += console qtestlib # Input SOURCES += tst_qerrormessage.cpp - - - diff --git a/tests/auto/qlocalsocket/lackey/lackey.pro b/tests/auto/qlocalsocket/lackey/lackey.pro index 6af58b122ad..2573222c8b4 100644 --- a/tests/auto/qlocalsocket/lackey/lackey.pro +++ b/tests/auto/qlocalsocket/lackey/lackey.pro @@ -1,10 +1,6 @@ #include(../src/src.pri) -QT = core script network - -requires(contains(QT_CONFIG,script)) - -CONFIG += qtestlib +QT = core script network testlib DESTDIR = ./ diff --git a/tests/auto/qmessagebox/qmessagebox.pro b/tests/auto/qmessagebox/qmessagebox.pro index 9fa1738a796..a845e2186aa 100644 --- a/tests/auto/qmessagebox/qmessagebox.pro +++ b/tests/auto/qmessagebox/qmessagebox.pro @@ -1,13 +1,9 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 26 13:53:24 2006 -###################################################################### load(qttest_p4) TEMPLATE = app TARGET = tst_qmessagebox DEPENDPATH += . INCLUDEPATH += . -CONFIG += console qtestlib # Input SOURCES += tst_qmessagebox.cpp diff --git a/tests/auto/qtipc/lackey/lackey.pro b/tests/auto/qtipc/lackey/lackey.pro index 2fa364c4c91..91659d701eb 100644 --- a/tests/auto/qtipc/lackey/lackey.pro +++ b/tests/auto/qtipc/lackey/lackey.pro @@ -1,17 +1,12 @@ include(../qsharedmemory/src/src.pri) -QT = core script -QT += core-private - -CONFIG += qtestlib +QT = core-private script testlib DESTDIR = ./ win32: CONFIG += console mac:CONFIG -= app_bundle -requires(contains(QT_CONFIG,script)) - DEFINES += QSHAREDMEMORY_DEBUG DEFINES += QSYSTEMSEMAPHORE_DEBUG diff --git a/tests/auto/uic/uic.pro b/tests/auto/uic/uic.pro index 355cb56cea2..00450154578 100644 --- a/tests/auto/uic/uic.pro +++ b/tests/auto/uic/uic.pro @@ -1,6 +1,5 @@ load(qttest_p4) -CONFIG += qtestlib SOURCES += tst_uic.cpp TARGET = tst_uic From 2f2ffed775300f3b3e1674a1c5d175a62f584ebf Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 27 May 2011 13:00:08 +1000 Subject: [PATCH 34/59] Make lexgen tests compile Correctly declare that the tests depend on the Qt build having testlib. Change-Id: Icf3332bc81a10e701316f1cd7021d2f6d3c2f424 Reviewed-on: http://codereview.qt.nokia.com/158 Reviewed-by: Rohan McGovern --- util/lexgen/tests/tests.pro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/lexgen/tests/tests.pro b/util/lexgen/tests/tests.pro index eb04439a13e..1a1e51d8c98 100644 --- a/util/lexgen/tests/tests.pro +++ b/util/lexgen/tests/tests.pro @@ -1,6 +1,5 @@ -CONFIG += qtestlib SOURCES += tst_lexgen.cpp TARGET = tst_lexgen include(../lexgen.pri) -QT = core +QT = core testlib DEFINES += SRCDIR=\\\"$$PWD\\\" From 6abf9093f75d11f120bd3b8569d2cc843c27c09f Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 27 May 2011 14:31:11 +1000 Subject: [PATCH 35/59] tests: fixed compilation of qstring benchmark on mac On Mac, MAP_ANONYMOUS and MAP_POPULATE are not defined. Fix MAP_ANONYMOUS by defining it to MAP_ANON. Fix MAP_POPULATE by removing it, because its usage was unnecessary in this code (the page was explicitly faulted in a few lines later anyway). Change-Id: Iead82e1a949b35fe3c304d38babac8d4dc6f0769 Reviewed-on: http://codereview.qt.nokia.com/162 Reviewed-by: Jason McDonald --- tests/benchmarks/corelib/tools/qstring/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp index d62cdac9bb4..95aaad3a25f 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/tools/qstring/main.cpp @@ -53,6 +53,11 @@ #include #endif +// MAP_ANON is deprecated on Linux, and MAP_ANONYMOUS is not present on Mac +#ifndef MAP_ANONYMOUS +# define MAP_ANONYMOUS MAP_ANON +#endif + #include #include "data.h" @@ -772,7 +777,7 @@ static void __attribute__((noinline)) equals2_selftest() void *page1, *page3; ushort *page2; page1 = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - page2 = (ushort *)mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0); + page2 = (ushort *)mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); page3 = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); Q_ASSERT(quintptr(page2) == quintptr(page1) + pagesize || quintptr(page2) == quintptr(page1) - pagesize); @@ -1329,7 +1334,7 @@ void tst_QString::ucstrncmp() const void *page1, *page3; ushort *page2; page1 = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - page2 = (ushort *)mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0); + page2 = (ushort *)mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); page3 = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); Q_ASSERT(quintptr(page2) == quintptr(page1) + pagesize || quintptr(page2) == quintptr(page1) - pagesize); From ddc9698079471ca9c6d43fe6f152446f53121046 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 27 May 2011 13:53:09 +1000 Subject: [PATCH 36/59] tests: fixed compile of tst_macgui This test uses private headers. Mark it as such. Change-Id: Icb6463629e1414b9da5403d0e0d766d8a113bd57 Reviewed-on: http://codereview.qt.nokia.com/160 Reviewed-by: Jason McDonald --- tests/auto/macgui/macgui.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/macgui/macgui.pro b/tests/auto/macgui/macgui.pro index 0ed2350a484..7e40d81808b 100644 --- a/tests/auto/macgui/macgui.pro +++ b/tests/auto/macgui/macgui.pro @@ -7,5 +7,7 @@ INCLUDEPATH += . SOURCES += tst_macgui.cpp guitest.cpp HEADERS += guitest.h +QT = core-private gui-private + requires(mac) From 750f995fb2e9e38f29e3ed0243b814b867d7d643 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 20 May 2011 11:07:06 +0200 Subject: [PATCH 37/59] Optimize QUuid::toString() and relevant QUuid::toString() and QUuid(const QString &) are too slow now. Task-number: QTBUG-19418 Reviewed-by: joao Reviewed-by: Denis Dzyubenko Reviewed-by: Ritt Konstantin Reviewed-by: Robin Burchell Reviewed-by: Richard J. Moore (cherry picked from commit 7ce566ed82666ac08f137f4d8590ce589d42c82a) Change-Id: I7e5bb4072f0941c20a7278a2d9766d4ef47be811 Reviewed-on: http://codereview.qt.nokia.com/166 Reviewed-by: Liang Qi --- src/corelib/plugin/quuid.cpp | 151 +++++++++++++++++++++++------------ src/corelib/plugin/quuid.h | 2 +- 2 files changed, 99 insertions(+), 54 deletions(-) diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 9cd353a7dab..7ef8522411a 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -42,9 +42,97 @@ #include "quuid.h" #include "qdatastream.h" +#include "qendian.h" QT_BEGIN_NAMESPACE +#ifndef QT_NO_QUUID_STRING +template +void _q_toHex(Char *&dst, Integral value) +{ + static const char digits[] = "0123456789abcdef"; + + if (sizeof(Integral) > 1) + value = qToBigEndian(value); + + const char* p = reinterpret_cast(&value); + + for (uint i = 0; i < sizeof(Integral); ++i, dst += 2) { + uint j = (p[i] >> 4) & 0xf; + dst[0] = Char(digits[j]); + j = p[i] & 0xf; + dst[1] = Char(digits[j]); + } +} + +template +bool _q_fromHex(const Char *&src, Integral &value) +{ + value = 0; + + for (uint i = 0; i < sizeof(Integral) * 2; ++i) { + int ch = *src++; + int tmp; + if (ch >= '0' && ch <= '9') + tmp = ch - '0'; + else if (ch >= 'a' && ch <= 'f') + tmp = ch - 'a' + 10; + else if (ch >= 'A' && ch <= 'F') + tmp = ch - 'A' + 10; + else + return false; + + value = value * 16 + tmp; + } + + return true; +} + +template +void _q_uuidToHex(Char *&dst, const uint &d1, const ushort &d2, const ushort &d3, const uchar (&d4)[8]) +{ + *dst++ = Char('{'); + _q_toHex(dst, d1); + *dst++ = Char('-'); + _q_toHex(dst, d2); + *dst++ = Char('-'); + _q_toHex(dst, d3); + *dst++ = Char('-'); + for (int i = 0; i < 2; i++) + _q_toHex(dst, d4[i]); + *dst++ = Char('-'); + for (int i = 2; i < 8; i++) + _q_toHex(dst, d4[i]); + *dst = Char('}'); +} + +template +bool _q_uuidFromHex(const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8]) +{ + if (*src == Char('{')) + src++; + if (!_q_fromHex(src, d1) + || *src++ != Char('-') + || !_q_fromHex(src, d2) + || *src++ != Char('-') + || !_q_fromHex(src, d3) + || *src++ != Char('-') + || !_q_fromHex(src, d4[0]) + || !_q_fromHex(src, d4[1]) + || *src++ != Char('-') + || !_q_fromHex(src, d4[2]) + || !_q_fromHex(src, d4[3]) + || !_q_fromHex(src, d4[4]) + || !_q_fromHex(src, d4[5]) + || !_q_fromHex(src, d4[6]) + || !_q_fromHex(src, d4[7])) { + return false; + } + + return true; +} +#endif + /*! \class QUuid \brief The QUuid class stores a Universally Unique Identifier (UUID). @@ -231,50 +319,22 @@ QT_BEGIN_NAMESPACE */ QUuid::QUuid(const QString &text) { - bool ok; - if (text.isEmpty()) { - *this = QUuid(); - return; - } - QString temp = text.toUpper(); - if (temp[0] != QLatin1Char('{')) - temp = QLatin1Char('{') + text; - if (text[(int)text.length()-1] != QLatin1Char('}')) - temp += QLatin1Char('}'); - - data1 = temp.mid(1, 8).toULongLong(&ok, 16); - if (!ok) { + if (text.length() < 36) { *this = QUuid(); return; } - data2 = temp.mid(10, 4).toUInt(&ok, 16); - if (!ok) { + const ushort *data = reinterpret_cast(text.unicode()); + + if (*data == '{' && text.length() < 37) { *this = QUuid(); return; } - data3 = temp.mid(15, 4).toUInt(&ok, 16); - if (!ok) { + + if (!_q_uuidFromHex(data, data1, data2, data3, data4)) { *this = QUuid(); return; } - data4[0] = temp.mid(20, 2).toUInt(&ok, 16); - if (!ok) { - *this = QUuid(); - return; - } - data4[1] = temp.mid(22, 2).toUInt(&ok, 16); - if (!ok) { - *this = QUuid(); - return; - } - for (int i = 2; i<8; i++) { - data4[i] = temp.mid(25 + (i-2)*2, 2).toUShort(&ok, 16); - if (!ok) { - *this = QUuid(); - return; - } - } } /*! @@ -308,11 +368,6 @@ QUuid::QUuid(const char *text) \sa toString() */ -static QString uuidhex(uint data, int digits) -{ - return QString::number(data, 16).rightJustified(digits, QLatin1Char('0')); -} - /*! Returns the string representation of this QUuid. The string is formatted as five hex fields separated by '-' and enclosed in @@ -349,22 +404,12 @@ static QString uuidhex(uint data, int digits) */ QString QUuid::toString() const { - QString result; + QString result(38, Qt::Uninitialized); + ushort *data = (ushort *)result.unicode(); - QChar dash = QLatin1Char('-'); - result = QLatin1Char('{') + uuidhex(data1,8); - result += dash; - result += uuidhex(data2,4); - result += dash; - result += uuidhex(data3,4); - result += dash; - result += uuidhex(data4[0],2); - result += uuidhex(data4[1],2); - result += dash; - for (int i = 2; i < 8; i++) - result += uuidhex(data4[i],2); + _q_uuidToHex(data, data1, data2, data3, data4); - return result + QLatin1Char('}'); + return result; } #endif diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index f42ca91270e..e9afacc560d 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -108,7 +108,7 @@ struct Q_CORE_EXPORT QUuid QUuid(const QString &); QUuid(const char *); QString toString() const; - operator QString() const { return toString(); } + operator QString() const { return toString(); } // ### Qt5 remove #endif bool isNull() const; From d6c9916fd157f0d3de5dbe17609177ee32e93488 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 20 May 2011 14:12:57 +0200 Subject: [PATCH 38/59] Add some autotests and benchmarks for QUuid Missing those functions for optimization. Reviewed-by: joao (cherry picked from commit 4e9286880fd2686e61de2c4be3c317e01f0d9989) Change-Id: I147e028f10cec7abc545dcbcca911d39a89d830e Reviewed-on: http://codereview.qt.nokia.com/165 Reviewed-by: Liang Qi --- tests/auto/quuid/tst_quuid.cpp | 65 +++++++++++++- .../corelib/plugin/quuid/tst_quuid.cpp | 89 +++++++++++++++++++ 2 files changed, 152 insertions(+), 2 deletions(-) diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index 6333e837d50..6e067b7d24c 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -60,7 +60,10 @@ public: tst_QUuid(); private slots: + void fromChar(); void toString(); + void fromString(); + void check_QDataStream(); void isNull(); void equal(); void notEqual(); @@ -83,16 +86,74 @@ public: tst_QUuid::tst_QUuid() { - uuidA = "{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; - uuidB = "{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; + //"{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; + uuidA = QUuid(0xfc69b59e, 0xcc34 ,0x4436 ,0xa4 ,0x3c ,0xee ,0x95 ,0xd1 ,0x28 ,0xb8 ,0xc5); + + //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; + uuidB = QUuid(0x1ab6e93a ,0xb1cb ,0x4a87 ,0xba ,0x47 ,0xec ,0x7e ,0x99 ,0x03 ,0x9a ,0x7b); } +void tst_QUuid::fromChar() +{ + QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")); + QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5")); + QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c")); + QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34")); + QCOMPARE(QUuid(), QUuid("fc69b59e-cc34-")); + QCOMPARE(QUuid(), QUuid("fc69b59e-cc34")); + QCOMPARE(QUuid(), QUuid("cc34")); + QCOMPARE(QUuid(), QUuid(NULL)); + + QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} void tst_QUuid::toString() { QCOMPARE(uuidA.toString(), QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + + QCOMPARE(uuidB.toString(), QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")); } +void tst_QUuid::fromString() +{ + QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(QUuid(), QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c"))); + + QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} + +void tst_QUuid::check_QDataStream() +{ + QUuid tmp; + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + out.setByteOrder(QDataStream::BigEndian); + out << uuidA; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + in.setByteOrder(QDataStream::BigEndian); + in >> tmp; + QCOMPARE(uuidA, tmp); + } + { + QDataStream out(&ar,QIODevice::WriteOnly); + out.setByteOrder(QDataStream::LittleEndian); + out << uuidA; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + in.setByteOrder(QDataStream::LittleEndian); + in >> tmp; + QCOMPARE(uuidA, tmp); + } +} void tst_QUuid::isNull() { diff --git a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp index dbec65ca420..61876e58166 100644 --- a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp @@ -53,6 +53,14 @@ public: private slots: void createUuid(); + void fromChar(); + void toString(); + void fromString(); + void toDataStream(); + void fromDataStream(); + void isNull(); + void operatorLess(); + void operatorMore(); }; void tst_bench_QUuid::createUuid() @@ -62,5 +70,86 @@ void tst_bench_QUuid::createUuid() } } +void tst_bench_QUuid::fromChar() +{ + QBENCHMARK { + QUuid uuid("{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"); + } +} + +void tst_bench_QUuid::toString() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toString(); + } +} + +void tst_bench_QUuid::fromString() +{ + QString string = "{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"; + QBENCHMARK { + QUuid uuid(string); + } +} + +void tst_bench_QUuid::toDataStream() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + QBENCHMARK { + out << uuid1; + } + } +} + +void tst_bench_QUuid::fromDataStream() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + out << uuid1; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + QBENCHMARK { + in >> uuid2; + } + } +} + +void tst_bench_QUuid::isNull() +{ + QUuid uuid = QUuid(); + QBENCHMARK { + uuid.isNull(); + } +} + +void tst_bench_QUuid::operatorLess() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + uuid2 = QUuid::createUuid(); + QBENCHMARK { + uuid1 < uuid2; + } +} + +void tst_bench_QUuid::operatorMore() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + uuid2 = QUuid::createUuid(); + QBENCHMARK { + uuid1 > uuid2; + } +} + QTEST_MAIN(tst_bench_QUuid); #include "tst_quuid.moc" From 40425ea53e2fafcfc3fe8357459da1a083660657 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 16 May 2011 10:48:05 +0200 Subject: [PATCH 39/59] Fix a regression in QList::mid() It doesn't need to copy anything when pos is after size(). Task-number: QTBUG-19164 Reviewed-by: Oswald Buddenhagen (cherry picked from commit 8befc4982a32752e48c82cacbed045e7336a3569) Change-Id: Iccac75842616f0d41e457e844a15d1a3ccfeb642 Reviewed-on: http://codereview.qt.nokia.com/164 Reviewed-by: Liang Qi --- src/corelib/tools/qlist.h | 2 ++ tests/auto/qlist/tst_qlist.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index e6f041fe3c2..4eb05d63b62 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -641,6 +641,8 @@ Q_OUTOFLINE_TEMPLATE QList QList::mid(int pos, int alength) const if (pos == 0 && alength == size()) return *this; QList cpy; + if (alength <= 0) + return cpy; cpy.reserve(alength); cpy.d->end = alength; QT_TRY { diff --git a/tests/auto/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp index 496f3d9170c..3901b6ffe85 100644 --- a/tests/auto/qlist/tst_qlist.cpp +++ b/tests/auto/qlist/tst_qlist.cpp @@ -200,6 +200,9 @@ void tst_QList::mid() const QCOMPARE(list.mid(3, 3), QList() << "bak" << "buck" << "hello"); + + QList list1; + QCOMPARE(list1.mid(1, 1).length(), 0); } void tst_QList::at() const From bf234e32887567caa27d9aa28aac3a12f09b5f19 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 25 May 2011 11:27:40 +0200 Subject: [PATCH 40/59] uic: Use QString::fromUtf8 for QUrl properties. As otherwise the compilation of ui_-files fails when using QT_NO_CAST_FROM_ASCII. Bug reported on mailing list. Reviewed-by: Jarek Kobus Change-Id: I00bf2e2605b97ff77efdcb68b7968375b3e9d195 (cherry picked from commit 00bf2e2605b97ff77efdcb68b7968375b3e9d195) Reviewed-on: http://codereview.qt.nokia.com/174 Reviewed-by: Friedemann Kleint --- src/tools/uic/cpp/cppwriteinitialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 8660991b17f..72da6db4577 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1452,7 +1452,7 @@ void WriteInitialization::writeProperties(const QString &varName, case DomProperty::Url: { const DomUrl* u = p->elementUrl(); - propertyValue = QString::fromLatin1("QUrl(%1)") + propertyValue = QString::fromLatin1("QUrl(QString::fromUtf8(%1))") .arg(fixString(u->elementString()->text(), m_dindent)); break; } From 4ace7475e7862bbe03e0d993f4675147ed28c972 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 23 May 2011 09:03:52 +0200 Subject: [PATCH 41/59] uic: #include for QToolBox on non-laid-out forms. for the fake tab-spacing property, which accesses the internal layout and sets its spacing. Task-number: QTBUG-19339 Reviewed-by: Jarek Kobus Change-Id: I89f5c035bd3798a0998c3046de643bda0fa8da6b (cherry picked from commit 89f5c035bd3798a0998c3046de643bda0fa8da6b) Reviewed-on: http://codereview.qt.nokia.com/173 Reviewed-by: Friedemann Kleint --- src/tools/uic/cpp/cppwriteincludes.cpp | 7 ++++++- src/tools/uic/cpp/cppwriteincludes.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 16a87c8d7be..c4613e20ae1 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -82,7 +82,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_scriptsActivated(false) + : m_uic(uic), m_output(uic->output()), m_scriptsActivated(false), m_laidOut(false) { // 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 @@ -106,6 +106,7 @@ WriteIncludes::WriteIncludes(Uic *uic) void WriteIncludes::acceptUI(DomUI *node) { m_scriptsActivated = false; + m_laidOut = false; m_localIncludes.clear(); m_globalIncludes.clear(); m_knownClasses.clear(); @@ -144,6 +145,7 @@ void WriteIncludes::acceptWidget(DomWidget *node) void WriteIncludes::acceptLayout(DomLayout *node) { add(node->attributeClass()); + m_laidOut = true; TreeWalker::acceptLayout(node); } @@ -220,6 +222,9 @@ void WriteIncludes::add(const QString &className, bool determineHeader, const QS m_knownClasses.insert(className); + if (!m_laidOut && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) + add(QLatin1String("QLayout")); // spacing property of QToolBox) + if (className == QLatin1String("Line")) { // ### hmm, deprecate me! add(QLatin1String("QFrame")); return; diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h index 39b1ddf897b..e8215364b95 100644 --- a/src/tools/uic/cpp/cppwriteincludes.h +++ b/src/tools/uic/cpp/cppwriteincludes.h @@ -107,6 +107,7 @@ private: StringMap m_oldHeaderToNewHeader; bool m_scriptsActivated; + bool m_laidOut; }; } // namespace CPP From fb214079bda2122878466db510fc7549065c3ae3 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 23 May 2011 09:27:23 +0200 Subject: [PATCH 42/59] Fix the build for QUuid Add a quint8 specialization for qbswap. Reviewed-by: Bradley T. Hughes (cherry picked from commit 32a583b575da1b387955734ccf36b0a93de37670) Change-Id: I7dae5e47565ed30de960983649e5c214e0303fe3 Reviewed-on: http://codereview.qt.nokia.com/171 Reviewed-by: Liang Qi --- src/corelib/global/qendian.h | 5 +++++ src/corelib/plugin/quuid.cpp | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 4e3f4e312fa..8a17af55f21 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -363,6 +363,11 @@ template inline void qToLittleEndian(T src, uchar *dest) #endif // Q_BYTE_ORDER == Q_BIG_ENDIAN +template <> inline quint8 qbswap(quint8 source) +{ + return source; +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 7ef8522411a..e99f87a86f5 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -52,8 +52,7 @@ void _q_toHex(Char *&dst, Integral value) { static const char digits[] = "0123456789abcdef"; - if (sizeof(Integral) > 1) - value = qToBigEndian(value); + value = qToBigEndian(value); const char* p = reinterpret_cast(&value); From ae0eb22591e7af6555d0cff39d63861a4fe4b890 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 20 May 2011 12:45:56 +0200 Subject: [PATCH 43/59] Optimize QUuid::QUuid(const char *) Reviewed-by: joao (cherry picked from commit 96d10abbb40c52ac6274f1144766f3fb27dfd726) Change-Id: I050b602b6cac669b4d88046b0a707048ce0a8cda Reviewed-on: http://codereview.qt.nokia.com/170 Reviewed-by: Liang Qi --- src/corelib/plugin/quuid.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index e99f87a86f5..63f6e045ead 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -341,7 +341,15 @@ QUuid::QUuid(const QString &text) */ QUuid::QUuid(const char *text) { - *this = QUuid(QString::fromLatin1(text)); + if (!text) { + *this = QUuid(); + return; + } + + if (!_q_uuidFromHex(text, data1, data2, data3, data4)) { + *this = QUuid(); + return; + } } #endif From c8888b518bd733778518e1643682f97bc7b28b64 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 20 May 2011 09:48:30 +0200 Subject: [PATCH 44/59] QDataStream: speedup steaming of QUuid. By reading and writing as a whole block, because the size of QUuid is fixed. Reviewed-by: joao (cherry picked from commit d56d7f107f9d18810d742ac4d3a2e36077722cb8) Change-Id: I90554d68da7394c99c48acd0bc5a0eee3b3f7776 Reviewed-on: http://codereview.qt.nokia.com/169 Reviewed-by: Liang Qi --- src/corelib/plugin/quuid.cpp | 64 ++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 63f6e045ead..796ee016023 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -427,11 +427,30 @@ QString QUuid::toString() const */ QDataStream &operator<<(QDataStream &s, const QUuid &id) { - s << (quint32)id.data1; - s << (quint16)id.data2; - s << (quint16)id.data3; - for (int i = 0; i < 8; i++) - s << (quint8)id.data4[i]; + QByteArray bytes; + if (s.byteOrder() == QDataStream::BigEndian) { + bytes = id.toRfc4122(); + } else { + // we know how many bytes a UUID has, I hope :) + bytes = QByteArray(16, Qt::Uninitialized); + uchar *data = reinterpret_cast(bytes.data()); + + qToLittleEndian(id.data1, data); + data += sizeof(quint32); + qToLittleEndian(id.data2, data); + data += sizeof(quint16); + qToLittleEndian(id.data3, data); + data += sizeof(quint16); + + for (int i = 0; i < 8; ++i) { + *(data) = id.data4[i]; + data++; + } + } + + if (s.writeRawData(bytes.data(), 16) != 16) { + s.setStatus(QDataStream::WriteFailed); + } return s; } @@ -441,19 +460,30 @@ QDataStream &operator<<(QDataStream &s, const QUuid &id) */ QDataStream &operator>>(QDataStream &s, QUuid &id) { - quint32 u32; - quint16 u16; - quint8 u8; - s >> u32; - id.data1 = u32; - s >> u16; - id.data2 = u16; - s >> u16; - id.data3 = u16; - for (int i = 0; i < 8; i++) { - s >> u8; - id.data4[i] = u8; + QByteArray bytes(16, Qt::Uninitialized); + if (s.readRawData(bytes.data(), 16) != 16) { + s.setStatus(QDataStream::ReadPastEnd); + return s; } + + if (s.byteOrder() == QDataStream::BigEndian) { + id = QUuid::fromRfc4122(bytes); + } else { + const uchar *data = reinterpret_cast(bytes.constData()); + + id.data1 = qFromLittleEndian(data); + data += sizeof(quint32); + id.data2 = qFromLittleEndian(data); + data += sizeof(quint16); + id.data3 = qFromLittleEndian(data); + data += sizeof(quint16); + + for (int i = 0; i < 8; ++i) { + id.data4[i] = *(data); + data++; + } + } + return s; } #endif // QT_NO_DATASTREAM From 8f4c007f85a4c16728281cb36f2f0f85b56c0999 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 20 May 2011 11:36:01 +0200 Subject: [PATCH 45/59] Add QUuid::toByteArray() and relevant Add QUuid::toByteArray() and QUuid(const QByteArray &). Same behavior with QUuid::toString() and QUuid(const QString &). Task-number: QTBUG-19419 Reviewed-by: joao (cherry picked from commit 71f923f29e2c60444a85fc765fc582e06cb7eca4) Change-Id: I41dad65e269f739ba9ec1c27e9da96af6401356c Reviewed-on: http://codereview.qt.nokia.com/167 Reviewed-by: Liang Qi --- src/corelib/plugin/quuid.cpp | 79 +++++++++++++++++++ src/corelib/plugin/quuid.h | 2 + tests/auto/quuid/tst_quuid.cpp | 20 +++++ .../corelib/plugin/quuid/tst_quuid.cpp | 18 +++++ 4 files changed, 119 insertions(+) diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 796ee016023..facd7326093 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -351,6 +351,39 @@ QUuid::QUuid(const char *text) return; } } + +/*! + Creates a QUuid object from the QByteArray \a text, which must be + formatted as five hex fields separated by '-', e.g., + "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' is a hex + digit. The curly braces shown here are optional, but it is normal to + include them. If the conversion fails, a null UUID is created. See + toByteArray() for an explanation of how the five hex fields map to the + public data members in QUuid. + + \since 4.8 + + \sa toByteArray(), QUuid() +*/ +QUuid::QUuid(const QByteArray &text) +{ + if (text.length() < 36) { + *this = QUuid(); + return; + } + + const char *data = text.constData(); + + if (*data == '{' && text.length() < 37) { + *this = QUuid(); + return; + } + + if (!_q_uuidFromHex(data, data1, data2, data3, data4)) { + *this = QUuid(); + return; + } +} #endif /*! @@ -418,6 +451,52 @@ QString QUuid::toString() const return result; } + +/*! + Returns the binary representation of this QUuid. The byte array is + formatted as five hex fields separated by '-' and enclosed in + curly braces, i.e., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where + 'x' is a hex digit. From left to right, the five hex fields are + obtained from the four public data members in QUuid as follows: + + \table + \header + \o Field # + \o Source + + \row + \o 1 + \o data1 + + \row + \o 2 + \o data2 + + \row + \o 3 + \o data3 + + \row + \o 4 + \o data4[0] .. data4[1] + + \row + \o 5 + \o data4[2] .. data4[7] + + \endtable + + \since 4.8 +*/ +QByteArray QUuid::toByteArray() const +{ + QByteArray result(38, Qt::Uninitialized); + char *data = result.data(); + + _q_uuidToHex(data, data1, data2, data3, data4); + + return result; +} #endif #ifndef QT_NO_DATASTREAM diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index e9afacc560d..69c4044e3ce 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -109,6 +109,8 @@ struct Q_CORE_EXPORT QUuid QUuid(const char *); QString toString() const; operator QString() const { return toString(); } // ### Qt5 remove + QUuid(const QByteArray &); + QByteArray toByteArray() const; #endif bool isNull() const; diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index 6e067b7d24c..3abc8af4c03 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -63,6 +63,8 @@ private slots: void fromChar(); void toString(); void fromString(); + void toByteArray(); + void fromByteArray(); void check_QDataStream(); void isNull(); void equal(); @@ -127,6 +129,24 @@ void tst_QUuid::fromString() QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); } +void tst_QUuid::toByteArray() +{ + QCOMPARE(uuidA.toByteArray(), QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + + QCOMPARE(uuidB.toByteArray(), QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")); +} + +void tst_QUuid::fromByteArray() +{ + QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c"))); + + QCOMPARE(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} + void tst_QUuid::check_QDataStream() { QUuid tmp; diff --git a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp index 61876e58166..24754ab3703 100644 --- a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp @@ -56,6 +56,8 @@ private slots: void fromChar(); void toString(); void fromString(); + void toByteArray(); + void fromByteArray(); void toDataStream(); void fromDataStream(); void isNull(); @@ -93,6 +95,22 @@ void tst_bench_QUuid::fromString() } } +void tst_bench_QUuid::toByteArray() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toByteArray(); + } +} + +void tst_bench_QUuid::fromByteArray() +{ + QByteArray string = "{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"; + QBENCHMARK { + QUuid uuid(string); + } +} + void tst_bench_QUuid::toDataStream() { QUuid uuid1, uuid2; From 623c753a7b6a582e352acc5a0abbb7eb402af3b7 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 27 May 2011 13:34:28 +0200 Subject: [PATCH 46/59] Add QUuid::toRfc4122() and fromRfc4122() Following the RFC4122, provide the interfaces between QUuid and QByteArray, they are simpler then toByteArray() and relevant. Thanks for the suggestion and brief code from Robin Burchell. Task-number: QTBUG-19420 Reviewed-by: joao (cherry picked from commit 06873e467d98ad60d827afae29500bf2ff783c03) Change-Id: I4623ae3363f1d5affa45de73fac616bb67a9eaa1 Reviewed-on: http://codereview.qt.nokia.com/168 Reviewed-by: Liang Qi --- src/corelib/plugin/quuid.cpp | 92 +++++++++++++++++++ src/corelib/plugin/quuid.h | 2 + tests/auto/quuid/tst_quuid.cpp | 16 ++++ .../corelib/plugin/quuid/tst_quuid.cpp | 18 ++++ 4 files changed, 128 insertions(+) diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index facd7326093..eb29e6eba8c 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -386,6 +386,45 @@ QUuid::QUuid(const QByteArray &text) } #endif +/*! + Creates a QUuid object from the binary representation of the UUID, as + specified by RFC 4122 section 4.1.2. See toRfc4122() for a further + explanation of the order of bytes required. + + The byte array accepted is NOT a human readable format. + + If the conversion fails, a null UUID is created. + + \since 4.8 + + \sa toRfc4122(), QUuid() +*/ +QUuid QUuid::fromRfc4122(const QByteArray &bytes) +{ + if (bytes.isEmpty() || bytes.length() != 16) + return QUuid(); + + uint d1; + ushort d2, d3; + uchar d4[8]; + + const uchar *data = reinterpret_cast(bytes.constData()); + + d1 = qFromBigEndian(data); + data += sizeof(quint32); + d2 = qFromBigEndian(data); + data += sizeof(quint16); + d3 = qFromBigEndian(data); + data += sizeof(quint16); + + for (int i = 0; i < 8; ++i) { + d4[i] = *(data); + data++; + } + + return QUuid(d1, d2, d3, d4[0], d4[1], d4[2], d4[3], d4[4], d4[5], d4[6], d4[7]); +} + /*! \fn bool QUuid::operator==(const QUuid &other) const @@ -499,6 +538,59 @@ QByteArray QUuid::toByteArray() const } #endif +/*! + Returns the binary representation of this QUuid. The byte array is in big + endian format, and formatted according to RFC 4122, section 4.1.2 - + "Layout and byte order". + + The order is as follows: + + \table + \header + \o Field # + \o Source + + \row + \o 1 + \o data1 + + \row + \o 2 + \o data2 + + \row + \o 3 + \o data3 + + \row + \o 4 + \o data4[0] .. data4[7] + + \endtable + + \since 4.8 +*/ +QByteArray QUuid::toRfc4122() const +{ + // we know how many bytes a UUID has, I hope :) + QByteArray bytes(16, Qt::Uninitialized); + uchar *data = reinterpret_cast(bytes.data()); + + qToBigEndian(data1, data); + data += sizeof(quint32); + qToBigEndian(data2, data); + data += sizeof(quint16); + qToBigEndian(data3, data); + data += sizeof(quint16); + + for (int i = 0; i < 8; ++i) { + *(data) = data4[i]; + data++; + } + + return bytes; +} + #ifndef QT_NO_DATASTREAM /*! \relates QUuid diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index 69c4044e3ce..832d5bc5c67 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -112,6 +112,8 @@ struct Q_CORE_EXPORT QUuid QUuid(const QByteArray &); QByteArray toByteArray() const; #endif + QByteArray toRfc4122() const; + static QUuid fromRfc4122(const QByteArray &); bool isNull() const; bool operator==(const QUuid &orig) const diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index 3abc8af4c03..4948312fd48 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -65,6 +65,8 @@ private slots: void fromString(); void toByteArray(); void fromByteArray(); + void toRfc4122(); + void fromRfc4122(); void check_QDataStream(); void isNull(); void equal(); @@ -147,6 +149,20 @@ void tst_QUuid::fromByteArray() QCOMPARE(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); } +void tst_QUuid::toRfc4122() +{ + QCOMPARE(uuidA.toRfc4122(), QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5")); + + QCOMPARE(uuidB.toRfc4122(), QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b")); +} + +void tst_QUuid::fromRfc4122() +{ + QCOMPARE(uuidA, QUuid::fromRfc4122(QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5"))); + + QCOMPARE(uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b"))); +} + void tst_QUuid::check_QDataStream() { QUuid tmp; diff --git a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp index 24754ab3703..a035cf36275 100644 --- a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp @@ -58,6 +58,8 @@ private slots: void fromString(); void toByteArray(); void fromByteArray(); + void toRfc4122(); + void fromRfc4122(); void toDataStream(); void fromDataStream(); void isNull(); @@ -111,6 +113,22 @@ void tst_bench_QUuid::fromByteArray() } } +void tst_bench_QUuid::toRfc4122() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toRfc4122(); + } +} + +void tst_bench_QUuid::fromRfc4122() +{ + QByteArray string = QByteArray::fromHex("67C8770B44F1410AAB9AF9B5446F13EE"); + QBENCHMARK { + QUuid uuid = QUuid::fromRfc4122(string); + } +} + void tst_bench_QUuid::toDataStream() { QUuid uuid1, uuid2; From 93339428c040a2576e4e0da315b1a6a4e4c1916f Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 27 May 2011 14:24:21 +0200 Subject: [PATCH 47/59] Fix compile for systems with old fontconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia26796bdbab7988d14163d3c1290111c0cb22bf7 Reviewed-on: http://codereview.qt.nokia.com/182 Reviewed-by: Samuel Rødal --- src/gui/text/qfontdatabase_x11.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index 8a13d91fbb6..a5fdcb52167 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1996,6 +1996,11 @@ void QFontDatabase::load(const QFontPrivate *d, int script) QFontCache::instance()->insertEngine(key, fe); } +// Needed for fontconfig version < 2.2.97 +#ifndef FC_FAMILYLANG +#define FC_FAMILYLANG "familylang" +#endif + static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) { #if defined(QT_NO_FONTCONFIG) From 37f20ea8e64afa2d29d9fb56ac34ff405367a2b8 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 20 May 2011 10:26:54 +0200 Subject: [PATCH 48/59] Fix ligature offset in multi-line text Reviewed-by: Eskil (cherry picked from commit 278cf1f37945050c4a46d5acab0659f3a7546a43) Change-Id: Ice20aa38a49ea16cf56bd3705c7d400ee165a9c2 Reviewed-on: http://codereview.qt.nokia.com/195 Reviewed-by: Jiang Jiang --- src/gui/text/qtextlayout.cpp | 4 ++-- tests/auto/qtextlayout/tst_qtextlayout.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 9e067d763f8..2e2a6234ae8 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2609,8 +2609,8 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const } else { bool rtl = eng->isRightToLeft(); bool visual = eng->visualCursorMovement(); + int end = qMin(lineEnd, si->position + l) - si->position; if (reverse) { - int end = qMin(lineEnd, si->position + l) - si->position; int glyph_end = end == l ? si->num_glyphs : logClusters[end]; int glyph_start = glyph_pos; if (visual && !rtl && !(lastLine && itm == (visualOrder[nItems - 1] + firstItem))) @@ -2626,7 +2626,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const for (int i = glyph_start; i <= glyph_end; i++) x += glyphs.effectiveAdvance(i); } - x += eng->offsetInLigature(si, pos, line.length, glyph_pos); + x += eng->offsetInLigature(si, pos, end, glyph_pos); } *cursorPos = pos + si->position; diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index b6adc2b8a05..be0a83fe38e 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -127,6 +127,7 @@ private slots: void textWithSurrogates_qtbug15679(); void textWidthWithStackedTextEngine(); void textWidthWithLineSeparator(); + void cursorInLigatureWithMultipleLines(); private: QFont testFont; @@ -1460,5 +1461,21 @@ void tst_QTextLayout::textWidthWithLineSeparator() QCOMPARE(line1.naturalTextWidth(), line2.naturalTextWidth()); } +void tst_QTextLayout::cursorInLigatureWithMultipleLines() +{ +#if !defined(Q_WS_MAC) + QSKIP("This test can not be run on Mac", SkipAll); +#endif + QTextLayout layout("first line finish", QFont("Times", 20)); + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(70); + line = layout.createLine(); + layout.endLayout(); + + // The second line will be "finish", with "fi" as a ligature + QVERIFY(line.cursorToX(0) != line.cursorToX(1)); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" From a4ecb10eff83747ed0fec220071d6649722dc1a7 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 27 May 2011 13:43:30 -0500 Subject: [PATCH 49/59] Only add dependent include when not already there Change-Id: I517ad8188a6f6b5ade763f0189f434f446ab6f05 Reviewed-on: http://codereview.qt.nokia.com/198 Reviewed-by: Marius Storm-Olsen --- mkspecs/features/qt.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index c611096147a..3791c9565a4 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -160,7 +160,7 @@ for(QTLIB, $$list($$lower($$unique(QT)))) { # add include paths for all .depends, since module/application might need f.ex. template specializations etc. QT_DEPENDS -= $$QT -for(QTLIB, $$list($$lower($$unique(QT_DEPENDS)))):INCLUDEPATH += $$INCLUDEPATH $$eval(QT.$${QTLIB}.includes) +for(QTLIB, $$list($$lower($$unique(QT_DEPENDS)))):INCLUDEPATH *= $$INCLUDEPATH $$eval(QT.$${QTLIB}.includes) !isEmpty(using_privates):!no_private_qt_headers_warning:if(!debug_and_release|!build_pass) { message("This project is using private headers and will therefore be tied to this specific Qt module build version.") From 9f837af9458ea4825b9a8061de444f62d8a7a048 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 19 May 2011 10:29:49 +0200 Subject: [PATCH 50/59] Support placing cursor in ligature with mouse or touch We need to find out the closest element in the ligature to the point we clicked (or tapped), currently we do this by dividing the width of that ligature glyph evenly by the number of characters it covered. We only support Common and Greek script at this point, ligatures in other scripts are still handled as a whole. Task-number: QTBUG-19260 Reviewed-by: Eskil (cherry picked from commit 5338d78aa9d80ddd2bcb21e6b22cd2cf1522a7d3) Change-Id: Ic747e9458d561aca0848dcd1e8b94e0a23fd8189 Reviewed-on: http://codereview.qt.nokia.com/196 Reviewed-by: Jiang Jiang --- src/gui/text/qtextengine.cpp | 69 ++++++++++++++++++++++ src/gui/text/qtextengine_p.h | 2 + src/gui/text/qtextlayout.cpp | 18 +++--- tests/auto/qtextlayout/tst_qtextlayout.cpp | 25 ++++++++ 4 files changed, 107 insertions(+), 7 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index b43c8f448bd..ad4f6d3fc68 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2825,6 +2825,75 @@ QFixed QTextEngine::offsetInLigature(const QScriptItem *si, int pos, int max, in return 0; } +// Scan in logClusters[from..to-1] for glyph_pos +int QTextEngine::getClusterLength(unsigned short *logClusters, + const HB_CharAttributes *attributes, + int from, int to, int glyph_pos, int *start) +{ + int clusterLength = 0; + for (int i = from; i < to; i++) { + if (logClusters[i] == glyph_pos && attributes[i].charStop) { + if (*start < 0) + *start = i; + clusterLength++; + } + else if (clusterLength) + break; + } + return clusterLength; +} + +int QTextEngine::positionInLigature(const QScriptItem *si, int end, + QFixed x, QFixed edge, int glyph_pos, + bool cursorOnCharacter) +{ + unsigned short *logClusters = this->logClusters(si); + int clusterStart = -1; + int clusterLength = 0; + + if (si->analysis.script != QUnicodeTables::Common && + si->analysis.script != QUnicodeTables::Greek) { + if (glyph_pos == -1) + return si->position + end; + else { + int i; + for (i = 0; i < end; i++) + if (logClusters[i] == glyph_pos) + break; + return si->position + i; + } + } + + if (glyph_pos == -1 && end > 0) + glyph_pos = logClusters[end - 1]; + else { + if (x <= edge) + glyph_pos--; + } + + const HB_CharAttributes *attrs = attributes(); + clusterLength = getClusterLength(logClusters, attrs, 0, end, glyph_pos, &clusterStart); + + if (clusterLength) { + const QGlyphLayout &glyphs = shapedGlyphs(si); + QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos); + // the approximate width of each individual element of the ligature + QFixed perItemWidth = glyphWidth / clusterLength; + QFixed left = x > edge ? edge : edge - glyphWidth; + int n = ((x - left) / perItemWidth).floor().toInt(); + QFixed dist = x - left - n * perItemWidth; + int closestItem = dist > (perItemWidth / 2) ? n + 1 : n; + if (cursorOnCharacter && closestItem > 0) + closestItem--; + int pos = si->position + clusterStart + closestItem; + // Jump to the next charStop + while (!attrs[pos].charStop && pos < end) + pos++; + return pos; + } + return si->position + end; +} + int QTextEngine::previousLogicalPosition(int oldPos) const { const HB_CharAttributes *attrs = attributes(); diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index ed24d5967b6..055974a4ada 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -620,6 +620,7 @@ public: QFixed leadingSpaceWidth(const QScriptLine &line); QFixed offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos); + int positionInLigature(const QScriptItem *si, int end, QFixed x, QFixed edge, int glyph_pos, bool cursorOnCharacter); int previousLogicalPosition(int oldPos) const; int nextLogicalPosition(int oldPos) const; int lineNumberForTextPosition(int pos); @@ -642,6 +643,7 @@ private: void resolveAdditionalFormats() const; int endOfLine(int lineNum); int beginningOfLine(int lineNum); + int getClusterLength(unsigned short *logClusters, const HB_CharAttributes *attributes, int from, int to, int glyph_pos, int *start); }; class QStackTextEngine : public QTextEngine { diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 2e2a6234ae8..add25cdad94 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2741,6 +2741,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const } int glyph_pos = -1; + QFixed edge; // has to be inside run if (cpos == QTextLine::CursorOnCharacter) { if (si.analysis.bidiLevel % 2) { @@ -2751,6 +2752,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const if (pos < x) break; glyph_pos = gs; + edge = pos; break; } pos -= glyphs.effectiveAdvance(gs); @@ -2763,6 +2765,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const if (pos > x) break; glyph_pos = gs; + edge = pos; } pos += glyphs.effectiveAdvance(gs); ++gs; @@ -2776,6 +2779,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const while (gs <= ge) { if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) { glyph_pos = gs; + edge = pos; dist = qAbs(x-pos); } pos -= glyphs.effectiveAdvance(gs); @@ -2785,6 +2789,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const while (ge >= gs) { if (glyphs.attributes[ge].clusterStart && qAbs(x-pos) < dist) { glyph_pos = ge; + edge = pos; dist = qAbs(x-pos); } pos += glyphs.effectiveAdvance(ge); @@ -2796,6 +2801,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const while (gs <= ge) { if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) { glyph_pos = gs; + edge = pos; dist = qAbs(x-pos); } pos += glyphs.effectiveAdvance(gs); @@ -2807,6 +2813,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const pos += glyphs.effectiveAdvance(gs); if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) { glyph_pos = gs; + edge = pos; dist = qAbs(x-pos); } ++gs; @@ -2823,16 +2830,13 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const if (rtl && nchars > 0) return insertionPoints[lastLine ? nchars : nchars - 1]; } - return si.position + end; + return eng->positionInLigature(&si, end, x, pos, -1, + cpos == QTextLine::CursorOnCharacter); } } Q_ASSERT(glyph_pos != -1); - int j; - for (j = 0; j < eng->length(item); ++j) - if (logClusters[j] == glyph_pos) - break; -// qDebug("at pos %d (in run: %d)", si.position + j, j); - return si.position + j; + return eng->positionInLigature(&si, end, x, edge, glyph_pos, + cpos == QTextLine::CursorOnCharacter); } } // right of last item diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index be0a83fe38e..2414ab3e378 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -128,6 +128,7 @@ private slots: void textWidthWithStackedTextEngine(); void textWidthWithLineSeparator(); void cursorInLigatureWithMultipleLines(); + void xToCursorForLigatures(); private: QFont testFont; @@ -1477,5 +1478,29 @@ void tst_QTextLayout::cursorInLigatureWithMultipleLines() QVERIFY(line.cursorToX(0) != line.cursorToX(1)); } +void tst_QTextLayout::xToCursorForLigatures() +{ +#if !defined(Q_WS_MAC) + QSKIP("This test can not be run on Mac", SkipAll); +#endif + QTextLayout layout("fi", QFont("Times", 20)); + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + QVERIFY(line.xToCursor(0) != line.xToCursor(line.naturalTextWidth() / 2)); + + // U+0061 U+0308 + QTextLayout layout2(QString::fromUtf8("\x61\xCC\x88"), QFont("Times", 20)); + + layout2.beginLayout(); + line = layout2.createLine(); + layout2.endLayout(); + + qreal width = line.naturalTextWidth(); + QVERIFY(line.xToCursor(0) == line.xToCursor(width / 2) || + line.xToCursor(width) == line.xToCursor(width / 2)); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" From 8ff3028e2354a32908c3dd03b330b5734e15630e Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 30 May 2011 15:33:21 +0200 Subject: [PATCH 51/59] Export the qt_gl_read_framebuffer function for use in declarative MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia1dd186ca954774e1faaa4b2e606acac9333d9b0 Reviewed-on: http://codereview.qt.nokia.com/224 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/opengl/qgl.cpp | 2 +- src/opengl/qglframebufferobject.cpp | 2 +- src/opengl/qglpixelbuffer.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 61ccce117b6..f1fb2b4e7f6 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1795,7 +1795,7 @@ static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, boo img = img.mirrored(); } -QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) +Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) { QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 0af8108f03d..682c26255d1 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); +extern Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize&, bool, bool); #define QGL_FUNC_CONTEXT const QGLContext *ctx = d_ptr->fbo_guard.context(); #define QGL_FUNCP_CONTEXT const QGLContext *ctx = fbo_guard.context(); diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 3afb3b1faed..45e7cdd8750 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -113,7 +113,7 @@ extern void qgl_cleanup_glyph_cache(QGLContext *); void qgl_cleanup_glyph_cache(QGLContext *) {} #endif -extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); +extern Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize&, bool, bool); QGLContext* QGLPBufferGLPaintDevice::context() const From a3146bb75fad0297b9e4056883d44ae218286a00 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Fri, 27 May 2011 14:43:13 +1000 Subject: [PATCH 52/59] Fixed linking against QtQuickTest on mac. qmltest is now a Qt module, so it's not necessary to configure the include&library paths manually. Change-Id: I1d2baa67138e08ab9007fba9f6adcf8847509ba8 Reviewed-on: http://codereview.qt.nokia.com/163 Reviewed-by: Rohan McGovern Reviewed-by: Qt Sanity Bot --- mkspecs/features/qmltestcase.prf | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/mkspecs/features/qmltestcase.prf b/mkspecs/features/qmltestcase.prf index a3d66e659e7..5e60185493a 100644 --- a/mkspecs/features/qmltestcase.prf +++ b/mkspecs/features/qmltestcase.prf @@ -1,20 +1,6 @@ CONFIG += testcase -!symbian { - INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtQuickTest -} else { - load(data_caging_paths) - - INCLUDEPATH+=$$MW_LAYER_PUBLIC_EXPORT_PATH(QtQuickTest) -} - -QT += declarative - -win32:CONFIG(debug, debug|release) { - LIBS += -lQtQuickTest$${QT_LIBINFIX}d -} else { - LIBS += -lQtQuickTest$${QT_LIBINFIX} -} +QT += declarative qmltest # If the .pro file specified an IMPORTPATH, then add that to # the command-line when the test is run. From 0b2ce8520020a0db9b5b5feb5e72f64518d3eea5 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 27 May 2011 15:36:22 +0200 Subject: [PATCH 53/59] Moved certain qmake config variables to .qmake.cache. The reason is that these are local to the build, and should not be present inside the qmodule.pri file, because this file is installed. Change-Id: I2207f2bf068b1aafd14e60d106c7028ca53d5efd Task: QTBUG-19585 Reviewed-on: http://codereview.qt.nokia.com/238 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- configure | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/configure b/configure index 759186b4ca9..6124d6d8a53 100755 --- a/configure +++ b/configure @@ -8472,22 +8472,6 @@ fi #------------------------------------------------------------------------------- QTMODULE="$outpath/mkspecs/qmodule.pri" -cat >>"$QTMODULE.tmp" <> "$QTMODULE.tmp" @@ -8538,13 +8522,6 @@ if [ "$CFG_MAC_XARCH" = "no" ]; then echo "QMAKE_MAC_XARCH = no" >> "$QTMODULE.tmp" fi -#dump the qmake spec -if [ -d "$outpath/mkspecs/$XPLATFORM" ]; then - echo "QMAKESPEC = \$\$QT_BUILD_TREE/mkspecs/$XPLATFORM" >> "$QTMODULE.tmp" -else - echo "QMAKESPEC = $XPLATFORM" >> "$QTMODULE.tmp" -fi - # cmdline args cat "$QMAKE_VARS_FILE" >> "$QTMODULE.tmp" rm -f "$QMAKE_VARS_FILE" 2>/dev/null @@ -8563,6 +8540,19 @@ fi CACHEFILE="$outpath/.qmake.cache" [ -f "$CACHEFILE.tmp" ] && rm -f "$CACHEFILE.tmp" cat >>"$CACHEFILE.tmp" <> "$CACHEFILE.tmp" +else + echo "QMAKESPEC = $XPLATFORM" >> "$CACHEFILE.tmp" +fi + # incrementals INCREMENTAL="" [ "$CFG_INCREMENTAL" = "auto" ] && "$WHICH" p4 >/dev/null 2>&1 && [ "$CFG_DEV" = "yes" ] && CFG_INCREMENTAL="yes" From a8814fcb697893f6ab151342727ea0867f6fec21 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 27 May 2011 10:10:36 +0200 Subject: [PATCH 54/59] Made qpluginbase.pri into a feature profile. This enables other modules to use it without having access to the QtBase sources. Change-Id: I0a588b2e14ca88fa068c7c2bcc69ff669444f6c6 Task: QTBUG-19585 Reviewed-on: http://codereview.qt.nokia.com/237 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- mkspecs/features/qt_plugin.prf | 41 ++++++++++++++++++ src/plugins/accessible/widgets/widgets.pro | 2 +- src/plugins/bearer/connman/connman.pro | 2 +- src/plugins/bearer/corewlan/corewlan.pro | 2 +- src/plugins/bearer/generic/generic.pro | 2 +- src/plugins/bearer/icd/icd.pro | 2 +- src/plugins/bearer/nativewifi/nativewifi.pro | 2 +- .../bearer/networkmanager/networkmanager.pro | 2 +- src/plugins/bearer/nla/nla.pro | 2 +- src/plugins/bearer/symbian/symbian.pri | 2 +- src/plugins/codecs/cn/cn.pro | 2 +- src/plugins/codecs/jp/jp.pro | 2 +- src/plugins/codecs/kr/kr.pro | 2 +- src/plugins/codecs/tw/tw.pro | 2 +- src/plugins/decorations/default/default.pro | 2 +- src/plugins/decorations/styled/styled.pro | 2 +- src/plugins/decorations/windows/windows.pro | 2 +- src/plugins/generic/linuxinput/linuxinput.pro | 2 +- src/plugins/generic/tslib/tslib.pro | 2 +- src/plugins/gfxdrivers/ahi/ahi.pro | 2 +- src/plugins/gfxdrivers/directfb/directfb.pro | 2 +- .../gfxdrivers/eglnullws/eglnullws.pro | 2 +- src/plugins/gfxdrivers/linuxfb/linuxfb.pro | 2 +- src/plugins/gfxdrivers/qvfb/qvfb.pro | 2 +- .../gfxdrivers/transformed/transformed.pro | 2 +- src/plugins/gfxdrivers/vnc/vnc.pro | 2 +- src/plugins/graphicssystems/meego/meego.pro | 2 +- src/plugins/graphicssystems/opengl/opengl.pro | 2 +- src/plugins/graphicssystems/openvg/openvg.pro | 2 +- .../graphicssystems/shivavg/shivavg.pro | 2 +- src/plugins/graphicssystems/trace/trace.pro | 2 +- src/plugins/imageformats/gif/gif.pro | 2 +- src/plugins/imageformats/ico/ico.pro | 2 +- src/plugins/imageformats/jpeg/jpeg.pro | 2 +- src/plugins/imageformats/mng/mng.pro | 2 +- src/plugins/imageformats/tiff/tiff.pro | 2 +- .../inputmethods/imsw-multi/imsw-multi.pro | 2 +- .../kbddrivers/linuxinput/linuxinput.pro | 2 +- src/plugins/mousedrivers/linuxtp/linuxtp.pro | 2 +- src/plugins/mousedrivers/pc/pc.pro | 2 +- src/plugins/mousedrivers/tslib/tslib.pro | 2 +- src/plugins/platforms/cocoa/cocoa.pro | 2 +- src/plugins/platforms/directfb/directfb.pro | 2 +- src/plugins/platforms/externalplugin.pri | 2 +- src/plugins/platforms/fb_base/fb_base.pro | 2 +- src/plugins/platforms/linuxfb/linuxfb.pro | 2 +- src/plugins/platforms/minimal/minimal.pro | 2 +- src/plugins/platforms/openkode/openkode.pro | 2 +- .../platforms/openvglite/openvglite.pro | 2 +- src/plugins/platforms/qvfb/qvfb.pro | 2 +- src/plugins/platforms/uikit/uikit.pro | 2 +- src/plugins/platforms/vnc/vnc.pro | 2 +- src/plugins/platforms/wayland/wayland.pro | 2 +- src/plugins/platforms/xcb/xcb.pro | 2 +- src/plugins/platforms/xlib/xlib.pro | 2 +- src/plugins/qpluginbase.pri | 42 +------------------ src/plugins/s60/s60pluginbase.pri | 2 +- src/plugins/sqldrivers/qsqldriverbase.pri | 2 +- 58 files changed, 98 insertions(+), 97 deletions(-) create mode 100644 mkspecs/features/qt_plugin.prf diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf new file mode 100644 index 00000000000..c4eaab8147f --- /dev/null +++ b/mkspecs/features/qt_plugin.prf @@ -0,0 +1,41 @@ +TEMPLATE = lib +isEmpty(QT_MAJOR_VERSION) { + VERSION=5.0.0 +} else { + VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} +} +CONFIG += qt plugin + +win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release +TARGET = $$qtLibraryTarget($$TARGET) +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols + +load(qt_targets) + +wince*:LIBS += $$QMAKE_LIBS_GUI + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY = All -Tcb + TARGET = $${TARGET}$${QT_LIBINFIX} + load(armcc_warnings) + + # Make partial upgrade SIS file for Qt plugin dll's + # Partial upgrade SIS file + vendorinfo = \ + "; Localised Vendor name" \ + "%{\"Nokia\"}" \ + " " \ + "; Unique Vendor name" \ + ":\"Nokia, Qt\"" \ + " " + isEmpty(QT_LIBINFIX): PARTIAL_UPGRADE_UID = 0x2001E61C + else: PARTIAL_UPGRADE_UID = 0xE001E61C + + pu_header = "; Partial upgrade package for testing $${TARGET} changes without reinstalling everything" \ + "$${LITERAL_HASH}{\"$${TARGET}\"}, ($$PARTIAL_UPGRADE_UID), $${QT_MAJOR_VERSION},$${QT_MINOR_VERSION},$${QT_PATCH_VERSION}, TYPE=PU" + partial_upgrade.pkg_prerules = pu_header vendorinfo + partial_upgrade.files = $$QMAKE_LIBDIR_QT/$${TARGET}.dll + partial_upgrade.path = c:/sys/bin + DEPLOYMENT += partial_upgrade +} diff --git a/src/plugins/accessible/widgets/widgets.pro b/src/plugins/accessible/widgets/widgets.pro index 8329bce963d..00d99f94e73 100644 --- a/src/plugins/accessible/widgets/widgets.pro +++ b/src/plugins/accessible/widgets/widgets.pro @@ -1,5 +1,5 @@ TARGET = qtaccessiblewidgets -include(../../qpluginbase.pri) +load(qt_plugin) include (../qaccessiblebase.pri) QT += core-private gui-private diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro index f57a0c930bd..25243f8e0a0 100644 --- a/src/plugins/bearer/connman/connman.pro +++ b/src/plugins/bearer/connman/connman.pro @@ -1,5 +1,5 @@ TARGET = qconnmanbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network-private dbus diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro index adc1625c3d0..0d11b1e9d38 100644 --- a/src/plugins/bearer/corewlan/corewlan.pro +++ b/src/plugins/bearer/corewlan/corewlan.pro @@ -1,5 +1,5 @@ TARGET = qcorewlanbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core-private network-private LIBS += -framework Foundation -framework SystemConfiguration diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro index 94fefaf6c29..4f86c2a38c1 100644 --- a/src/plugins/bearer/generic/generic.pro +++ b/src/plugins/bearer/generic/generic.pro @@ -1,5 +1,5 @@ TARGET = qgenericbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core-private network-private diff --git a/src/plugins/bearer/icd/icd.pro b/src/plugins/bearer/icd/icd.pro index 4737045ae77..3f5753409d5 100644 --- a/src/plugins/bearer/icd/icd.pro +++ b/src/plugins/bearer/icd/icd.pro @@ -1,5 +1,5 @@ TARGET = qicdbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network dbus diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro index ba02f37d23f..ec86cc0b939 100644 --- a/src/plugins/bearer/nativewifi/nativewifi.pro +++ b/src/plugins/bearer/nativewifi/nativewifi.pro @@ -1,5 +1,5 @@ TARGET = qnativewifibearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core-private network-private diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro index a9de1561fdc..262f60a69c6 100644 --- a/src/plugins/bearer/networkmanager/networkmanager.pro +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -1,5 +1,5 @@ TARGET = qnmbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network-private dbus diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro index ecf958f559f..76da098dbf7 100644 --- a/src/plugins/bearer/nla/nla.pro +++ b/src/plugins/bearer/nla/nla.pro @@ -1,5 +1,5 @@ TARGET = qnlabearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network diff --git a/src/plugins/bearer/symbian/symbian.pri b/src/plugins/bearer/symbian/symbian.pri index 5d2ae1a5cda..c4b3c6d09d8 100644 --- a/src/plugins/bearer/symbian/symbian.pri +++ b/src/plugins/bearer/symbian/symbian.pri @@ -1,5 +1,5 @@ TARGET = qsymbianbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network diff --git a/src/plugins/codecs/cn/cn.pro b/src/plugins/codecs/cn/cn.pro index 51a2f413728..fc2e94b5a63 100644 --- a/src/plugins/codecs/cn/cn.pro +++ b/src/plugins/codecs/cn/cn.pro @@ -1,5 +1,5 @@ TARGET = qcncodecs -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.core.plugins/codecs diff --git a/src/plugins/codecs/jp/jp.pro b/src/plugins/codecs/jp/jp.pro index e6b7a4bb7f1..834ca31ad6a 100644 --- a/src/plugins/codecs/jp/jp.pro +++ b/src/plugins/codecs/jp/jp.pro @@ -1,5 +1,5 @@ TARGET = qjpcodecs -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.core.plugins/codecs diff --git a/src/plugins/codecs/kr/kr.pro b/src/plugins/codecs/kr/kr.pro index 14c162c6e85..f5aea6554f2 100644 --- a/src/plugins/codecs/kr/kr.pro +++ b/src/plugins/codecs/kr/kr.pro @@ -1,5 +1,5 @@ TARGET = qkrcodecs -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.core.plugins/codecs diff --git a/src/plugins/codecs/tw/tw.pro b/src/plugins/codecs/tw/tw.pro index b0d5a2b68a2..f76cba4dbc3 100644 --- a/src/plugins/codecs/tw/tw.pro +++ b/src/plugins/codecs/tw/tw.pro @@ -1,5 +1,5 @@ TARGET = qtwcodecs -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.core.plugins/codecs diff --git a/src/plugins/decorations/default/default.pro b/src/plugins/decorations/default/default.pro index a30899a62b0..c323d109303 100644 --- a/src/plugins/decorations/default/default.pro +++ b/src/plugins/decorations/default/default.pro @@ -1,5 +1,5 @@ TARGET = qdecorationdefault -include(../../qpluginbase.pri) +load(qt_plugin) HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qdecorationdefault_qws.h SOURCES = main.cpp \ diff --git a/src/plugins/decorations/styled/styled.pro b/src/plugins/decorations/styled/styled.pro index 151ef881788..c5329aea291 100644 --- a/src/plugins/decorations/styled/styled.pro +++ b/src/plugins/decorations/styled/styled.pro @@ -1,5 +1,5 @@ TARGET = qdecorationstyled -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/decorations target.path += $$[QT_INSTALL_PLUGINS]/decorations diff --git a/src/plugins/decorations/windows/windows.pro b/src/plugins/decorations/windows/windows.pro index 7f788a3d7ed..f27adb908b0 100644 --- a/src/plugins/decorations/windows/windows.pro +++ b/src/plugins/decorations/windows/windows.pro @@ -1,5 +1,5 @@ TARGET = qdecorationwindows -include(../../qpluginbase.pri) +load(qt_plugin) HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qdecorationwindows_qws.h SOURCES = main.cpp \ diff --git a/src/plugins/generic/linuxinput/linuxinput.pro b/src/plugins/generic/linuxinput/linuxinput.pro index d4dc4bbbcbc..a771ee9734a 100644 --- a/src/plugins/generic/linuxinput/linuxinput.pro +++ b/src/plugins/generic/linuxinput/linuxinput.pro @@ -1,5 +1,5 @@ TARGET = qlinuxinputplugin -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/generic target.path = $$[QT_INSTALL_PLUGINS]/generic diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro index 485152181c7..d9726b6d3a4 100644 --- a/src/plugins/generic/tslib/tslib.pro +++ b/src/plugins/generic/tslib/tslib.pro @@ -1,5 +1,5 @@ TARGET = qlinuxinputplugin -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/generic target.path = $$[QT_INSTALL_PLUGINS]/generic diff --git a/src/plugins/gfxdrivers/ahi/ahi.pro b/src/plugins/gfxdrivers/ahi/ahi.pro index 3abe2a76cc8..fd078421f94 100644 --- a/src/plugins/gfxdrivers/ahi/ahi.pro +++ b/src/plugins/gfxdrivers/ahi/ahi.pro @@ -1,5 +1,5 @@ TARGET = qahiscreen -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/gfxdrivers diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index 54d11ca1599..6fb2a0f9aa6 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -1,5 +1,5 @@ TARGET = qdirectfbscreen -include(../../qpluginbase.pri) +load(qt_plugin) include($$QT_SOURCE_TREE/src/gui/embedded/directfb.pri) DESTDIR = $$QT.gui.plugins/gfxdrivers diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullws.pro b/src/plugins/gfxdrivers/eglnullws/eglnullws.pro index 30cebab41ac..cb65c2b6279 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullws.pro +++ b/src/plugins/gfxdrivers/eglnullws/eglnullws.pro @@ -1,5 +1,5 @@ TARGET = qeglnullws -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on QT += opengl diff --git a/src/plugins/gfxdrivers/linuxfb/linuxfb.pro b/src/plugins/gfxdrivers/linuxfb/linuxfb.pro index c1cdc0eda73..2bbe910e639 100644 --- a/src/plugins/gfxdrivers/linuxfb/linuxfb.pro +++ b/src/plugins/gfxdrivers/linuxfb/linuxfb.pro @@ -1,5 +1,5 @@ TARGET = qscreenlinuxfb -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/gfxdrivers diff --git a/src/plugins/gfxdrivers/qvfb/qvfb.pro b/src/plugins/gfxdrivers/qvfb/qvfb.pro index e45319db875..99376be81c1 100644 --- a/src/plugins/gfxdrivers/qvfb/qvfb.pro +++ b/src/plugins/gfxdrivers/qvfb/qvfb.pro @@ -1,5 +1,5 @@ TARGET = qscreenvfb -include(../../qpluginbase.pri) +load(qt_plugin) DEFINES += QT_QWS_QVFB QT_QWS_MOUSE_QVFB QT_QWS_KBD_QVFB diff --git a/src/plugins/gfxdrivers/transformed/transformed.pro b/src/plugins/gfxdrivers/transformed/transformed.pro index f6e07704b39..f97713fc38b 100644 --- a/src/plugins/gfxdrivers/transformed/transformed.pro +++ b/src/plugins/gfxdrivers/transformed/transformed.pro @@ -1,5 +1,5 @@ TARGET = qgfxtransformed -include(../../qpluginbase.pri) +load(qt_plugin) DEFINES += QT_QWS_TRANSFORMED diff --git a/src/plugins/gfxdrivers/vnc/vnc.pro b/src/plugins/gfxdrivers/vnc/vnc.pro index 48bad8c6e39..95e2ba7cf8c 100644 --- a/src/plugins/gfxdrivers/vnc/vnc.pro +++ b/src/plugins/gfxdrivers/vnc/vnc.pro @@ -1,5 +1,5 @@ TARGET = qgfxvnc -include(../../qpluginbase.pri) +load(qt_plugin) DEFINES += QT_QWS_VNC diff --git a/src/plugins/graphicssystems/meego/meego.pro b/src/plugins/graphicssystems/meego/meego.pro index c497ba2eb68..5c650eef2eb 100644 --- a/src/plugins/graphicssystems/meego/meego.pro +++ b/src/plugins/graphicssystems/meego/meego.pro @@ -1,5 +1,5 @@ TARGET = qmeegographicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += gui opengl diff --git a/src/plugins/graphicssystems/opengl/opengl.pro b/src/plugins/graphicssystems/opengl/opengl.pro index 30c88271b69..fd3542ecf0b 100644 --- a/src/plugins/graphicssystems/opengl/opengl.pro +++ b/src/plugins/graphicssystems/opengl/opengl.pro @@ -1,5 +1,5 @@ TARGET = qglgraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += core-private gui-private opengl-private diff --git a/src/plugins/graphicssystems/openvg/openvg.pro b/src/plugins/graphicssystems/openvg/openvg.pro index 6f8b13907a9..6a737790a2f 100644 --- a/src/plugins/graphicssystems/openvg/openvg.pro +++ b/src/plugins/graphicssystems/openvg/openvg.pro @@ -1,5 +1,5 @@ TARGET = qvggraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += openvg diff --git a/src/plugins/graphicssystems/shivavg/shivavg.pro b/src/plugins/graphicssystems/shivavg/shivavg.pro index 6bf9d7a975c..1d934cd685a 100644 --- a/src/plugins/graphicssystems/shivavg/shivavg.pro +++ b/src/plugins/graphicssystems/shivavg/shivavg.pro @@ -1,5 +1,5 @@ TARGET = qshivavggraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += openvg diff --git a/src/plugins/graphicssystems/trace/trace.pro b/src/plugins/graphicssystems/trace/trace.pro index b31beb35f82..f44bb3211eb 100644 --- a/src/plugins/graphicssystems/trace/trace.pro +++ b/src/plugins/graphicssystems/trace/trace.pro @@ -1,5 +1,5 @@ TARGET = qtracegraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += core-private gui-private network diff --git a/src/plugins/imageformats/gif/gif.pro b/src/plugins/imageformats/gif/gif.pro index 4b72cae6e49..b8d260e43ce 100644 --- a/src/plugins/imageformats/gif/gif.pro +++ b/src/plugins/imageformats/gif/gif.pro @@ -1,5 +1,5 @@ TARGET = qgif -include(../../qpluginbase.pri) +load(qt_plugin) include(../../../gui/image/qgifhandler.pri) SOURCES += $$PWD/main.cpp diff --git a/src/plugins/imageformats/ico/ico.pro b/src/plugins/imageformats/ico/ico.pro index cef92cedc89..e0109c6a322 100644 --- a/src/plugins/imageformats/ico/ico.pro +++ b/src/plugins/imageformats/ico/ico.pro @@ -1,5 +1,5 @@ TARGET = qico -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-ico)" diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro index 1e6c24d061c..aa489729a10 100644 --- a/src/plugins/imageformats/jpeg/jpeg.pro +++ b/src/plugins/imageformats/jpeg/jpeg.pro @@ -1,5 +1,5 @@ TARGET = qjpeg -include(../../qpluginbase.pri) +load(qt_plugin) QT += core-private diff --git a/src/plugins/imageformats/mng/mng.pro b/src/plugins/imageformats/mng/mng.pro index 01dc418c1b6..72dc506cf9a 100644 --- a/src/plugins/imageformats/mng/mng.pro +++ b/src/plugins/imageformats/mng/mng.pro @@ -1,5 +1,5 @@ TARGET = qmng -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-mng)" diff --git a/src/plugins/imageformats/tiff/tiff.pro b/src/plugins/imageformats/tiff/tiff.pro index e4eb21b1e7d..012c49ecf13 100644 --- a/src/plugins/imageformats/tiff/tiff.pro +++ b/src/plugins/imageformats/tiff/tiff.pro @@ -1,5 +1,5 @@ TARGET = qtiff -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-tiff)" diff --git a/src/plugins/inputmethods/imsw-multi/imsw-multi.pro b/src/plugins/inputmethods/imsw-multi/imsw-multi.pro index 5d0535f3ac0..4c7b9b96d81 100644 --- a/src/plugins/inputmethods/imsw-multi/imsw-multi.pro +++ b/src/plugins/inputmethods/imsw-multi/imsw-multi.pro @@ -1,5 +1,5 @@ TARGET = qimsw-multi -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.gui.plugins/inputmethods diff --git a/src/plugins/kbddrivers/linuxinput/linuxinput.pro b/src/plugins/kbddrivers/linuxinput/linuxinput.pro index c0af91c7f0f..8eaa786ce04 100644 --- a/src/plugins/kbddrivers/linuxinput/linuxinput.pro +++ b/src/plugins/kbddrivers/linuxinput/linuxinput.pro @@ -1,5 +1,5 @@ TARGET = qlinuxinputkbddriver -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/kbddrivers target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers diff --git a/src/plugins/mousedrivers/linuxtp/linuxtp.pro b/src/plugins/mousedrivers/linuxtp/linuxtp.pro index b8e26b4483b..e5d274a0b75 100644 --- a/src/plugins/mousedrivers/linuxtp/linuxtp.pro +++ b/src/plugins/mousedrivers/linuxtp/linuxtp.pro @@ -1,5 +1,5 @@ TARGET = qlinuxtpmousedriver -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/mousedrivers target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers diff --git a/src/plugins/mousedrivers/pc/pc.pro b/src/plugins/mousedrivers/pc/pc.pro index d38e3fe5d11..04d7b0f06fa 100644 --- a/src/plugins/mousedrivers/pc/pc.pro +++ b/src/plugins/mousedrivers/pc/pc.pro @@ -1,5 +1,5 @@ TARGET = qpcmousedriver -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/mousedrivers target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers diff --git a/src/plugins/mousedrivers/tslib/tslib.pro b/src/plugins/mousedrivers/tslib/tslib.pro index e2fa013fdb5..552a2e71733 100644 --- a/src/plugins/mousedrivers/tslib/tslib.pro +++ b/src/plugins/mousedrivers/tslib/tslib.pro @@ -1,5 +1,5 @@ TARGET = qtslibmousedriver -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/mousedrivers diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 705e60439e9..bfa147f9481 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -1,5 +1,5 @@ TARGET = qcocoa -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms OBJECTIVE_SOURCES = main.mm \ diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index 4a637463eff..f830177dcb4 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -1,5 +1,5 @@ TARGET = qdirectfb -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms isEmpty(DIRECTFB_LIBS) { diff --git a/src/plugins/platforms/externalplugin.pri b/src/plugins/platforms/externalplugin.pri index 54da4d957c8..9b00acb4e95 100644 --- a/src/plugins/platforms/externalplugin.pri +++ b/src/plugins/platforms/externalplugin.pri @@ -26,4 +26,4 @@ QT_SOURCE_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_SOURCE_TREE) QT_BUILD_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_BUILD_TREE) -include($$QT_SOURCE_TREE/src/plugins/qpluginbase.pri) +load(qt_plugin) diff --git a/src/plugins/platforms/fb_base/fb_base.pro b/src/plugins/platforms/fb_base/fb_base.pro index 4445516cc70..4ebd53b407c 100644 --- a/src/plugins/platforms/fb_base/fb_base.pro +++ b/src/plugins/platforms/fb_base/fb_base.pro @@ -6,7 +6,7 @@ #QT -= core gui TARGET = fb_base -#include(../../qpluginbase.pri) +#load(qt_plugin) DESTDIR = $$QT.gui.plugins/graphicssystems diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index 4e4fe6ff4b0..ce6814ecc16 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -1,5 +1,5 @@ TARGET = qlinuxfbgraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index d1088e32338..d51b6b2ed0c 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -1,5 +1,5 @@ TARGET = qminimal -include(../../qpluginbase.pri) +load(qt_plugin) QT = core-private gui-private DESTDIR = $$QT.gui.plugins/platforms diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro index a6e7d7665a9..ad17a3bc781 100644 --- a/src/plugins/platforms/openkode/openkode.pro +++ b/src/plugins/platforms/openkode/openkode.pro @@ -1,5 +1,5 @@ TARGET = qopenkodeintegration -include(../../qpluginbase.pri) +load(qt_plugin) QT += opengl diff --git a/src/plugins/platforms/openvglite/openvglite.pro b/src/plugins/platforms/openvglite/openvglite.pro index 11e867d9981..bb7efe9bf36 100644 --- a/src/plugins/platforms/openvglite/openvglite.pro +++ b/src/plugins/platforms/openvglite/openvglite.pro @@ -1,5 +1,5 @@ TARGET = qvglitegraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += openvg diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro index bc17525104b..5db85332647 100644 --- a/src/plugins/platforms/qvfb/qvfb.pro +++ b/src/plugins/platforms/qvfb/qvfb.pro @@ -1,5 +1,5 @@ TARGET = qvfbintegration -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms diff --git a/src/plugins/platforms/uikit/uikit.pro b/src/plugins/platforms/uikit/uikit.pro index 6f5947f2c00..45a48dc92ad 100644 --- a/src/plugins/platforms/uikit/uikit.pro +++ b/src/plugins/platforms/uikit/uikit.pro @@ -1,5 +1,5 @@ TARGET = quikit -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += opengl diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index a7b8ca540af..85bffb0637e 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -1,5 +1,5 @@ TARGET = qvncgraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += network diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 3f5a69cf755..857a2918ce1 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -1,5 +1,5 @@ TARGET = qwayland -include(../../qpluginbase.pri) +load(qt_plugin) QT+=gui-private core-private opengl-private diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 139f5c95917..27d10b67561 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -1,6 +1,6 @@ TARGET = xcb -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += core-private gui-private diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro index 902d379ee20..2cba5513d54 100644 --- a/src/plugins/platforms/xlib/xlib.pro +++ b/src/plugins/platforms/xlib/xlib.pro @@ -1,6 +1,6 @@ TARGET = qxlib -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms QT += core-private gui-private opengl-private diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri index 2dd96bf7f27..b22a5277613 100644 --- a/src/plugins/qpluginbase.pri +++ b/src/plugins/qpluginbase.pri @@ -1,41 +1 @@ -TEMPLATE = lib -isEmpty(QT_MAJOR_VERSION) { - VERSION=5.0.0 -} else { - VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} -} -CONFIG += qt plugin - -win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release -TARGET = $$qtLibraryTarget($$TARGET) -contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols - -include(../qt_targets.pri) - -wince*:LIBS += $$QMAKE_LIBS_GUI - -symbian: { - TARGET.EPOCALLOWDLLDATA=1 - TARGET.CAPABILITY = All -Tcb - TARGET = $${TARGET}$${QT_LIBINFIX} - load(armcc_warnings) - - # Make partial upgrade SIS file for Qt plugin dll's - # Partial upgrade SIS file - vendorinfo = \ - "; Localised Vendor name" \ - "%{\"Nokia\"}" \ - " " \ - "; Unique Vendor name" \ - ":\"Nokia, Qt\"" \ - " " - isEmpty(QT_LIBINFIX): PARTIAL_UPGRADE_UID = 0x2001E61C - else: PARTIAL_UPGRADE_UID = 0xE001E61C - - pu_header = "; Partial upgrade package for testing $${TARGET} changes without reinstalling everything" \ - "$${LITERAL_HASH}{\"$${TARGET}\"}, ($$PARTIAL_UPGRADE_UID), $${QT_MAJOR_VERSION},$${QT_MINOR_VERSION},$${QT_PATCH_VERSION}, TYPE=PU" - partial_upgrade.pkg_prerules = pu_header vendorinfo - partial_upgrade.files = $$QMAKE_LIBDIR_QT/$${TARGET}.dll - partial_upgrade.path = c:/sys/bin - DEPLOYMENT += partial_upgrade -} +load(qt_plugin) diff --git a/src/plugins/s60/s60pluginbase.pri b/src/plugins/s60/s60pluginbase.pri index 0cde7d2277c..41d4b27db2a 100644 --- a/src/plugins/s60/s60pluginbase.pri +++ b/src/plugins/s60/s60pluginbase.pri @@ -1,6 +1,6 @@ # Note: These version based 'plugins' are not an actual Qt plugins, # they are just regular runtime loaded libraries -include(../qpluginbase.pri) +load(qt_plugin) CONFIG -= plugin diff --git a/src/plugins/sqldrivers/qsqldriverbase.pri b/src/plugins/sqldrivers/qsqldriverbase.pri index 7399c659da1..45638fcd4fe 100644 --- a/src/plugins/sqldrivers/qsqldriverbase.pri +++ b/src/plugins/sqldrivers/qsqldriverbase.pri @@ -1,4 +1,4 @@ -include(../qpluginbase.pri) +load(qt_plugin) QT = core sql-private DESTDIR = $$QT.sql.plugins/sqldrivers From 15871d606a0a85cfcd2b68b95c0891165f61e402 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Mon, 30 May 2011 11:30:42 +0159 Subject: [PATCH 55/59] Fix build in C++0x mode This fixes compiler errors (gcc 4.6 -std=gnu++0x on x86_64 Linux): embedded/qwslock.cpp: In function `bool forceLock(int, int, int)': embedded/qwslock.cpp:121:39: error: narrowing conversion of `semNum' from `int' to `short unsigned int' inside { } [-fpermissive] (and equivalent errors in other lines/files) See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf Section 8.5.4/6 Change-Id: I2cbac5482b87f33287a416af5a5c9bde621720bc Reviewed-By: Olivier Goffart Merge-Request: 1240 Reviewed-on: http://codereview.qt.nokia.com/275 Reviewed-by: Qt Sanity Bot Reviewed-by: Olivier Goffart --- src/gui/embedded/qmousepc_qws.cpp | 2 +- src/gui/embedded/qwslock.cpp | 10 +++++----- src/gui/text/qfontdatabase.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/embedded/qmousepc_qws.cpp b/src/gui/embedded/qmousepc_qws.cpp index 5d3b182d0a9..c22cab91f26 100644 --- a/src/gui/embedded/qmousepc_qws.cpp +++ b/src/gui/embedded/qmousepc_qws.cpp @@ -261,7 +261,7 @@ public: usleep(50000); QT_WRITE(fd,"@EeI!",5); usleep(10000); - static const char ibuf[] = { 246, 244 }; + static const unsigned char ibuf[] = { 246, 244 }; QT_WRITE(fd,ibuf,1); QT_WRITE(fd,ibuf+1,1); if (tcflush(fd,TCIOFLUSH) == -1) { diff --git a/src/gui/embedded/qwslock.cpp b/src/gui/embedded/qwslock.cpp index 0d65b611774..a64dc3d9c42 100644 --- a/src/gui/embedded/qwslock.cpp +++ b/src/gui/embedded/qwslock.cpp @@ -114,7 +114,7 @@ QWSLock::~QWSLock() QWSSignalHandler::instance()->removeSemaphore(semId); } -static bool forceLock(int semId, int semNum, int) +static bool forceLock(int semId, unsigned short semNum, int) { int ret; do { @@ -135,7 +135,7 @@ static bool forceLock(int semId, int semNum, int) return (ret != -1); } -static bool up(int semId, int semNum) +static bool up(int semId, unsigned short semNum) { int ret; do { @@ -148,7 +148,7 @@ static bool up(int semId, int semNum) return (ret != -1); } -static bool down(int semId, int semNum) +static bool down(int semId, unsigned short semNum) { int ret; do { @@ -161,7 +161,7 @@ static bool down(int semId, int semNum) return (ret != -1); } -static int getValue(int semId, int semNum) +static int getValue(int semId, unsigned short semNum) { int ret; do { @@ -210,7 +210,7 @@ void QWSLock::unlock(LockType type) return; } - const int semNum = type; + const unsigned short semNum = type; int ret; do { sembuf sops = {semNum, 1, 0}; diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 7a8a9122f23..98186dfd9b4 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -879,10 +879,10 @@ QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteA TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2); if (os2) { quint32 unicodeRange[4] = { - os2->ulUnicodeRange1, os2->ulUnicodeRange2, os2->ulUnicodeRange3, os2->ulUnicodeRange4 + static_cast(os2->ulUnicodeRange1), static_cast(os2->ulUnicodeRange2), static_cast(os2->ulUnicodeRange3), static_cast(os2->ulUnicodeRange4) }; quint32 codePageRange[2] = { - os2->ulCodePageRange1, os2->ulCodePageRange2 + static_cast(os2->ulCodePageRange1), static_cast(os2->ulCodePageRange2) }; writingSystems = qt_determine_writing_systems_from_truetype_bits(unicodeRange, codePageRange); From 3c7793acc0a5688e17ce2860c70fed7eae8690bb Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Mon, 9 May 2011 14:04:08 +1000 Subject: [PATCH 56/59] Don't crash on an invalid replacementStart from an input method. Ensure the cursor position does not exceed the bounds of the current text. Change-Id: If38f7729372562324d11eadd1a976c0c6da91863 Task-number: QTBUG-19054 Reviewed-by: Martin Jones (cherry picked from commit 6fbfb1ab3f26ad672eb24f9b4a0ce1a8eea08298) Reviewed-on: http://codereview.qt.nokia.com/290 Reviewed-by: Qt Sanity Bot Reviewed-by: Andrew den Exter --- src/gui/widgets/qlinecontrol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index ee7d7fb126e..bf36033c083 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -435,6 +435,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); m_cursor += event->replacementStart(); + if (m_cursor < 0) + m_cursor = 0; // insert commit string if (event->replacementLength()) { @@ -447,7 +449,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) cursorPositionChanged = true; } - m_cursor = qMin(c, m_text.length()); + m_cursor = qBound(0, c, m_text.length()); for (int i = 0; i < event->attributes().size(); ++i) { const QInputMethodEvent::Attribute &a = event->attributes().at(i); From 16bd22b1bce3add1827d6cfa47d2641e5d4c2d71 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Mon, 9 May 2011 13:57:34 +1000 Subject: [PATCH 57/59] Ensure the TextEdit cursor delegate is repositioned on mouse events. Update the micro focus when a mouse press changes the cursor position of a read only TextEdit. Change-Id: I11855037f7938b2cd23ac6ad165722b5289b4f46 Task-number: QTBUG-19109 Reviewed-by: Martin Jones Reviewed-on: http://codereview.qt.nokia.com/291 Reviewed-by: Qt Sanity Bot Reviewed-by: Andrew den Exter --- src/gui/text/qtextcontrol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 347761a1ee0..e1f42a5fb58 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1579,8 +1579,10 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con emit q->cursorPositionChanged(); _q_updateCurrentCharFormatAndSelection(); } else { - if (cursor.position() != oldCursorPos) + if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); + emit q->microFocusChanged(); + } selectionChanged(); } repaintOldAndNewSelection(oldSelection); From 50b77ef0b05de59c67c0cf82811d22ca02ef91b4 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 13 May 2011 13:49:20 +1000 Subject: [PATCH 58/59] Make TextEdit word selection more natural. QTextControl will only extend the selection to a word if the cursor is directly over it which prevents the selection being extended if the mouse is dragged up or down a to a shorter line of text making it difficult to select multiple lines of text. Just disable that limitation when the TextEdit word selection is enabled. Change-Id: I3b9d1575c0141db8441197d740de94a90eacc077 Task-number: QTBUG-19230 Reviewed-by: Martin Jones Reviewed-on: http://codereview.qt.nokia.com/292 Reviewed-by: Qt Sanity Bot Reviewed-by: Andrew den Exter --- src/gui/text/qtextcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index e1f42a5fb58..aacac0445c8 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -677,7 +677,7 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea const qreal wordEndX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x(); - if (mouseXPosition < wordStartX || mouseXPosition > wordEndX) + if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX)) return; // keep the already selected word even when moving to the left From 7b6c3707dea3292b62cca02245a710f00db21427 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 24 May 2011 14:05:48 +0100 Subject: [PATCH 59/59] sockets: limit buffer size of the internal sockets in proxy engines The application can normally control the amount of buffering of a socket or QNetworkReply by using the setReadBufferSize API. This allows the application to flow control the TCP connection, and avoids out of memory errors when the data being downloaded is received faster than the application can process it. However when using a proxy, the proxy socket engine has an internal socket which is used to communicate with the proxy server. It is not visible to the user, and does not have awareness of the buffer size of the external socket. To solve this, we limit the internal sockets' buffer size to 64k bytes. Under normal operation, the data is swiftly copied to the external socket where the buffer can grow (or not) based on the application's set value for read buffer size. Task-number: QT-4966 Reviewed-by: Markus Goetz (cherry picked from commit c4727a85eed57a4db698326a1bed4aa75b6e5284) Change-Id: I29e6628e38b79b41c4464ba8cb772a0f03717043 Reviewed-on: http://codereview.qt.nokia.com/153 Reviewed-by: Qt Sanity Bot Reviewed-by: Markus Goetz --- src/network/socket/qhttpsocketengine.cpp | 2 ++ src/network/socket/qsocks5socketengine.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 5f5db170729..5c672ec2273 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -149,6 +149,8 @@ bool QHttpSocketEngine::connectInternal() // Handshake isn't done. If unconnected, start connecting. if (d->state == None && d->socket->state() == QAbstractSocket::UnconnectedState) { setState(QAbstractSocket::ConnectingState); + //limit buffer in internal socket, data is buffered in the external socket under application control + d->socket->setReadBufferSize(65536); d->socket->connectToHost(d->proxy.hostName(), d->proxy.port()); } diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 575c0bc73e0..ab757987f6b 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1126,6 +1126,8 @@ bool QSocks5SocketEngine::connectInternal() if (d->socks5State == QSocks5SocketEnginePrivate::Uninitialized && d->socketState != QAbstractSocket::ConnectingState) { setState(QAbstractSocket::ConnectingState); + //limit buffer in internal socket, data is buffered in the external socket under application control + d->data->controlSocket->setReadBufferSize(65536); d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); return false; }