From f24b247961e8a3d22ae385c3e29b7df2fd50b032 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Tue, 21 Jan 2020 08:08:29 +0100 Subject: Doc: Add since version to enum value documentation Fixes: QTBUG-80980 Change-Id: I707c4f45d45cb088fb7419038a448d29a2e8dbf5 Reviewed-by: Leena Miettinen --- src/corelib/global/qnamespace.qdoc | 1 + src/corelib/text/qchar.cpp | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 1908fedead..31e1bcc0da 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1181,6 +1181,7 @@ \value WA_StyleSheetTarget Indicates that the widget appearance was modified by a \l{Qt Style Sheets}{style sheet}. WA_StyleSheet will also be set. + This value was introduced in Qt 5.12. \value WA_TabletTracking Indicates that the widget has tablet tracking enabled. See QWidget::tabletTracking. diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index 9b03a93278..1f9f51a53a 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -411,22 +411,22 @@ QT_BEGIN_NAMESPACE \value Script_Khudawadi \value Script_Tirhuta \value Script_WarangCiti - \value Script_Ahom - \value Script_AnatolianHieroglyphs - \value Script_Hatran - \value Script_Multani - \value Script_OldHungarian - \value Script_SignWriting - \value Script_Adlam - \value Script_Bhaiksuki - \value Script_Marchen - \value Script_Newa - \value Script_Osage - \value Script_Tangut - \value Script_MasaramGondi - \value Script_Nushu - \value Script_Soyombo - \value Script_ZanabazarSquare + \value Script_Ahom This value was introduced in Qt 5.6. + \value Script_AnatolianHieroglyphs This value was introduced in Qt 5.6. + \value Script_Hatran This value was introduced in Qt 5.6. + \value Script_Multani This value was introduced in Qt 5.6. + \value Script_OldHungarian This value was introduced in Qt 5.6. + \value Script_SignWriting This value was introduced in Qt 5.6. + \value Script_Adlam This value was introduced in Qt 5.11. + \value Script_Bhaiksuki This value was introduced in Qt 5.11. + \value Script_Marchen This value was introduced in Qt 5.11. + \value Script_Newa This value was introduced in Qt 5.11. + \value Script_Osage This value was introduced in Qt 5.11. + \value Script_Tangut This value was introduced in Qt 5.11. + \value Script_MasaramGondi This value was introduced in Qt 5.11. + \value Script_Nushu This value was introduced in Qt 5.11. + \value Script_Soyombo This value was introduced in Qt 5.11. + \value Script_ZanabazarSquare This value was introduced in Qt 5.11. \omitvalue ScriptCount -- cgit v1.2.3 From 5399f9443e30f7ca849b8096dbe9ee8c88a35c74 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 29 Jan 2020 11:06:35 +0100 Subject: Fix qt5_make_output_file macro for file base names with dots The qt5_make_output_file macro returns the wrong outfile for infiles containing multiple dots in the file name, e.g. 'foo.bar.h'. To fix this we need to use get_filename_component(... NAME_WLE) which is available since CMake 3.14. Re-implement the NAME_WLE functionality for older CMake versions by using multiple get_filename_component calls. Fixes: QTBUG-80295 Change-Id: Ib8e11a69a41ba7f6739eb3d5541ce8f6f59dc18c Reviewed-by: Alexandru Croitor --- src/corelib/Qt5CoreMacros.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 84c75401b1..02f49a4b1e 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -59,7 +59,14 @@ macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile ) set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}") string(REPLACE ".." "__" _outfile ${_outfile}) get_filename_component(outpath ${_outfile} PATH) - get_filename_component(_outfile ${_outfile} NAME_WE) + if(CMAKE_VERSION VERSION_LESS "3.14") + get_filename_component(_outfile_ext ${_outfile} EXT) + get_filename_component(_outfile_ext ${_outfile_ext} NAME_WE) + get_filename_component(_outfile ${_outfile} NAME_WE) + string(APPEND _outfile ${_outfile_ext}) + else() + get_filename_component(_outfile ${_outfile} NAME_WLE) + endif() file(MAKE_DIRECTORY ${outpath}) set(${outfile} ${outpath}/${prefix}${_outfile}.${ext}) endmacro() -- cgit v1.2.3 From 45967dfbd8192a14a324a75377d1860891845fbf Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 18:03:59 +0100 Subject: Simplify textdate/datestring #if-ery Since datestring implies textdate, we don't need to check the latter inside the #if-ery of the former. Change-Id: I01e648245bc7707db024eac925092ed816173781 Reviewed-by: Thiago Macieira --- src/corelib/time/qdatetime.cpp | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index a8d643d483..cde8587094 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1098,9 +1098,8 @@ QString QDate::longDayName(int weekday, MonthNameType type) } #endif // textdate && deprecated -#if QT_CONFIG(datestring) +#if QT_CONFIG(datestring) // depends on, so implies, textdate -#if QT_CONFIG(textdate) static QString toStringTextDate(QDate date, QCalendar cal) { if (date.isValid()) { @@ -1119,7 +1118,6 @@ static QString toStringTextDate(QDate date) { return toStringTextDate(date, QCalendar()); } -#endif // textdate static QString toStringIsoDate(const QDate &date) { @@ -1193,10 +1191,8 @@ QString QDate::toString(Qt::DateFormat format) const case Qt::RFC2822Date: return QLocale::c().toString(*this, u"dd MMM yyyy"); default: -#if QT_CONFIG(textdate) case Qt::TextDate: return toStringTextDate(*this); -#endif case Qt::ISODate: case Qt::ISODateWithMs: return toStringIsoDate(*this); @@ -1292,10 +1288,8 @@ QString QDate::toString(Qt::DateFormat format, QCalendar cal) const case Qt::RFC2822Date: return QLocale::c().toString(*this, QStringView(u"dd MMM yyyy"), cal); default: -#ifndef QT_NO_TEXTDATE case Qt::TextDate: return toStringTextDate(*this, cal); -#endif case Qt::ISODate: case Qt::ISODateWithMs: return toStringIsoDate(*this); @@ -1625,7 +1619,7 @@ qint64 QDate::daysTo(const QDate &d) const \sa QTime::currentTime(), QDateTime::currentDateTime() */ -#if QT_CONFIG(datestring) +#if QT_CONFIG(datestring) // depends on, so implies, textdate namespace { struct ParsedInt { int value = 0; bool ok = false; }; @@ -1680,7 +1674,6 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format) case Qt::RFC2822Date: return rfcDateImpl(string).date; default: -#if QT_CONFIG(textdate) case Qt::TextDate: { QVector parts = string.splitRef(QLatin1Char(' '), QString::SkipEmptyParts); @@ -1699,7 +1692,6 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format) return QDate(year, month, day); } -#endif // textdate case Qt::ISODate: // Semi-strict parsing, must be long enough and have punctuators as separators if (string.size() >= 10 && string.at(4).isPunct() && string.at(7).isPunct() @@ -2014,7 +2006,7 @@ int QTime::msec() const return ds() % 1000; } -#if QT_CONFIG(datestring) +#if QT_CONFIG(datestring) // depends on, so implies, textdate /*! \overload @@ -2347,7 +2339,7 @@ int QTime::msecsTo(const QTime &t) const \sa QDateTime::currentDateTime(), QDateTime::currentDateTimeUtc() */ -#if QT_CONFIG(datestring) +#if QT_CONFIG(datestring) // depends on, so implies, textdate static QTime fromIsoTimeString(QStringView string, Qt::DateFormat format, bool *isMidnight24) { @@ -4292,7 +4284,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC) } #endif -#if QT_CONFIG(datestring) +#if QT_CONFIG(datestring) // depends on, so implies, textdate /*! \fn QString QDateTime::toString(Qt::DateFormat format) const @@ -4365,7 +4357,6 @@ QString QDateTime::toString(Qt::DateFormat format) const return buf; } default: -#if QT_CONFIG(textdate) case Qt::TextDate: { const QPair p = getDateTime(d); buf = p.first.toString(Qt::TextDate); @@ -4376,11 +4367,11 @@ QString QDateTime::toString(Qt::DateFormat format) const switch (timeSpec()) { case Qt::LocalTime: break; -# if QT_CONFIG(timezone) +#if QT_CONFIG(timezone) case Qt::TimeZone: buf += QLatin1Char(' ') + d->m_timeZone.abbreviation(*this); break; -# endif +#endif default: buf += QLatin1String(" GMT"); if (getSpec(d) == Qt::OffsetFromUTC) @@ -4388,7 +4379,6 @@ QString QDateTime::toString(Qt::DateFormat format) const } return buf; } -#endif case Qt::ISODate: case Qt::ISODateWithMs: { const QPair p = getDateTime(d); @@ -5202,7 +5192,7 @@ int QDateTime::utcOffset() const } #endif // QT_DEPRECATED_SINCE -#if QT_CONFIG(datestring) +#if QT_CONFIG(datestring) // depends on, so implies, textdate /*! Returns the QDateTime represented by the \a string, using the @@ -5306,7 +5296,6 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) date = date.addDays(1); return QDateTime(date, time, spec, offset); } -#if QT_CONFIG(textdate) case Qt::TextDate: { QVector parts = string.splitRef(QLatin1Char(' '), QString::SkipEmptyParts); @@ -5412,7 +5401,6 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) return QDateTime(date, time, Qt::UTC); } } -#endif // textdate } return QDateTime(); -- cgit v1.2.3 From 2130d282b1a2671049c90dd4e99e512b8009de9a Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 18:21:58 +0100 Subject: Change examples and snippets to pass QDate and QTime by value They're value types, so we should show them being used as such. Change-Id: If9f0c366fac66306b7861f04e2f047540d444acc Reviewed-by: Christian Ehrlicher --- src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp | 4 ++-- src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp index 9813cc98d5..e070ada069 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -151,7 +151,7 @@ class Employee { public: Employee() {} - Employee(const QString &name, const QDate &dateOfBirth); + Employee(const QString &name, QDate dateOfBirth); ... private: diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp index 506022f082..145cd10d84 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp @@ -151,7 +151,7 @@ class Employee { public: Employee() {} - Employee(const QString &name, const QDate &dateOfBirth); + Employee(const QString &name, QDate dateOfBirth); ... private: -- cgit v1.2.3 From 3041393d2e6dc094652334fcb4bc35597632d228 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 24 Jan 2020 15:48:41 +0100 Subject: Fix flawed logic in QSystemLocalePrivate::getLocaleInfo() If the first call to GetLocaleInfo() returned non-zero, then GetLastError()'s return has nothing to do with GetLocaleInfo(), since it didn't fail. The check for ERROR_INSUFFICIENT_BUFFER as last error needs to happen in the branch where GetLocaleInfo() failed, returning zero. Change-Id: Idb6eaad1515a003133c787998aff0c265ef98251 Reviewed-by: Friedemann Kleint --- src/corelib/text/qlocale_win.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index 4b4152c519..d7319c1532 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -214,9 +214,9 @@ inline int QSystemLocalePrivate::getLocaleInfo(LCTYPE type, LPWSTR data, int siz QString QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen) { QVarLengthArray buf(maxlen ? maxlen : 64); - if (!getLocaleInfo(type, buf.data(), buf.size())) - return QString(); - if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + if (!getLocaleInfo(type, buf.data(), buf.size())) { + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + return QString(); int cnt = getLocaleInfo(type, 0, 0); if (cnt == 0) return QString(); -- cgit v1.2.3 From 9ede07613dc5b7759f398d5a8839b2ffdb4675a2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Jan 2020 16:59:59 -0800 Subject: QLockFile: Disable flock() on QNX It appears it's not implemented. [ChangeLog][QtCore][QLockFile] Suppressed the warning on QNX that said 'setNativeLocks failed: "Function not implemented"'. There is no difference in behavior: Qt will continue not to be able to apply an OS- level file lock, which means the lock could be accidentally stolen by buggy software. Correct software using QLockFile should not be affected. Fixes: QTBUG-81701 Change-Id: If79a52e476594446baccfffd15ee35bbac6c6e47 Reviewed-by: David Faure --- src/corelib/io/qlockfile_unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index b2bf77c0da..ce2b7e8faa 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -58,7 +58,8 @@ #include // flock #endif -#if defined(Q_OS_RTEMS) +#if defined(Q_OS_RTEMS) || defined(Q_OS_QNX) +// flock() does not work in these OSes and produce warnings when we try to use # undef LOCK_EX # undef LOCK_NB #endif -- cgit v1.2.3 From 2b1068af97f1483b7bdb3d7a9257ab59fc4b2b59 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 18:28:07 +0100 Subject: Pass QDate and QTime by value in various static and local functions They're value types, so pass them as such. Change-Id: I0dc46c63a3a0e6d859b821362f71390f0148b64c Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale_mac.mm | 4 ++-- src/corelib/time/qdatetime.cpp | 10 +++++----- src/corelib/time/qdatetimeparser.cpp | 2 +- src/corelib/time/qtimezoneprivate_win.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm index 31ede1352b..7bdae662c7 100644 --- a/src/corelib/text/qlocale_mac.mm +++ b/src/corelib/text/qlocale_mac.mm @@ -119,7 +119,7 @@ static QString macDayName(int day, bool short_format) return QString(); } -static QString macDateToString(const QDate &date, bool short_format) +static QString macDateToString(QDate date, bool short_format) { QCFType myDate = QDateTime(date, QTime()).toCFDate(); QCFType mylocale = CFLocaleCopyCurrent(); @@ -131,7 +131,7 @@ static QString macDateToString(const QDate &date, bool short_format) return QCFString(CFDateFormatterCreateStringWithDate(0, myFormatter, myDate)); } -static QString macTimeToString(const QTime &time, bool short_format) +static QString macTimeToString(QTime time, bool short_format) { QCFType myDate = QDateTime(QDate::currentDate(), time).toCFDate(); QCFType mylocale = CFLocaleCopyCurrent(); diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index cde8587094..a5761055ed 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -682,7 +682,7 @@ static bool inDateTimeRange(qint64 jd, bool start) return jd >= minDay && jd < maxDay; } -static QDateTime toEarliest(const QDate &day, const QDateTime &form) +static QDateTime toEarliest(QDate day, const QDateTime &form) { const Qt::TimeSpec spec = form.timeSpec(); const int offset = (spec == Qt::OffsetFromUTC) ? form.offsetFromUtc() : 0; @@ -806,7 +806,7 @@ QDateTime QDate::startOfDay(const QTimeZone &zone) const } #endif // timezone -static QDateTime toLatest(const QDate &day, const QDateTime &form) +static QDateTime toLatest(QDate day, const QDateTime &form) { const Qt::TimeSpec spec = form.timeSpec(); const int offset = (spec == Qt::OffsetFromUTC) ? form.offsetFromUtc() : 0; @@ -1119,7 +1119,7 @@ static QString toStringTextDate(QDate date) return toStringTextDate(date, QCalendar()); } -static QString toStringIsoDate(const QDate &date) +static QString toStringIsoDate(QDate date) { const auto parts = QCalendar().partsFromDate(date); if (parts.isValid() && parts.year >= 0 && parts.year <= 9999) @@ -2869,7 +2869,7 @@ static void msecsToTime(qint64 msecs, QDate *date, QTime *time) } // Converts a date/time value into msecs -static qint64 timeToMSecs(const QDate &date, const QTime &time) +static qint64 timeToMSecs(QDate date, QTime time) { return ((date.toJulianDay() - JULIAN_DAY_FOR_EPOCH) * MSECS_PER_DAY) + time.msecsSinceStartOfDay(); @@ -3214,7 +3214,7 @@ static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds) } } -static void setDateTime(QDateTimeData &d, const QDate &date, const QTime &time) +static void setDateTime(QDateTimeData &d, QDate date, QTime time) { // If the date is valid and the time is not we set time to 00:00:00 QTime useTime = time; diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 2636928e69..2f7cbb4017 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -903,7 +903,7 @@ QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex, by \a weekDay. */ -static int weekDayWithinMonth(const QCalendar &calendar, const QDate &rough, int weekDay) +static int weekDayWithinMonth(QCalendar calendar, QDate rough, int weekDay) { // TODO: can we adapt this to cope gracefully with intercallary days (day of // week > 7) without making it slower for more widely-used calendars ? diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp index 0fec5355b2..0aaf469ed9 100644 --- a/src/corelib/time/qtimezoneprivate_win.cpp +++ b/src/corelib/time/qtimezoneprivate_win.cpp @@ -363,7 +363,7 @@ QDate calculateTransitionLocalDate(const SYSTEMTIME &rule, int year) } // Converts a date/time value into msecs -inline qint64 timeToMSecs(const QDate &date, const QTime &time) +inline qint64 timeToMSecs(QDate date, QTime time) { return ((date.toJulianDay() - JULIAN_DAY_FOR_EPOCH) * MSECS_PER_DAY) + time.msecsSinceStartOfDay(); -- cgit v1.2.3 From 5ac1516edd17eb4ddd94fe43a04fa4d736c50041 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 30 Jan 2020 15:16:18 +0100 Subject: Check for (__ARM_FP & 2) to verify 16-bit FP support It appears __ARM_FP16_FORMAT_IEEE is sometimes incorrectly set, and we need to double-check that 16-bit floating point is available in the __ARM_FP macro as well. Task-number: QTBUG-68314 Fixes: QTBUG-81461 Change-Id: I878d6b286aa31e21271163dc6c8f8038b9534c76 Reviewed-by: BogDan Vatra Reviewed-by: Thiago Macieira --- src/corelib/global/qfloat16.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index c868e879b7..0c9bb80cb2 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -205,7 +205,7 @@ f16cextern void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype #undef f16cextern } -#elif defined(__ARM_FP16_FORMAT_IEEE) && defined(__ARM_NEON__) +#elif defined(__ARM_FP16_FORMAT_IEEE) && defined(__ARM_NEON__) && (__ARM_FP & 2) static inline bool hasFastF16() { return true; -- cgit v1.2.3 From aadf21b25cad7026f07a5fe7bf19fbedfb1866b7 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 31 Jan 2020 16:47:46 +0100 Subject: Fix 'the the' typo in comments Change-Id: I00fcb1c2374e7ca168b6240f9d41c0323fb0867c Reviewed-by: Giuseppe D'Angelo --- src/corelib/io/qiodevice.cpp | 2 +- src/corelib/kernel/qcore_mac_objc.mm | 2 +- src/corelib/tools/qbitarray.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index e26508e631..076b2394ba 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -714,7 +714,7 @@ void QIODevicePrivate::setReadChannelCount(int count) /*! \since 5.7 - Returns the the index of the current write channel. + Returns the index of the current write channel. \sa setCurrentWriteChannel(), writeChannelCount() */ diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index b1f3b74cd4..a042361686 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -247,7 +247,7 @@ AppleApplication *qt_apple_sharedApplication() qWarning() << "accessing the shared" << [AppleApplication class] << "is not allowed in application extensions"; - // In practice the application is actually available, but the the App + // In practice the application is actually available, but the App // review process will likely catch uses of it, so we return nil just // in case, unless we don't care about being App Store compliant. #if QT_CONFIG(appstore_compliant) diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index f0b81cce66..ab3054d5be 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -305,7 +305,7 @@ void QBitArray::fill(bool value, int begin, int end) \since 5.11 Returns a pointer to a dense bit array for this QBitArray. Bits are counted - upwards from the least significant bit in each byte. The the number of bits + upwards from the least significant bit in each byte. The number of bits relevant in the last byte is given by \c{size() % 8}. \sa fromBits(), size() -- cgit v1.2.3 From a049325cc708b483ed1aadc6589419f4d74b19f3 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 20 Jan 2020 15:54:42 +0100 Subject: Win: work around (estimated) 32k char limit for OutputDebugString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reaching a certain number of characters, OutputDebugString will just eat the string and not give any output. As there is no way of handling that error properly we divide the string into usable chunks. Fixes: QTBUG-80996 Change-Id: Ic7ef34c48c212cbaec3a03790d1020506b7b4319 Reviewed-by: Miguel Costa Reviewed-by: Friedemann Kleint Reviewed-by: MÃ¥rten Nordheim --- src/corelib/global/qlogging.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 5a7f8242de..c1dd04f03c 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1669,14 +1669,34 @@ static bool android_default_message_handler(QtMsgType type, #endif //Q_OS_ANDROID #ifdef Q_OS_WIN +static void win_outputDebugString_helper(QStringView message) +{ + const int maxOutputStringLength = 32766; + static QBasicMutex m; + auto locker = qt_unique_lock(m); + // fast path: Avoid string copies if one output is enough + if (message.length() <= maxOutputStringLength) { + OutputDebugString(reinterpret_cast(message.utf16())); + } else { + wchar_t *messagePart = new wchar_t[maxOutputStringLength + 1]; + for (int i = 0; i < message.length(); i += maxOutputStringLength ) { + const int length = std::min(message.length() - i, maxOutputStringLength ); + const int len = message.mid(i, length).toWCharArray(messagePart); + Q_ASSERT(len == length); + messagePart[len] = 0; + OutputDebugString(messagePart); + } + delete[] messagePart; + } +} + static bool win_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &message) { if (shouldLogToStderr()) return false; // Leave logging up to stderr handler - QString formattedMessage = qFormatLogMessage(type, context, message); - formattedMessage.append(QLatin1Char('\n')); - OutputDebugString(reinterpret_cast(formattedMessage.utf16())); + const QString formattedMessage = qFormatLogMessage(type, context, message).append('\n'); + win_outputDebugString_helper(formattedMessage); return true; // Prevent further output to stderr } @@ -1832,11 +1852,11 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex static void qt_message_print(const QString &message) { #if defined(Q_OS_WINRT) - OutputDebugString(reinterpret_cast(message.utf16())); + win_outputDebugString_helper(message); return; #elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) if (!shouldLogToStderr()) { - OutputDebugString(reinterpret_cast(message.utf16())); + win_outputDebugString_helper(message); return; } #endif -- cgit v1.2.3 From e0f9b57462226b4f5842d1e857612d6c8fbe38fd Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 24 Jan 2020 16:01:33 +0100 Subject: qlocale_win.cpp: distinguish empty QString from null QVariant An empty string, when packaged as a QVariant, is non-null (as a QVariant); and QSystemLocale::query()'s callers care about the difference. Some callers of the internal getLocaleInfo(LCTYPE type, int maxlen) need an actual QString return, while others are what query() returns, so need to return a QVariant; where the former want an empty string, the latter need a null QVariant. So make that getLocaleInfo() into a template, so callers can chose QString or QVariant as return type, only affecting the failure returns. Change-Id: I7b9a698badedc0e0d8aef8c6e85c22931c33297a Reviewed-by: Friedemann Kleint Reviewed-by: Volker Hilsheimer --- src/corelib/text/qlocale_win.cpp | 55 +++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index d7319c1532..faaa15cf6b 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -106,11 +106,11 @@ struct QSystemLocalePrivate { QSystemLocalePrivate(); - QString zeroDigit(); - QString decimalPoint(); - QString groupSeparator(); - QString negativeSign(); - QString positiveSign(); + QVariant zeroDigit(); + QVariant decimalPoint(); + QVariant groupSeparator(); + QVariant negativeSign(); + QVariant positiveSign(); QVariant dateFormat(QLocale::FormatType); QVariant timeFormat(QLocale::FormatType); QVariant dateTimeFormat(QLocale::FormatType); @@ -150,7 +150,9 @@ private: QString zero; // cached value for zeroDigit() int getLocaleInfo(LCTYPE type, LPWSTR data, int size); - QString getLocaleInfo(LCTYPE type, int maxlen = 0); + // Need to distinguish empty QString packaged as (non-null) QVariant from null QVariant: + template + T getLocaleInfo(LCTYPE type, int maxlen = 0); int getLocaleInfo_int(LCTYPE type, int maxlen = 0); int getCurrencyFormat(DWORD flags, LPCWSTR value, const CURRENCYFMTW *format, LPWSTR data, int size); @@ -211,18 +213,19 @@ inline int QSystemLocalePrivate::getLocaleInfo(LCTYPE type, LPWSTR data, int siz #endif } -QString QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen) +template +T QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen) { QVarLengthArray buf(maxlen ? maxlen : 64); if (!getLocaleInfo(type, buf.data(), buf.size())) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) - return QString(); + return {}; int cnt = getLocaleInfo(type, 0, 0); if (cnt == 0) - return QString(); + return {}; buf.resize(cnt); if (!getLocaleInfo(type, buf.data(), buf.size())) - return QString(); + return {}; } return QString::fromWCharArray(buf.data()); } @@ -298,7 +301,7 @@ QString &QSystemLocalePrivate::substituteDigits(QString &string) return string; } -QString QSystemLocalePrivate::zeroDigit() +QVariant QSystemLocalePrivate::zeroDigit() { if (zero.isEmpty()) { /* Ten digits plus a terminator. @@ -317,24 +320,24 @@ QString QSystemLocalePrivate::zeroDigit() return zero; } -QString QSystemLocalePrivate::decimalPoint() +QVariant QSystemLocalePrivate::decimalPoint() { - return getLocaleInfo(LOCALE_SDECIMAL); + return getLocaleInfo(LOCALE_SDECIMAL); } -QString QSystemLocalePrivate::groupSeparator() +QVariant QSystemLocalePrivate::groupSeparator() { - return getLocaleInfo(LOCALE_STHOUSAND); + return getLocaleInfo(LOCALE_STHOUSAND); } -QString QSystemLocalePrivate::negativeSign() +QVariant QSystemLocalePrivate::negativeSign() { - return getLocaleInfo(LOCALE_SNEGATIVESIGN); + return getLocaleInfo(LOCALE_SNEGATIVESIGN); } -QString QSystemLocalePrivate::positiveSign() +QVariant QSystemLocalePrivate::positiveSign() { - return getLocaleInfo(LOCALE_SPOSITIVESIGN); + return getLocaleInfo(LOCALE_SPOSITIVESIGN); } QVariant QSystemLocalePrivate::dateFormat(QLocale::FormatType type) @@ -392,10 +395,10 @@ QVariant QSystemLocalePrivate::dayName(int day, QLocale::FormatType type) day -= 1; if (type == QLocale::LongFormat) - return getLocaleInfo(long_day_map[day]); + return getLocaleInfo(long_day_map[day]); if (type == QLocale::NarrowFormat) - return getLocaleInfo(narrow_day_map[day]); - return getLocaleInfo(short_day_map[day]); + return getLocaleInfo(narrow_day_map[day]); + return getLocaleInfo(short_day_map[day]); } QVariant QSystemLocalePrivate::monthName(int month, QLocale::FormatType type) @@ -418,7 +421,7 @@ QVariant QSystemLocalePrivate::monthName(int month, QLocale::FormatType type) LCTYPE lctype = (type == QLocale::ShortFormat || type == QLocale::NarrowFormat) ? short_month_map[month] : long_month_map[month]; - return getLocaleInfo(lctype); + return getLocaleInfo(lctype); } QVariant QSystemLocalePrivate::toString(QDate date, QLocale::FormatType type) @@ -485,7 +488,7 @@ QVariant QSystemLocalePrivate::measurementSystem() QVariant QSystemLocalePrivate::collation() { - return getLocaleInfo(LOCALE_SSORTLOCALE); + return getLocaleInfo(LOCALE_SSORTLOCALE); } QVariant QSystemLocalePrivate::amText() @@ -687,12 +690,12 @@ QVariant QSystemLocalePrivate::uiLanguages() QVariant QSystemLocalePrivate::nativeLanguageName() { - return getLocaleInfo(LOCALE_SNATIVELANGUAGENAME); + return getLocaleInfo(LOCALE_SNATIVELANGUAGENAME); } QVariant QSystemLocalePrivate::nativeCountryName() { - return getLocaleInfo(LOCALE_SNATIVECOUNTRYNAME); + return getLocaleInfo(LOCALE_SNATIVECOUNTRYNAME); } -- cgit v1.2.3 From 3730452bfe098f8cdc68ec2183dd283a17f7ad39 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 10:53:01 +0100 Subject: Fall back to "+" if MS returns empty string for positive sign MS's documentation says empty means "+" here, so implement that fallback (which shall over-ride whatever the CLDR has given us for the fallbackUiLanguage's positive sign). Task-number: QTBUG-81530 Change-Id: Ic3f10dd061d0c46d1433f29b8065988da94c38e6 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale_win.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index faaa15cf6b..4a38adf309 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -216,9 +216,17 @@ inline int QSystemLocalePrivate::getLocaleInfo(LCTYPE type, LPWSTR data, int siz template T QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen) { + // https://docs.microsoft.com/en-us/windows/win32/intl/locale-spositivesign + // says empty for LOCALE_SPOSITIVESIGN means "+", although GetLocaleInfo() + // is documented to return 0 only on failure, so it's not clear how it + // returns empty to mean this; hence the two checks for it below. + const QString plus = QStringLiteral("+"); QVarLengthArray buf(maxlen ? maxlen : 64); if (!getLocaleInfo(type, buf.data(), buf.size())) { - if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + const auto lastError = GetLastError(); + if (type == LOCALE_SPOSITIVESIGN && lastError == ERROR_SUCCESS) + return plus; + if (lastError != ERROR_INSUFFICIENT_BUFFER) return {}; int cnt = getLocaleInfo(type, 0, 0); if (cnt == 0) @@ -227,6 +235,8 @@ T QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen) if (!getLocaleInfo(type, buf.data(), buf.size())) return {}; } + if (type == LOCALE_SPOSITIVESIGN && !buf[0]) + return plus; return QString::fromWCharArray(buf.data()); } -- cgit v1.2.3 From 71fa90a37c4f250aa4a6ae8e6bd957dd372566c8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 6 Jan 2020 13:15:06 +0100 Subject: Enable system locale to skip digit-grouping if configured to do so On macOS it's possible to configure the system locale to not do digit grouping (separating "thousands", in most western locales); it then returns an empty string when asked for the grouping character, which QLocale's system-configuration then ignored, falling back on using the base UI locale's grouping separator. This could lead to the same separator being used for decimal and grouping, which should never happen, least of all when configured to not group at all. In order to notice when this happens, query() must take care to return an empty QString (as a QVariant, which is then non-null) when it *has* a value for the locale property, and that value is empty, as opposed to a null QVariant when it doesn't find a configured value. The caller can then distinguish the two cases. Furthermore, the group and decimal separators need to be distinct, so we need to take care to avoid cases where the system overrides one with what the CLDR has given for the other and doesn't over-ride that other. Only presently implemented for macOS and MS-Win, since the (other) Unix implementation of the system locale returns single QChar values for the numeric tokens - see QTBUG-69324, QTBUG-81053. Fixes: QTBUG-80459 Change-Id: Ic3fbb0fb86e974604a60781378b09abc13bab15d Reviewed-by: Ulf Hermann --- src/corelib/text/qlocale.cpp | 36 ++++++++++++++++++++++++++++++++---- src/corelib/text/qlocale_mac.mm | 16 +++++++--------- src/corelib/text/qlocale_p.h | 4 ++-- 3 files changed, 41 insertions(+), 15 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 26db674a99..11e788c200 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -660,6 +660,11 @@ static QLocalePrivate *c_private() return &c_locale; } +static const QLocaleData *systemData(); +static QLocale::NumberOptions system_number_options = QLocale::DefaultNumberOptions; +Q_GLOBAL_STATIC_WITH_ARGS(QExplicitlySharedDataPointer, systemLocalePrivate, + (QLocalePrivate::create(systemData(), system_number_options))) + #ifndef QT_NO_SYSTEMLOCALE /****************************************************************************** ** Default system locale behavior @@ -711,6 +716,7 @@ static void updateSystemPrivate() { // This function is NOT thread-safe! // It *should not* be called by anything but systemData() + // It *is* called before {system,default}LocalePrivate exist. const QSystemLocale *sys_locale = systemLocale(); // tell the object that the system locale has changed. @@ -718,11 +724,14 @@ static void updateSystemPrivate() // Populate global with fallback as basis: globalLocaleData = *sys_locale->fallbackUiLocaleData(); + system_number_options = QLocale::DefaultNumberOptions; QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant()); if (!res.isNull()) { globalLocaleData.m_language_id = res.toInt(); globalLocaleData.m_script_id = QLocale::AnyScript; // default for compatibility + if (globalLocaleData.m_language_id == QLocale::C) + system_number_options = QLocale::OmitGroupSeparator; } res = sys_locale->query(QSystemLocale::CountryId, QVariant()); if (!res.isNull()) { @@ -737,9 +746,26 @@ static void updateSystemPrivate() if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_decimal = res.toString().at(0).unicode(); + // System may supply empty group separator to say we should omit grouping; + // and it makes no sense to use the same separator for decimal and grouping + // (which might happen by system supplying, as decimal, what CLDR has given + // us for grouping; or the other way round). Assume, at least, that each of + // system and CLDR has decimal != group, all the same. res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant()); - if (!res.isNull() && !res.toString().isEmpty()) - globalLocaleData.m_group = res.toString().at(0).unicode(); + if (res.isNull()) { + // The case where system over-rides decimal but not group, and its + // decimal clashes with CLDR's group. + if (globalLocaleData.m_group == globalLocaleData.m_decimal) + system_number_options |= QLocale::OmitGroupSeparator; + } else if (res.toString().isEmpty()) { + system_number_options |= QLocale::OmitGroupSeparator; + } else { + const ushort group = res.toString().at(0).unicode(); + if (group != globalLocaleData.m_decimal) + globalLocaleData.m_group = group; + else if (group == globalLocaleData.m_group) + qWarning("System-supplied decimal and grouping character are both 0x%hx", group); + } res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant()); if (!res.isNull() && !res.toString().isEmpty()) @@ -752,6 +778,10 @@ static void updateSystemPrivate() res = sys_locale->query(QSystemLocale::PositiveSign, QVariant()); if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_plus = res.toString().at(0).unicode(); + + if (systemLocalePrivate.exists()) + systemLocalePrivate->data()->m_numberOptions = system_number_options; + // else: system_number_options will be passed to create() when constructing. } #endif // !QT_NO_SYSTEMLOCALE @@ -834,8 +864,6 @@ static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1; Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer, defaultLocalePrivate, (QLocalePrivate::create(defaultData()))) -Q_GLOBAL_STATIC_WITH_ARGS(QExplicitlySharedDataPointer, systemLocalePrivate, - (QLocalePrivate::create(systemData()))) static QLocalePrivate *localePrivateByName(const QString &name) { diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm index 7bdae662c7..5381f0f975 100644 --- a/src/corelib/text/qlocale_mac.mm +++ b/src/corelib/text/qlocale_mac.mm @@ -283,10 +283,12 @@ static QString getMacTimeFormat(CFDateFormatterStyle style) return macToQtFormat(QString::fromCFString(CFDateFormatterGetFormat(formatter))); } -static QString getCFLocaleValue(CFStringRef key) +static QVariant getCFLocaleValue(CFStringRef key) { QCFType locale = CFLocaleCopyCurrent(); CFTypeRef value = CFLocaleGetValue(locale, key); + if (!value) + return QVariant(); return QString::fromCFString(CFStringRef(static_cast(value))); } @@ -411,14 +413,10 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const switch(type) { // case Name: // return getMacLocaleName(); - case DecimalPoint: { - QString value = getCFLocaleValue(kCFLocaleDecimalSeparator); - return value.isEmpty() ? QVariant() : value; - } - case GroupSeparator: { - QString value = getCFLocaleValue(kCFLocaleGroupingSeparator); - return value.isEmpty() ? QVariant() : value; - } + case DecimalPoint: + return getCFLocaleValue(kCFLocaleDecimalSeparator); + case GroupSeparator: + return getCFLocaleValue(kCFLocaleGroupingSeparator); case DateFormatLong: case DateFormatShort: return getMacDateFormat(type == DateFormatShort diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index bb24009523..7e26e86fdf 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -87,7 +87,7 @@ public: LanguageId, // uint CountryId, // uint DecimalPoint, // QString - GroupSeparator, // QString + GroupSeparator, // QString (empty QString means: don't group digits) ZeroDigit, // QString NegativeSign, // QString DateFormatLong, // QString -- cgit v1.2.3 From 056230cc9c3309823a93df0e34c92affb29df9e4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Jan 2020 14:32:06 -0800 Subject: qfloat16: include the tables in AVX2 binaries regardless Having a QtCore build optimized for AVX2 does not imply all user binaries and libraries are optimized the same way. Most of them will actually have been built for the base platform, which means they require access to these tables to operate if they are using qfloat16. Introduced by 5e40d3d982d014cd01db4dbe6aecc6ea6baf840a. Change-Id: If79a52e476594446baccfffd15ee2da9e3693cce Reviewed-by: Allan Sandfeld Jensen --- src/corelib/global/qfloat16tables.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qfloat16tables.cpp b/src/corelib/global/qfloat16tables.cpp index 3d764937d7..b87986d6b8 100644 --- a/src/corelib/global/qfloat16tables.cpp +++ b/src/corelib/global/qfloat16tables.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE -#if !defined(__F16C__) && !defined(__ARM_FP16_FORMAT_IEEE) +#if !defined(__ARM_FP16_FORMAT_IEEE) const quint32 qfloat16::mantissatable[2048] = { 0, -- cgit v1.2.3