diff options
35 files changed, 411 insertions, 172 deletions
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 120c96746d..6fadcd43e6 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -17,6 +17,10 @@ defineReplace(cmakeModuleList) { CMAKE_MODULE_NAME = $$cmakeModuleName($${MODULE}) +CMAKE_MODULE_DEPS = $$cmakeModuleList($$eval(QT.$${MODULE}.depends)) +CMAKE_PARTIAL_MODULE_DEPS = $$replace(CMAKE_MODULE_DEPS, ";", ";Qt5::") +!isEmpty(CMAKE_PARTIAL_MODULE_DEPS):CMAKE_QT5_MODULE_DEPS = "Qt5::$${CMAKE_PARTIAL_MODULE_DEPS}" + CMAKE_QT_INSTALL_PREFIX = $$replace($$list($$[QT_INSTALL_PREFIX]), \\\\, /)/ CMAKE_QT_INSTALL_PREFIX_ESCAPED = "^$$re_escape($$CMAKE_QT_INSTALL_PREFIX)" diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index b901da5dcf..024dad7c6e 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -27635,7 +27635,7 @@ SQLITE_API int sqlite3_fullsync_count = 0; ** If you know that your system does support fdatasync() correctly, ** then simply compile with -Dfdatasync=fdatasync */ -#if !defined(fdatasync) && !defined(__linux__) +#if !defined(fdatasync) # define fdatasync fsync #endif diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index d7299e80d5..1626c4a93b 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -765,7 +765,7 @@ void Widget::sprintfFunction() char buf[BufSize]; ::snprintf(buf, BufSize, "%lld", 123456789LL); - QString str = QString::fromAscii(buf); + QString str = QString::fromUtf8(buf); //! [63] //! [64] diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index e28d886c3b..5b9ca6ca1b 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -41,6 +41,8 @@ #include "qurl_p.h" +#include <QtCore/qstringlist.h> + QT_BEGIN_NAMESPACE // needed by the punycode encoder/decoder diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index ccb03611f5..2e2db11558 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -42,6 +42,8 @@ #include "qurlquery.h" #include "qurl_p.h" +#include <QtCore/qstringlist.h> + QT_BEGIN_NAMESPACE /*! diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 7ccc5e500e..83d48d9330 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1949,7 +1949,7 @@ QEasingCurve QVariant::toEasingCurve() const \fn QByteArray QVariant::toByteArray() const Returns the variant as a QByteArray if the variant has type() \l - ByteArray or \l String (converted using QString::fromAscii()); + ByteArray or \l String (converted using QString::fromUtf8()); otherwise returns an empty byte array. \sa canConvert(), convert() diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index b67d655a9d..c92c269cac 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -1249,12 +1249,12 @@ void QByteArray::chop(int n) Appends the string \a str onto the end of this byte array and returns a reference to this byte array. The Unicode data is - converted into 8-bit characters using QString::toAscii(). + converted into 8-bit characters using QString::toUtf8(). If the QString contains non-ASCII Unicode characters, using this operator can lead to loss of information. You can disable this operator by defining \c QT_NO_CAST_TO_ASCII when you compile your - applications. You then need to call QString::toAscii() (or + applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) explicitly if you want to convert the data to \c{const char *}. */ @@ -1613,12 +1613,12 @@ QByteArray &QByteArray::append(const QByteArray &ba) \overload Appends the string \a str to this byte array. The Unicode data is - converted into 8-bit characters using QString::toAscii(). + converted into 8-bit characters using QString::toUtf8(). If the QString contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining \c QT_NO_CAST_TO_ASCII when you compile your - applications. You then need to call QString::toAscii() (or + applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) explicitly if you want to convert the data to \c{const char *}. */ @@ -1729,17 +1729,15 @@ QByteArray &QByteArray::insert(int i, const QByteArray &ba) Inserts the string \a str at index position \a i in the byte array. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). If \a i is greater than size(), the array is first extended using resize(). - If the QString contains non-ASCII Unicode characters, using this - function can lead to loss of information. You can disable this - function by defining \c QT_NO_CAST_TO_ASCII when you compile your - applications. You then need to call QString::toAscii() (or - QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) - explicitly if you want to convert the data to \c{const char *}. + You can disable this function by defining \c QT_NO_CAST_TO_ASCII when you + compile your applications. You then need to call QString::toUtf8() (or + QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to + convert the data to \c{const char *}. */ /*! @@ -2053,14 +2051,12 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after Replaces every occurrence of the string \a before with the byte array \a after. The Unicode data is converted into 8-bit - characters using QString::toAscii(). + characters using QString::toUtf8(). - If the QString contains non-ASCII Unicode characters, using this - function can lead to loss of information. You can disable this - function by defining \c QT_NO_CAST_TO_ASCII when you compile your - applications. You then need to call QString::toAscii() (or - QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) - explicitly if you want to convert the data to \c{const char *}. + You can disable this function by defining \c QT_NO_CAST_TO_ASCII when you + compile your applications. You then need to call QString::toUtf8() (or + QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to + convert the data to \c{const char *}. */ /*! \fn QByteArray &QByteArray::replace(const QString &before, const char *after) @@ -2098,12 +2094,12 @@ QByteArray &QByteArray::replace(char before, const QByteArray &after) Replaces every occurrence of the character \a before with the string \a after. The Unicode data is converted into 8-bit - characters using QString::toAscii(). + characters using QString::toUtf8(). If the QString contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining \c QT_NO_CAST_TO_ASCII when you compile your - applications. You then need to call QString::toAscii() (or + applications. You then need to call QString::toUtf8() (or QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) explicitly if you want to convert the data to \c{const char *}. */ @@ -2244,14 +2240,12 @@ int QByteArray::indexOf(const QByteArray &ba, int from) const \a from. Returns -1 if \a str could not be found. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). - If the QString contains non-ASCII Unicode characters, using this - function can lead to loss of information. You can disable this - function by defining \c QT_NO_CAST_TO_ASCII when you compile your - applications. You then need to call QString::toAscii() (or - QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) - explicitly if you want to convert the data to \c{const char *}. + You can disable this function by defining \c QT_NO_CAST_TO_ASCII when you + compile your applications. You then need to call QString::toUtf8() (or + QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to + convert the data to \c{const char *}. */ /*! \fn int QByteArray::indexOf(const char *str, int from) const @@ -2371,14 +2365,12 @@ int QByteArray::lastIndexOf(const QByteArray &ba, int from) const last (size() - 1) byte. Returns -1 if \a str could not be found. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). - If the QString contains non-ASCII Unicode characters, using this - function can lead to loss of information. You can disable this - function by defining \c QT_NO_CAST_TO_ASCII when you compile your - applications. You then need to call QString::toAscii() (or - QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) - explicitly if you want to convert the data to \c{const char *}. + You can disable this function by defining \c QT_NO_CAST_TO_ASCII when you + compile your applications. You then need to call QString::toUtf8() (or + QString::toLatin1() or QString::toLocal8Bit()) explicitly if you want to + convert the data to \c{const char *}. */ /*! \fn int QByteArray::lastIndexOf(const char *str, int from) const @@ -2772,16 +2764,15 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) otherwise returns false. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). The comparison is case sensitive. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. You - then need to call QString::fromAscii(), QString::fromLatin1(), - QString::fromUtf8(), or QString::fromLocal8Bit() explicitly if - you want to convert the byte array to a QString before doing the - comparison. + then need to call QString::fromUtf8(), QString::fromLatin1(), + or QString::fromLocal8Bit() explicitly if you want to convert the byte + array to a QString before doing the comparison. */ /*! \fn bool QByteArray::operator!=(const QString &str) const @@ -2790,16 +2781,15 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) otherwise returns false. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). The comparison is case sensitive. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. You - then need to call QString::fromAscii(), QString::fromLatin1(), - QString::fromUtf8(), or QString::fromLocal8Bit() explicitly if - you want to convert the byte array to a QString before doing the - comparison. + then need to call QString::fromUtf8(), QString::fromLatin1(), + or QString::fromLocal8Bit() explicitly if you want to convert the byte + array to a QString before doing the comparison. */ /*! \fn bool QByteArray::operator<(const QString &str) const @@ -2808,16 +2798,15 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) str; otherwise returns false. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). The comparison is case sensitive. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. You - then need to call QString::fromAscii(), QString::fromLatin1(), - QString::fromUtf8(), or QString::fromLocal8Bit() explicitly if - you want to convert the byte array to a QString before doing the - comparison. + then need to call QString::fromUtf8(), QString::fromLatin1(), + or QString::fromLocal8Bit() explicitly if you want to convert the byte + array to a QString before doing the comparison. */ /*! \fn bool QByteArray::operator>(const QString &str) const @@ -2826,16 +2815,15 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) \a str; otherwise returns false. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). The comparison is case sensitive. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. You - then need to call QString::fromAscii(), QString::fromLatin1(), - QString::fromUtf8(), or QString::fromLocal8Bit() explicitly if - you want to convert the byte array to a QString before doing the - comparison. + then need to call QString::fromUtf8(), QString::fromLatin1(), + or QString::fromLocal8Bit() explicitly if you want to convert the byte + array to a QString before doing the comparison. */ /*! \fn bool QByteArray::operator<=(const QString &str) const @@ -2844,16 +2832,15 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) to string \a str; otherwise returns false. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). The comparison is case sensitive. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. You - then need to call QString::fromAscii(), QString::fromLatin1(), - QString::fromUtf8(), or QString::fromLocal8Bit() explicitly if - you want to convert the byte array to a QString before doing the - comparison. + then need to call QString::fromUtf8(), QString::fromLatin1(), + or QString::fromLocal8Bit() explicitly if you want to convert the byte + array to a QString before doing the comparison. */ /*! \fn bool QByteArray::operator>=(const QString &str) const @@ -2862,16 +2849,15 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba) \a str; otherwise returns false. The Unicode data is converted into 8-bit characters using - QString::toAscii(). + QString::toUtf8(). The comparison is case sensitive. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. You - then need to call QString::fromAscii(), QString::fromLatin1(), - QString::fromUtf8(), or QString::fromLocal8Bit() explicitly if - you want to convert the byte array to a QString before doing the - comparison. + then need to call QString::fromUtf8(), QString::fromLatin1(), + or QString::fromLocal8Bit() explicitly if you want to convert the byte + array to a QString before doing the comparison. */ /*! \fn bool operator==(const QByteArray &a1, const QByteArray &a2) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index b83170cb46..89017fee58 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -151,9 +151,9 @@ QT_BEGIN_NAMESPACE to convert to and from traditional 8-bit \c{char}s. If you defined \c QT_NO_CAST_FROM_ASCII and \c QT_NO_CAST_TO_ASCII, as explained in the QString documentation, you will need to - explicitly call fromAscii() or fromLatin1(), or use QLatin1Char, + explicitly call fromLatin1(), or use QLatin1Char, to construct a QChar from an 8-bit \c char, and you will need to - call toAscii() or toLatin1() to get the 8-bit value back. + call toLatin1() to get the 8-bit value back. For more information see \l{http://www.unicode.org/ucd/}{"About the Unicode Character Database"}. @@ -1251,7 +1251,7 @@ ushort QChar::toCaseFolded(ushort ucs2) \note It is not possible to distinguish a non-Latin-1 character from a Latin-1 0 (NUL) character. Prefer to use unicode(), which does not have this ambiguity. - \sa toAscii(), unicode() + \sa unicode() */ /*! @@ -1262,7 +1262,7 @@ ushort QChar::toCaseFolded(ushort ucs2) An alternative is to use QLatin1Char. - \sa fromAscii(), unicode() + \sa toLatin1(), unicode() */ /*! diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 04626742bd..fd0d1286f6 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -470,13 +470,12 @@ const QString::Null QString::null = { }; \snippet qstring/main.cpp 0 QString converts the \c{const char *} data into Unicode using the - fromAscii() function. fromAscii() treats ordinals above 128 as Latin-1 - characters. + fromUtf8() function. In all of the QString functions that take \c{const char *} parameters, the \c{const char *} is interpreted as a classic - C-style '\\0'-terminated string. It is legal for the \c{const char - *} parameter to be 0. + C-style '\\0'-terminated string encoded in UTF-8. It is legal for + the \c{const char *} parameter to be 0. You can also provide string data as an array of \l{QChar}s: @@ -604,12 +603,11 @@ const QString::Null QString::null = { }; \section1 Converting Between 8-Bit Strings and Unicode Strings - QString provides the following four functions that return a - \c{const char *} version of the string as QByteArray: toAscii(), - toLatin1(), toUtf8(), and toLocal8Bit(). + QString provides the following three functions that return a + \c{const char *} version of the string as QByteArray: toUtf8(), + toLatin1(), and toLocal8Bit(). \list - \li toAscii() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. \li toLatin1() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. \li toUtf8() returns a UTF-8 encoded 8-bit string. UTF-8 is a superset of US-ASCII (ANSI X3.4-1986) that supports the entire @@ -619,7 +617,7 @@ const QString::Null QString::null = { }; \endlist To convert from one of these encodings, QString provides - fromAscii(), fromLatin1(), fromUtf8(), and fromLocal8Bit(). Other + fromLatin1(), fromUtf8(), and fromLocal8Bit(). Other encodings are supported through the QTextCodec class. As mentioned above, QString provides a lot of functions and @@ -644,14 +642,14 @@ const QString::Null QString::null = { }; \snippet code/src_corelib_tools_qstring.cpp 0 - You then need to explicitly call fromAscii(), fromLatin1(), - fromUtf8(), or fromLocal8Bit() to construct a QString from an + You then need to explicitly call fromUtf8(), fromLatin1(), + or fromLocal8Bit() to construct a QString from an 8-bit string, or use the lightweight QLatin1String class, for example: \snippet code/src_corelib_tools_qstring.cpp 1 - Similarly, you must call toAscii(), toLatin1(), toUtf8(), or + Similarly, you must call toLatin1(), toUtf8(), or toLocal8Bit() explicitly to convert the QString to an 8-bit string. (Other encodings are supported through the QTextCodec class.) @@ -688,7 +686,7 @@ const QString::Null QString::null = { }; \snippet qstring/main.cpp 8 All functions except isNull() treat null strings the same as empty - strings. For example, toAscii().constData() returns a pointer to a + strings. For example, toUtf8().constData() returns a pointer to a '\\0' character for a null string (\e not a null pointer), and QString() compares equal to QString(""). We recommend that you always use the isEmpty() function and avoid isNull(). @@ -913,25 +911,25 @@ const QString::Null QString::null = { }; Constructs a string initialized with the 8-bit string \a str. The given const char pointer is converted to Unicode using the - fromAscii() function. + fromUtf8() function. You can disable this constructor by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr(), for example. - \sa fromAscii(), fromLatin1(), fromLocal8Bit(), fromUtf8() + \sa fromLatin1(), fromLocal8Bit(), fromUtf8() */ /*! \fn QString QString::fromStdString(const std::string &str) Returns a copy of the \a str string. The given string is converted - to Unicode using the fromAscii() function. + to Unicode using the fromUtf8() function. This constructor is only available if Qt is configured with STL compatibility enabled. - \sa fromAscii(), fromLatin1(), fromLocal8Bit(), fromUtf8() + \sa fromLatin1(), fromLocal8Bit(), fromUtf8() */ /*! \fn QString QString::fromStdWString(const std::wstring &str) @@ -966,7 +964,7 @@ const QString::Null QString::null = { }; This operator is mostly useful to pass a QString to a function that accepts a std::wstring object. - \sa utf16(), toAscii(), toLatin1(), toUtf8(), toLocal8Bit() + \sa utf16(), toLatin1(), toUtf8(), toLocal8Bit() */ // ### replace with QCharIterator @@ -999,11 +997,11 @@ int QString::toUcs4_helper(const ushort *uc, int length, uint *out) hold the complete string (allocating the array with the same length as the string is always sufficient). - returns the actual length of the string in \a array. + This function returns the actual length of the string in \a array. \note This function does not append a null character to the array. - \sa utf16(), toUcs4(), toAscii(), toLatin1(), toUtf8(), toLocal8Bit(), toStdWString() + \sa utf16(), toUcs4(), toLatin1(), toUtf8(), toLocal8Bit(), toStdWString() */ /*! \fn QString::QString(const QString &other) @@ -1114,7 +1112,7 @@ QString::QString(QChar ch) /*! \fn QString::QString(const QByteArray &ba) Constructs a string initialized with the byte array \a ba. The - given byte array is converted to Unicode using fromAscii(). Stops + given byte array is converted to Unicode using fromUtf8(). Stops copying at the first 0 character, otherwise copies the entire byte array. @@ -1123,7 +1121,7 @@ QString::QString(QChar ch) can be useful if you want to ensure that all user-visible strings go through QObject::tr(), for example. - \sa fromAscii(), fromLatin1(), fromLocal8Bit(), fromUtf8() + \sa fromLatin1(), fromLocal8Bit(), fromUtf8() */ /*! \fn QString::QString(const Null &) @@ -1341,7 +1339,7 @@ QString &QString::operator=(const QString &other) \overload operator=() Assigns \a ba to this string. The byte array is converted to Unicode - using the fromAscii() function. This function stops conversion at the + using the fromUtf8() function. This function stops conversion at the first NUL character found, or the end of the \a ba byte array. You can disable this operator by defining \c @@ -1355,7 +1353,7 @@ QString &QString::operator=(const QString &other) \overload operator=() Assigns \a str to this string. The const char pointer is converted - to Unicode using the fromAscii() function. + to Unicode using the fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -1367,8 +1365,9 @@ QString &QString::operator=(const QString &other) \overload operator=() - Assigns character \a ch to this string. The character is converted - to Unicode using the fromAscii() function. + Assigns character \a ch to this string. Note that the character is + converted to Unicode using the fromLatin1() function, unlike other 8-bit + functions that operate on UTF-8 data. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -1532,7 +1531,7 @@ QString &QString::append(const QLatin1String &str) \overload append() Appends the byte array \a ba to this string. The given byte array - is converted to Unicode using the fromAscii() function. + is converted to Unicode using the fromUtf8() function. You can disable this function by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -1545,7 +1544,7 @@ QString &QString::append(const QLatin1String &str) \overload append() Appends the string \a str to this string. The given const char - pointer is converted to Unicode using the fromAscii() function. + pointer is converted to Unicode using the fromUtf8() function. You can disable this function by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -1591,7 +1590,7 @@ QString &QString::append(QChar ch) \overload prepend() Prepends the byte array \a ba to this string. The byte array is - converted to Unicode using the fromAscii() function. + converted to Unicode using the fromUtf8() function. You can disable this function by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -1604,7 +1603,7 @@ QString &QString::append(QChar ch) \overload prepend() Prepends the string \a str to this string. The const char pointer - is converted to Unicode using the fromAscii() function. + is converted to Unicode using the fromUtf8() function. You can disable this function by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -2151,7 +2150,7 @@ bool QString::operator==(const QLatin1String &other) const \overload operator==() The \a other byte array is converted to a QString using the - fromAscii() function. This function stops conversion at the + fromUtf8() function. This function stops conversion at the first NUL character found, or the end of the byte array. You can disable this operator by defining \c @@ -2165,7 +2164,7 @@ bool QString::operator==(const QLatin1String &other) const \overload operator==() The \a other const char pointer is converted to a QString using - the fromAscii() function. + the fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -2214,7 +2213,7 @@ bool QString::operator<(const QLatin1String &other) const \overload operator<() The \a other byte array is converted to a QString using the - fromAscii() function. If any NUL characters ('\\0') are embedded + fromUtf8() function. If any NUL characters ('\\0') are embedded in the byte array, they will be included in the transformation. You can disable this operator by defining \c @@ -2228,7 +2227,7 @@ bool QString::operator<(const QLatin1String &other) const \overload operator<() The \a other const char pointer is converted to a QString using - the fromAscii() function. + the fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -2257,7 +2256,7 @@ bool QString::operator<(const QLatin1String &other) const \overload operator<=() The \a other byte array is converted to a QString using the - fromAscii() function. If any NUL characters ('\\0') are embedded + fromUtf8() function. If any NUL characters ('\\0') are embedded in the byte array, they will be included in the transformation. You can disable this operator by defining \c @@ -2271,7 +2270,7 @@ bool QString::operator<(const QLatin1String &other) const \overload operator<=() The \a other const char pointer is converted to a QString using - the fromAscii() function. + the fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -2316,7 +2315,7 @@ bool QString::operator>(const QLatin1String &other) const \overload operator>() The \a other byte array is converted to a QString using the - fromAscii() function. If any NUL characters ('\\0') are embedded + fromUtf8() function. If any NUL characters ('\\0') are embedded in the byte array, they will be included in the transformation. You can disable this operator by defining \c @@ -2330,7 +2329,7 @@ bool QString::operator>(const QLatin1String &other) const \overload operator>() The \a other const char pointer is converted to a QString using - the fromAscii() function. + the fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -2360,7 +2359,7 @@ bool QString::operator>(const QLatin1String &other) const \overload operator>=() The \a other byte array is converted to a QString using the - fromAscii() function. If any NUL characters ('\\0') are embedded in + fromUtf8() function. If any NUL characters ('\\0') are embedded in the byte array, they will be included in the transformation. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII @@ -2374,7 +2373,7 @@ bool QString::operator>(const QLatin1String &other) const \overload operator>=() The \a other const char pointer is converted to a QString using - the fromAscii() function. + the fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -2404,7 +2403,7 @@ bool QString::operator>(const QLatin1String &other) const \overload operator!=() The \a other byte array is converted to a QString using the - fromAscii() function. If any NUL characters ('\\0') are embedded + fromUtf8() function. If any NUL characters ('\\0') are embedded in the byte array, they will be included in the transformation. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII @@ -2418,7 +2417,7 @@ bool QString::operator>(const QLatin1String &other) const \overload operator!=() The \a other const char pointer is converted to a QString using - the fromAscii() function. + the fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -3917,7 +3916,7 @@ static QByteArray toLatin1_helper(const QChar *data, int length) characters. Those characters may be suppressed or replaced with a question mark. - \sa fromLatin1(), toAscii(), toUtf8(), toLocal8Bit(), QTextCodec + \sa fromLatin1(), toUtf8(), toLocal8Bit(), QTextCodec */ QByteArray QString::toLatin1() const { @@ -3963,7 +3962,7 @@ static QByteArray toLocal8Bit_helper(const QChar *data, int length) locale, the returned byte array is undefined. Those characters may be suppressed or replaced by another. - \sa fromLocal8Bit(), toAscii(), toLatin1(), toUtf8(), QTextCodec + \sa fromLocal8Bit(), toLatin1(), toUtf8(), QTextCodec */ QByteArray QString::toLocal8Bit() const { @@ -3988,7 +3987,7 @@ QByteArray QString::toLocal8Bit() const may be discarded and will not appear in the UTF-8 representation, or they may be replaced by one or more replacement characters. - \sa fromUtf8(), toAscii(), toLatin1(), toLocal8Bit(), QTextCodec + \sa fromUtf8(), toLatin1(), toLocal8Bit(), QTextCodec */ QByteArray QString::toUtf8() const { @@ -4006,7 +4005,7 @@ QByteArray QString::toUtf8() const UCS-4 is a Unicode codec and is lossless. All characters from this string can be encoded in UCS-4. The vector is not null terminated. - \sa fromUtf8(), toAscii(), toLatin1(), toLocal8Bit(), QTextCodec, fromUcs4(), toWCharArray() + \sa fromUtf8(), toUtf8(), toLatin1(), toLocal8Bit(), QTextCodec, fromUcs4(), toWCharArray() */ QVector<uint> QString::toUcs4() const { @@ -4075,7 +4074,7 @@ QString::Data *QString::fromAscii_helper(const char *str, int size) If \a size is -1 (default), it is taken to be strlen(\a str). - \sa toLatin1(), fromAscii(), fromUtf8(), fromLocal8Bit() + \sa toLatin1(), fromUtf8(), fromLocal8Bit() */ @@ -4088,7 +4087,7 @@ QString::Data *QString::fromAscii_helper(const char *str, int size) QTextCodec::codecForLocale() is used to perform the conversion. - \sa toLocal8Bit(), fromAscii(), fromLatin1(), fromUtf8() + \sa toLocal8Bit(), fromLatin1(), fromUtf8() */ QString QString::fromLocal8Bit_helper(const char *str, int size) { @@ -4139,7 +4138,7 @@ QString QString::fromLocal8Bit_helper(const char *str, int size) Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, etc.), as well as 16 codepoints in the range U+FDD0..U+FDDF, inclusive. - \sa toUtf8(), fromAscii(), fromLatin1(), fromLocal8Bit() + \sa toUtf8(), fromLatin1(), fromLocal8Bit() */ QString QString::fromUtf8_helper(const char *str, int size) { @@ -4564,7 +4563,7 @@ QString& QString::fill(QChar ch, int size) \overload operator+=() Appends the byte array \a ba to this string. The byte array is converted - to Unicode using the fromAscii() function. If any NUL characters ('\\0') + to Unicode using the fromUtf8() function. If any NUL characters ('\\0') are embedded in the \a ba byte array, they will be included in the transformation. @@ -4579,7 +4578,7 @@ QString& QString::fill(QChar ch, int size) \overload operator+=() Appends the string \a str to this string. The const char pointer - is converted to Unicode using the fromAscii() function. + is converted to Unicode using the fromUtf8() function. You can disable this function by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -4598,8 +4597,9 @@ QString& QString::fill(QChar ch, int size) \overload operator+=() - Appends the character \a ch to this string. The character is - converted to Unicode using the fromAscii() function. + Appends the character \a ch to this string. Note that the character is + converted to Unicode using the fromLatin1() function, unlike other 8-bit + functions that operate on UTF-8 data. You can disable this function by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -4722,10 +4722,10 @@ QString& QString::fill(QChar ch, int size) \relates QString Returns a string which is the result of concatenating \a s1 and \a - s2 (\a s2 is converted to Unicode using the QString::fromAscii() + s2 (\a s2 is converted to Unicode using the QString::fromUtf8() function). - \sa QString::fromAscii() + \sa QString::fromUtf8() */ /*! @@ -4733,10 +4733,10 @@ QString& QString::fill(QChar ch, int size) \relates QString Returns a string which is the result of concatenating \a s1 and \a - s2 (\a s1 is converted to Unicode using the QString::fromAscii() + s2 (\a s1 is converted to Unicode using the QString::fromUtf8() function). - \sa QString::fromAscii() + \sa QString::fromUtf8() */ /*! @@ -7352,7 +7352,7 @@ bool QString::isRightToLeft() const Returns a std::string object with the data contained in this QString. The Unicode data is converted into 8-bit characters using - the toAscii() function. + the toUtf8() function. This operator is mostly useful to pass a QString to a function that accepts a std::string object. @@ -7360,7 +7360,7 @@ bool QString::isRightToLeft() const If the QString contains non-Latin1 Unicode characters, using this can lead to loss of information. - \sa toAscii(), toLatin1(), toUtf8(), toLocal8Bit() + \sa toLatin1(), toUtf8(), toLocal8Bit() */ /*! @@ -7544,7 +7544,7 @@ QString &QString::setRawData(const QChar *unicode, int size) \overload The \a other const char pointer is converted to a QString using - the QString::fromAscii() function. + the QString::fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -7569,7 +7569,7 @@ QString &QString::setRawData(const QChar *unicode, int size) \overload operator!=() The \a other const char pointer is converted to a QString using - the QString::fromAscii() function. + the QString::fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -7595,7 +7595,7 @@ QString &QString::setRawData(const QChar *unicode, int size) \overload The \a other const char pointer is converted to a QString using - the QString::fromAscii() function. + the QString::fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want @@ -7621,7 +7621,7 @@ QString &QString::setRawData(const QChar *unicode, int size) \overload The \a other const char pointer is converted to a QString using - the QString::fromAscii() function. + the QString::fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -7647,7 +7647,7 @@ QString &QString::setRawData(const QChar *unicode, int size) \overload The \a other const char pointer is converted to a QString using - the QString::fromAscii() function. + the QString::fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -7672,7 +7672,7 @@ QString &QString::setRawData(const QChar *unicode, int size) \overload The \a other const char pointer is converted to a QString using - the QString::fromAscii() function. + the QString::fromUtf8() function. You can disable this operator by defining \c QT_NO_CAST_FROM_ASCII when you compile your applications. This @@ -9024,7 +9024,7 @@ static inline bool qt_ends_with(const QChar *haystack, int haystackLen, characters. Those characters may be suppressed or replaced with a question mark. - \sa toAscii(), toUtf8(), toLocal8Bit(), QTextCodec + \sa toUtf8(), toLocal8Bit(), QTextCodec */ QByteArray QStringRef::toLatin1() const { @@ -9063,7 +9063,7 @@ QByteArray QStringRef::toAscii() const locale, the returned byte array is undefined. Those characters may be suppressed or replaced by another. - \sa toAscii(), toLatin1(), toUtf8(), QTextCodec + \sa toLatin1(), toUtf8(), QTextCodec */ QByteArray QStringRef::toLocal8Bit() const { @@ -9090,7 +9090,7 @@ QByteArray QStringRef::toLocal8Bit() const may be discarded and will not appear in the UTF-8 representation, or they may be replaced by one or more replacement characters. - \sa toAscii(), toLatin1(), toLocal8Bit(), QTextCodec + \sa toLatin1(), toLocal8Bit(), QTextCodec */ QByteArray QStringRef::toUtf8() const { @@ -9108,7 +9108,7 @@ QByteArray QStringRef::toUtf8() const UCS-4 is a Unicode codec and is lossless. All characters from this string can be encoded in UCS-4. - \sa toAscii(), toLatin1(), toLocal8Bit(), QTextCodec + \sa toUtf8(), toLatin1(), toLocal8Bit(), QTextCodec */ QVector<uint> QStringRef::toUcs4() const { diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index bbfb31aef3..bf2928346c 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -49,6 +49,15 @@ #include <string> +#if defined(Q_OS_LINUX_ANDROID) +// std::wstring is disabled on android's glibc, as bionic lacks certain features +// that libstdc++ checks for (like mbcslen). +namespace std +{ + typedef basic_string<wchar_t> wstring; +} +#endif + #include <stdarg.h> #ifdef truncate diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 3c08717d11..56473e2982 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -44,7 +44,9 @@ #include "private/qipaddress_p.h" #include "qdebug.h" #if defined(Q_OS_WIN) -#include <winsock2.h> +# include <winsock2.h> +#else +# include <netinet/in.h> #endif #include "qplatformdefs.h" #include "qstringlist.h" diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index e9848213d8..8284ae4c27 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -84,19 +84,22 @@ QT_BEGIN_NAMESPACE /*! \enum QLocalServer::SocketOption + \since 5.0 This enum describes the possible options that can be used to create the socket. This changes the access permissions on platforms (Linux, Windows) that support access permissions on the socket. Both GroupAccess and OtherAccess may vary slightly in meanings depending on the platform. - \value UserAccess + \value UserAccessOption Access is restricted to the same user as the process that created the socket. - \value GroupAccess + \value GroupAccessOption Access is restricted to the same group but not the user that created the socket on Linux. - \value OtherAccess + Access is restricted to the primary group of the process on Windows + \value OtherAccessOption Access is available to everyone but the user and group that created the socket on Linux. - \value WorldAccess + Access is available to everyone on Windows. + \value WorldAccessOption No access restrictions. \sa SocketOptions @@ -149,6 +152,13 @@ QLocalServer::~QLocalServer() honor file permissions for Unix domain sockets and by default have WorldAccess and these permission flags will have no effect. + On Windows, UserAccessOption is sufficient to allow a non + elevated process to connect to a local server created by an + elevated process run by the same user. GroupAccessOption + refers to the primary group of the process (see TokenPrimaryGroup + in the Windows documentation). OtherAccessOption refers to + the well known "Everyone" group. + By default none of the flags are set, access permissions are the platform default. @@ -162,6 +172,7 @@ void QLocalServer::setSocketOptions(SocketOptions options) } /*! + \since 5.0 Returns the socket options set on the socket. \sa setSocketOptions() diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp index 07357e5789..00eae32c99 100644 --- a/src/network/socket/qlocalserver_win.cpp +++ b/src/network/socket/qlocalserver_win.cpp @@ -42,9 +42,14 @@ #include "qlocalserver.h" #include "qlocalserver_p.h" #include "qlocalsocket.h" +#include <QtCore/private/qsystemerror_p.h> #include <qdebug.h> +#include <Aclapi.h> +#include <AccCtrl.h> +#include <Sddl.h> + // The buffer size need to be 0 otherwise data could be // lost if the socket that has written data closes the connection // before it is read. Pipewriter is used for write buffering. @@ -62,6 +67,116 @@ bool QLocalServerPrivate::addListener() listeners << Listener(); Listener &listener = listeners.last(); + SECURITY_ATTRIBUTES sa; + sa.nLength = sizeof(SECURITY_ATTRIBUTES); + sa.bInheritHandle = FALSE; //non inheritable handle, same as default + sa.lpSecurityDescriptor = 0; //default security descriptor + + QScopedPointer<SECURITY_DESCRIPTOR> pSD; + PSID worldSID = 0; + QByteArray aclBuffer; + QByteArray tokenUserBuffer; + QByteArray tokenGroupBuffer; + + // create security descriptor if access options were specified + if ((socketOptions & QLocalServer::WorldAccessOption)) { + pSD.reset(new SECURITY_DESCRIPTOR); + if (!InitializeSecurityDescriptor(pSD.data(), SECURITY_DESCRIPTOR_REVISION)) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + return false; + } + HANDLE hToken = NULL; + if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) + return false; + DWORD dwBufferSize = 0; + GetTokenInformation(hToken, TokenUser, 0, 0, &dwBufferSize); + tokenUserBuffer.fill(0, dwBufferSize); + PTOKEN_USER pTokenUser = (PTOKEN_USER)tokenUserBuffer.data(); + if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwBufferSize, &dwBufferSize)) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + CloseHandle(hToken); + return false; + } + + dwBufferSize = 0; + GetTokenInformation(hToken, TokenPrimaryGroup, 0, 0, &dwBufferSize); + tokenGroupBuffer.fill(0, dwBufferSize); + PTOKEN_PRIMARY_GROUP pTokenGroup = (PTOKEN_PRIMARY_GROUP)tokenGroupBuffer.data(); + if (!GetTokenInformation(hToken, TokenPrimaryGroup, pTokenGroup, dwBufferSize, &dwBufferSize)) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + CloseHandle(hToken); + return false; + } + CloseHandle(hToken); + +#ifdef QLOCALSERVER_DEBUG + DWORD groupNameSize; + DWORD domainNameSize; + SID_NAME_USE groupNameUse; + LPWSTR groupNameSid; + LookupAccountSid(0, pTokenGroup->PrimaryGroup, 0, &groupNameSize, 0, &domainNameSize, &groupNameUse); + QScopedPointer<wchar_t, QScopedPointerArrayDeleter<wchar_t>> groupName(new wchar_t[groupNameSize]); + QScopedPointer<wchar_t, QScopedPointerArrayDeleter<wchar_t>> domainName(new wchar_t[domainNameSize]); + if (LookupAccountSid(0, pTokenGroup->PrimaryGroup, groupName.data(), &groupNameSize, domainName.data(), &domainNameSize, &groupNameUse)) { + qDebug() << "primary group" << QString::fromWCharArray(domainName.data()) << "\\" << QString::fromWCharArray(groupName.data()) << "type=" << groupNameUse; + } + if (ConvertSidToStringSid(pTokenGroup->PrimaryGroup, &groupNameSid)) { + qDebug() << "primary group SID" << QString::fromWCharArray(groupNameSid) << "valid" << IsValidSid(pTokenGroup->PrimaryGroup); + LocalFree(groupNameSid); + } +#endif + + SID_IDENTIFIER_AUTHORITY WorldAuth = SECURITY_WORLD_SID_AUTHORITY; + if (!AllocateAndInitializeSid(&WorldAuth, 1, SECURITY_WORLD_RID, + 0, 0, 0, 0, 0, 0, 0, + &worldSID)) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + return false; + } + + //calculate size of ACL buffer + DWORD aclSize = sizeof(ACL) + ((sizeof(ACCESS_ALLOWED_ACE)) * 3); + aclSize += GetLengthSid(pTokenUser->User.Sid) - sizeof(DWORD); + aclSize += GetLengthSid(pTokenGroup->PrimaryGroup) - sizeof(DWORD); + aclSize += GetLengthSid(worldSID) - sizeof(DWORD); + aclSize = (aclSize + (sizeof(DWORD) - 1)) & 0xfffffffc; + + aclBuffer.fill(0, aclSize); + PACL acl = (PACL)aclBuffer.data(); + InitializeAcl(acl, aclSize, ACL_REVISION_DS); + + if (socketOptions & QLocalServer::UserAccessOption) { + if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenUser->User.Sid)) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + FreeSid(worldSID); + return false; + } + } + if (socketOptions & QLocalServer::GroupAccessOption) { + if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, pTokenGroup->PrimaryGroup)) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + FreeSid(worldSID); + return false; + } + } + if (socketOptions & QLocalServer::OtherAccessOption) { + if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, worldSID)) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + FreeSid(worldSID); + return false; + } + } + SetSecurityDescriptorOwner(pSD.data(), pTokenUser->User.Sid, FALSE); + SetSecurityDescriptorGroup(pSD.data(), pTokenGroup->PrimaryGroup, FALSE); + if (!SetSecurityDescriptorDacl(pSD.data(), TRUE, acl, FALSE)) { + setError(QLatin1String("QLocalServerPrivate::addListener")); + FreeSid(worldSID); + return false; + } + + sa.lpSecurityDescriptor = pSD.data(); + } + listener.handle = CreateNamedPipe( (const wchar_t *)fullServerName.utf16(), // pipe name PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, // read/write access @@ -72,7 +187,7 @@ bool QLocalServerPrivate::addListener() BUFSIZE, // output buffer size BUFSIZE, // input buffer size 3000, // client time-out - NULL); + &sa); if (listener.handle == INVALID_HANDLE_VALUE) { setError(QLatin1String("QLocalServerPrivate::addListener")); @@ -80,6 +195,9 @@ bool QLocalServerPrivate::addListener() return false; } + if (worldSID) + FreeSid(worldSID); + memset(&listener.overlapped, 0, sizeof(listener.overlapped)); listener.overlapped.hEvent = eventHandle; if (!ConnectNamedPipe(listener.handle, &listener.overlapped)) { diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index a48fcfa769..67e7038e00 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -56,6 +56,7 @@ #include "private/qabstractsocketengine_p.h" #ifndef Q_OS_WIN # include "qplatformdefs.h" +# include <netinet/in.h> #else # include <winsock2.h> #endif diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri index 8f93f0d0c0..39b214ffb9 100644 --- a/src/network/socket/socket.pri +++ b/src/network/socket/socket.pri @@ -40,6 +40,8 @@ win32:SOURCES += socket/qnativesocketengine_win.cpp \ socket/qlocalsocket_win.cpp \ socket/qlocalserver_win.cpp +win32:!wince*:LIBS += -lAdvapi32 + wince*: { SOURCES -= socket/qlocalsocket_win.cpp \ socket/qlocalserver_win.cpp diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index bac837e62f..59f6f53fef 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1239,7 +1239,8 @@ bool QSslSocketBackendPrivate::startHandshake() #ifdef Q_OS_WIN //Skip this if not using system CAs, or if the SSL errors are configured in advance to be ignorable - if (s_loadRootCertsOnDemand + if (doVerifyPeer + && s_loadRootCertsOnDemand && allowRootCertOnDemandLoading && !verifyErrorsHaveBeenIgnored()) { //Windows desktop versions starting from vista ship with minimal set of roots @@ -1247,12 +1248,29 @@ bool QSslSocketBackendPrivate::startHandshake() //trusted by MS. //However, this is only transparent if using WinINET - we have to trigger it //ourselves. + QSslCertificate certToFetch; + bool fetchCertificate = true; for (int i=0; i< sslErrors.count(); i++) { - if (sslErrors.at(i).error() == QSslError::UnableToGetLocalIssuerCertificate) { - fetchCaRootForCert(sslErrors.at(i).certificate()); - return false; + switch (sslErrors.at(i).error()) { + case QSslError::UnableToGetLocalIssuerCertificate: + certToFetch = sslErrors.at(i).certificate(); + break; + case QSslError::SelfSignedCertificate: + case QSslError::CertificateBlacklisted: + //With these errors, we know it will be untrusted so save time by not asking windows + fetchCertificate = false; + break; + default: +#ifdef QSSLSOCKET_DEBUG + qDebug() << sslErrors.at(i).errorString(); +#endif + break; } } + if (fetchCertificate && !certToFetch.isNull()) { + fetchCaRootForCert(certToFetch); + return false; + } } #endif diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp index 647e1a692f..089d5681d6 100644 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp +++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp @@ -191,6 +191,26 @@ bool QQnxBpsEventFilter::handleNavigatorEvent(bps_event_t *event) m_navigatorEventHandler->handleExit(); break; + case NAVIGATOR_WINDOW_ACTIVE: { + #if defined(QQNXBPSEVENTFILTER_DEBUG) + qDebug() << "QQNX: Navigator WINDOW ACTIVE event"; + #endif + + const QByteArray id(navigator_event_get_groupid(event)); + m_navigatorEventHandler->handleWindowGroupActivated(id); + break; + } + + case NAVIGATOR_WINDOW_INACTIVE: { + #if defined(QQNXBPSEVENTFILTER_DEBUG) + qDebug() << "QQNX: Navigator WINDOW INACTIVE event"; + #endif + + const QByteArray id(navigator_event_get_groupid(event)); + m_navigatorEventHandler->handleWindowGroupDeactivated(id); + break; + } + default: #if defined(QQNXBPSEVENTFILTER_DEBUG) qDebug() << "QQNX: Unhandled navigator event. code=" << bps_event_get_code(event); diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index 2fa3b45047..73d8cb2007 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -448,6 +448,8 @@ void QQnxIntegration::createDisplays() screen, SLOT(windowClosed(void *))); QObject::connect(m_navigatorEventHandler, SIGNAL(rotationChanged(int)), screen, SLOT(setRotation(int))); + QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupActivated(QByteArray)), screen, SLOT(activateWindowGroup(QByteArray))); + QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupDeactivated(QByteArray)), screen, SLOT(deactivateWindowGroup(QByteArray))); } } diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp index 72227c6089..41b4a2f301 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp @@ -95,4 +95,22 @@ void QQnxNavigatorEventHandler::handleExit() QCoreApplication::quit(); } +void QQnxNavigatorEventHandler::handleWindowGroupActivated(const QByteArray &id) +{ +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << Q_FUNC_INFO << id; +#endif + + Q_EMIT windowGroupActivated(id); +} + +void QQnxNavigatorEventHandler::handleWindowGroupDeactivated(const QByteArray &id) +{ +#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << Q_FUNC_INFO << id; +#endif + + Q_EMIT windowGroupDeactivated(id); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h index 58a1ac8cb3..363374153b 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h @@ -56,9 +56,13 @@ public: void handleOrientationChange(int angle); void handleSwipeDown(); void handleExit(); + void handleWindowGroupActivated(const QByteArray &id); + void handleWindowGroupDeactivated(const QByteArray &id); Q_SIGNALS: void rotationChanged(int angle); + void windowGroupActivated(const QByteArray &id); + void windowGroupDeactivated(const QByteArray &id); }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp index d5220c936e..23e2167a25 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp @@ -197,6 +197,10 @@ void QQnxNavigatorEventNotifier::handleMessage(const QByteArray &msg, const QByt m_eventHandler->handleSwipeDown(); } else if (msg == "exit") { m_eventHandler->handleExit(); + } else if (msg == "windowActive") { + m_eventHandler->handleWindowGroupActivated(dat); + } else if (msg == "windowInactive") { + m_eventHandler->handleWindowGroupDeactivated(dat); } } diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index 27c1357a87..ea0c9e340f 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -348,4 +348,34 @@ void QQnxScreen::windowClosed(void *window) removeOverlayWindow(windowHandle); } +void QQnxScreen::activateWindowGroup(const QByteArray &id) +{ +#if defined(QQNXSCREEN_DEBUG) + qDebug() << Q_FUNC_INFO; +#endif + + if (!rootWindow() || id != rootWindow()->groupName()) + return; + + if (!m_childWindows.isEmpty()) { + // We're picking up the last window of the list here + // because this list is ordered by stacking order. + // Last window is effectively the one on top. + QWindow * const window = m_childWindows.last()->window(); + QWindowSystemInterface::handleWindowActivated(window); + } +} + +void QQnxScreen::deactivateWindowGroup(const QByteArray &id) +{ +#if defined(QQNXSCREEN_DEBUG) + qDebug() << Q_FUNC_INFO; +#endif + + if (!rootWindow() || id != rootWindow()->groupName()) + return; + + QWindowSystemInterface::handleWindowActivated(0); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxscreen.h b/src/plugins/platforms/qnx/qqnxscreen.h index 272cdd6261..7816661323 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.h +++ b/src/plugins/platforms/qnx/qqnxscreen.h @@ -94,6 +94,8 @@ public Q_SLOTS: void setRotation(int rotation); void newWindowCreated(void *window); void windowClosed(void *window); + void activateWindowGroup(const QByteArray &id); + void deactivateWindowGroup(const QByteArray &id); private Q_SLOTS: void keyboardHeightChanged(int height); diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 12ea880ab0..7cd857e3a4 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -770,8 +770,9 @@ void QWindowsNativeFileDialogBase::setDirectory(const QString &directory) QString QWindowsNativeFileDialogBase::directory() const { IShellItem *item = 0; - return (m_fileDialog && item) ? - QWindowsNativeFileDialogBase::itemPath(item) : QString(); + if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&item)) && item) + return QWindowsNativeFileDialogBase::itemPath(item); + return QString(); } void QWindowsNativeFileDialogBase::exec(HWND owner) diff --git a/src/printsupport/kernel/qprinterinfo_unix.cpp b/src/printsupport/kernel/qprinterinfo_unix.cpp index 241986d9e8..b87d2a160b 100644 --- a/src/printsupport/kernel/qprinterinfo_unix.cpp +++ b/src/printsupport/kernel/qprinterinfo_unix.cpp @@ -363,7 +363,7 @@ char *qt_parsePrintersConf(QList<QPrinterDescription> *printers, bool *found) j++; // that's our default printer defaultPrinter = - qstrdup(printerDesc.mid(i, j-i).toAscii().data()); + qstrdup(printerDesc.mid(i, j-i).toLatin1().data()); printerName = QString(); printerDesc = QString(); } else if (printerName == QLatin1String("_all")) { @@ -758,7 +758,7 @@ Q_PRINTSUPPORT_EXPORT int qt_getLprPrinters(QList<QPrinterDescription>& printers if (def.readLine(etcLpDefault.data(), 1024) > 0) { QRegExp rx(QLatin1String("^(\\S+)")); if (rx.indexIn(QString::fromLatin1(etcLpDefault)) != -1) - etcLpDefault = rx.cap(1).toAscii(); + etcLpDefault = rx.cap(1).toLatin1(); } } } diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp index 81f806309a..97c6147b71 100644 --- a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp +++ b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp @@ -202,8 +202,8 @@ void QSqlQuery_snippets() QMapIterator<QString, QVariant> i(query.boundValues()); while (i.hasNext()) { i.next(); - cout << i.key().toAscii().data() << ": " - << i.value().toString().toAscii().data() << endl; + cout << i.key().toUtf8().data() << ": " + << i.value().toString().toUtf8().data() << endl; } //! [14] } @@ -213,7 +213,7 @@ void QSqlQuery_snippets() //! [15] QList<QVariant> list = query.boundValues().values(); for (int i = 0; i < list.size(); ++i) - cout << i << ": " << list.at(i).toString().toAscii().data() << endl; + cout << i << ": " << list.at(i).toString().toUtf8().data() << endl; //! [15] } } diff --git a/src/tools/qdoc/tokenizer.cpp b/src/tools/qdoc/tokenizer.cpp index 7d9039e299..e9906a13c5 100644 --- a/src/tools/qdoc/tokenizer.cpp +++ b/src/tools/qdoc/tokenizer.cpp @@ -512,7 +512,7 @@ void Tokenizer::initialize(const Config &config) QStringList tokens = config.getStringList(LANGUAGE_CPP + Config::dot + CONFIG_IGNORETOKENS); foreach (const QString &t, tokens) { - const QByteArray tb = t.toAscii(); + const QByteArray tb = t.toLatin1(); ignoredTokensAndDirectives->insert(tb, false); insertKwordIntoHash(tb.data(), -1); } @@ -520,7 +520,7 @@ void Tokenizer::initialize(const Config &config) QStringList directives = config.getStringList(LANGUAGE_CPP + Config::dot + CONFIG_IGNOREDIRECTIVES); foreach (const QString &d, directives) { - const QByteArray db = d.toAscii(); + const QByteArray db = d.toLatin1(); ignoredTokensAndDirectives->insert(db, true); insertKwordIntoHash(db.data(), -1); } diff --git a/src/winmain/winmain.pro b/src/winmain/winmain.pro index 04a3756bb5..306304ead0 100644 --- a/src/winmain/winmain.pro +++ b/src/winmain/winmain.pro @@ -7,6 +7,11 @@ CONFIG += staticlib warn_on CONFIG -= qt shared win32 { + win32-msvc*:QMAKE_CFLAGS_DEBUG -= -Zi + win32-msvc*:QMAKE_CXXFLAGS_DEBUG -= -Zi + win32-msvc*:QMAKE_CFLAGS_DEBUG *= -Z7 + win32-msvc*:QMAKE_CXXFLAGS_DEBUG *= -Z7 + win32-g++*:DEFINES += QT_NEEDS_QMAIN win32-g++*:DEFINES += QT_NEEDS_QMAIN win32-borland:DEFINES += QT_NEEDS_QMAIN SOURCES = qtmain_win.cpp diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 616ceeb042..b841debd66 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -1563,7 +1563,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) { #ifdef QT_NO_TEXTCODEC Q_UNUSED(beginning); - return QString::fromAscii(data.constData(), data.size()); + return QString::fromLatin1(data.constData(), data.size()); #else if (data.size() == 0) return QString(); diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index b9b0e8c605..dfcb225555 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -85,8 +85,7 @@ else() message("CMake version older than 2.8.7 (Found ${CMAKE_VERSION}). Not running test \"pass1\"") endif() expect_pass(pass2) -# Modules do not currently find their own dependencies. -# expect_pass(pass3) +expect_pass(pass3) expect_fail(fail4) expect_fail(fail5) expect_pass("pass(needsquoting)6") diff --git a/tests/auto/cmake/pass(needsquoting)6/CMakeLists.txt b/tests/auto/cmake/pass(needsquoting)6/CMakeLists.txt index 7b9561c588..63f675df18 100644 --- a/tests/auto/cmake/pass(needsquoting)6/CMakeLists.txt +++ b/tests/auto/cmake/pass(needsquoting)6/CMakeLists.txt @@ -9,14 +9,14 @@ find_package(Qt5Widgets REQUIRED) include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) -add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}) +add_definitions(${Qt5Core_DEFINITIONS}) set(CMAKE_INCLUDE_CURRENT_DIR ON) qt5_wrap_cpp(moc_files mywidget.h) qt5_wrap_ui(ui_files mywidget.ui) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}") add_executable(mywidget mywidget.cpp ${moc_files} ${ui_files}) -target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Core_LIBRARIES}) +target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES}) diff --git a/tests/auto/cmake/pass1/CMakeLists.txt b/tests/auto/cmake/pass1/CMakeLists.txt index 970ca33078..cbe3afc7c4 100644 --- a/tests/auto/cmake/pass1/CMakeLists.txt +++ b/tests/auto/cmake/pass1/CMakeLists.txt @@ -43,9 +43,6 @@ endmacro() add_executable(two two.cpp) add_executable(three three.cpp) -qt5_use_package(two Core) qt5_use_package(two Test) qt5_use_package(three Widgets) -qt5_use_package(three Gui) -qt5_use_package(three Core) qt5_use_package(three Test) diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 38208d27c8..324e1f5d12 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -474,6 +474,9 @@ void tst_QOpenGL::openGLPaintDevice() QOpenGLContext ctx; ctx.create(); + QSurfaceFormat format = ctx.format(); + if (format.majorVersion() < 2) + QSKIP("This test requires at least OpenGL 2.0"); ctx.makeCurrent(&window); QImage image(128, 128, QImage::Format_RGB32); diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 824f5fc507..90cecba72c 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -4410,9 +4410,8 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress() incomingSocket->setReadBufferSize(1*1024); - QTestEventLoop::instance().enterLoop(2); // some progress should have been made - QVERIFY(!spy.isEmpty()); + QTRY_VERIFY(!spy.isEmpty()); QList<QVariant> args = spy.last(); QVERIFY(args.at(0).toLongLong() > 0); // but not everything! diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp index d8b193f5c8..2b92f7c7b6 100644 --- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp +++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp @@ -138,10 +138,10 @@ public slots: { QUrl url("http://127.0.0.1:1088"); QNetworkRequest req(url); - req.setRawHeader("POST", url.path().toAscii()); + req.setRawHeader("POST", url.path().toLatin1()); req.setRawHeader("user-agent", "xml-test"); req.setRawHeader("keep-alive", "false"); - req.setRawHeader("host", url.host().toAscii()); + req.setRawHeader("host", url.host().toLatin1()); QByteArray xmlrpc("<methodCall>\r\n\ <methodName>SFD.GetVersion</methodName>\r\n\ |