From 78edc18057d04a8329060b52d78833711bcadf39 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 25 Jan 2020 00:48:48 +0100 Subject: [PATCH 01/37] QGraphicsProxyWidget: fix handling of proxy focus If a widget inside a QGPW has a proxy focus, the code would keep sending focus in events to the proxy even if the proxy was already focused. Amend the check in place to prevent this from happening. Change-Id: Id28d3bfe4f396da5c9477df713441ca7d506662f Fixes: QTBUG-51856 Reviewed-by: Christian Ehrlicher Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qwidget.cpp | 2 +- .../tst_qgraphicsproxywidget.cpp | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c389c4ab4d8..8ec7f7e0722 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6309,7 +6309,7 @@ void QWidget::setFocus(Qt::FocusReason reason) previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); if (previousProxyFocus && previousProxyFocus->focusProxy()) previousProxyFocus = previousProxyFocus->focusProxy(); - if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus) + if (previousProxyFocus == f && !topData->proxyWidget->d_func()->proxyIsGivingFocus) return; } } diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index a437b054792..8c2d89e34bf 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -89,6 +89,7 @@ private slots: void focusNextPrevChild(); void focusOutEvent_data(); void focusOutEvent(); + void focusProxy_QTBUG_51856(); void hoverEnterLeaveEvent_data(); void hoverEnterLeaveEvent(); void hoverMoveEvent_data(); @@ -864,6 +865,75 @@ void tst_QGraphicsProxyWidget::focusOutEvent() } } +void tst_QGraphicsProxyWidget::focusProxy_QTBUG_51856() +{ + // QSpinBox has an internal QLineEdit; this QLineEdit has the spinbox + // as its focus proxy. + struct FocusedSpinBox : QSpinBox + { + int focusCount = 0; + + bool event(QEvent *event) override + { + switch (event->type()) { + case QEvent::FocusIn: + ++focusCount; + break; + case QEvent::FocusOut: + --focusCount; + break; + default: + break; + } + return QSpinBox::event(event); + } + }; + + QGraphicsScene scene; + QGraphicsView view(&scene); + SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; + scene.addItem(proxy); + view.show(); + view.raise(); + view.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + FocusedSpinBox *spinBox = new FocusedSpinBox; + + proxy->setWidget(spinBox); + proxy->show(); + proxy->setFocus(); + QVERIFY(proxy->hasFocus()); + QEXPECT_FAIL("", "Widget should have focus but doesn't", Continue); + QVERIFY(spinBox->hasFocus()); + QEXPECT_FAIL("", "Widget should have focus but doesn't", Continue); + QCOMPARE(spinBox->focusCount, 1); + + enum { Count = 10 }; + + for (int i = 0; i < Count; ++i) { + for (int clickCount = 0; clickCount < Count; ++clickCount) { + auto proxyCenter = proxy->boundingRect().center(); + auto proxyCenterInScene = proxy->mapToScene(proxyCenter); + auto proxyCenterInView = view.mapFromScene(proxyCenterInScene); + + QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, proxyCenterInView); + QTRY_COMPARE(spinBox->focusCount, 1); + } + + QLineEdit *edit = new QLineEdit(&view); + edit->show(); + QTRY_VERIFY(edit->isVisible()); + edit->setFocus(); + QTRY_VERIFY(edit->hasFocus()); + QTRY_VERIFY(!proxy->hasFocus()); + QTRY_COMPARE(proxy->focusOut, i + 1); + QTRY_VERIFY(!spinBox->hasFocus()); + QTRY_COMPARE(spinBox->focusCount, 0); + delete edit; + } +} + class EventLogger : public QWidget { public: From 5d82cbcfc30a01b489bdaa18a8ed9395b69212c7 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 27 Jan 2020 23:50:33 +0100 Subject: [PATCH 02/37] Doc: Specify install path for Vulkan examples Vulkan examples, although part of the Qt GUI documentation project, live under their own directory under /examples. Mark the correct install path for these using the \meta command. Fixes: QTBUG-81360 Change-Id: I0b98a19bf56d5b1953dbd90c0d5103be9041689a Reviewed-by: Paul Wicking --- examples/vulkan/doc/src/hellovulkancubes.qdoc | 1 + examples/vulkan/doc/src/hellovulkantexture.qdoc | 1 + examples/vulkan/doc/src/hellovulkantriangle.qdoc | 1 + examples/vulkan/doc/src/hellovulkanwidget.qdoc | 1 + examples/vulkan/doc/src/hellovulkanwindow.qdoc | 1 + 5 files changed, 5 insertions(+) diff --git a/examples/vulkan/doc/src/hellovulkancubes.qdoc b/examples/vulkan/doc/src/hellovulkancubes.qdoc index 8fa3243024d..f6160a5083a 100644 --- a/examples/vulkan/doc/src/hellovulkancubes.qdoc +++ b/examples/vulkan/doc/src/hellovulkancubes.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkancubes + \meta installpath vulkan \title Hello Vulkan Cubes Example \ingroup examples-vulkan \brief Shows the basics of using QVulkanWindow. diff --git a/examples/vulkan/doc/src/hellovulkantexture.qdoc b/examples/vulkan/doc/src/hellovulkantexture.qdoc index 4284e4a05c4..968c5602363 100644 --- a/examples/vulkan/doc/src/hellovulkantexture.qdoc +++ b/examples/vulkan/doc/src/hellovulkantexture.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkantexture + \meta installpath vulkan \ingroup examples-vulkan \title Hello Vulkan Texture Vulkan Example \brief Shows the basics of rendering with textures in a QVulkanWindow. diff --git a/examples/vulkan/doc/src/hellovulkantriangle.qdoc b/examples/vulkan/doc/src/hellovulkantriangle.qdoc index 57793cf25ad..f030d615786 100644 --- a/examples/vulkan/doc/src/hellovulkantriangle.qdoc +++ b/examples/vulkan/doc/src/hellovulkantriangle.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkantriangle + \meta installpath vulkan \ingroup examples-vulkan \title Hello Vulkan Triangle Example \brief Shows the basics of rendering with QVulkanWindow and the Vulkan API. diff --git a/examples/vulkan/doc/src/hellovulkanwidget.qdoc b/examples/vulkan/doc/src/hellovulkanwidget.qdoc index b5ad43ba2aa..b1fb52ee856 100644 --- a/examples/vulkan/doc/src/hellovulkanwidget.qdoc +++ b/examples/vulkan/doc/src/hellovulkanwidget.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkanwidget + \meta installpath vulkan \ingroup examples-vulkan \title Hello Vulkan Widget Example \brief Shows the usage of QVulkanWindow in QWidget applications. diff --git a/examples/vulkan/doc/src/hellovulkanwindow.qdoc b/examples/vulkan/doc/src/hellovulkanwindow.qdoc index a9682b7e90c..e1e95a09523 100644 --- a/examples/vulkan/doc/src/hellovulkanwindow.qdoc +++ b/examples/vulkan/doc/src/hellovulkanwindow.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkanwindow + \meta installpath vulkan \title Hello Vulkan Window Example \ingroup examples-vulkan \brief Shows the basics of using QVulkanWindow. From f24b247961e8a3d22ae385c3e29b7df2fd50b032 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Tue, 21 Jan 2020 08:08:29 +0100 Subject: [PATCH 03/37] 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(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 1908fedead6..31e1bcc0dad 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 9b03a932785..1f9f51a53ad 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 From 49b158e07de222473454e2485d981751eb5b5ccf Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 29 Jan 2020 10:57:17 +0100 Subject: [PATCH 04/37] Don't use libpng allocated buffer to store ICC profile data The data becomes invalid by the next PNG read or write. Fixes: QTBUG-81671 Change-Id: I738f5c2abbeebf2c9080d64fef7e66cc082afe89 Reviewed-by: Eirik Aavitsland --- src/gui/image/qpnghandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index fa67d38f7a0..39ca7c1672f 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -606,7 +606,7 @@ bool QPngHandlerPrivate::readPngHeader() #endif png_uint_32 profLen; png_get_iCCP(png_ptr, info_ptr, &name, &compressionType, &profileData, &profLen); - colorSpace = QColorSpace::fromIccProfile(QByteArray::fromRawData((const char *)profileData, profLen)); + colorSpace = QColorSpace::fromIccProfile(QByteArray((const char *)profileData, profLen)); if (!colorSpace.isValid()) { qWarning() << "QPngHandler: Failed to parse ICC profile"; } else { From 9b0525729b161524c3ef5b1ec63c0c9ac3efb964 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 29 Jan 2020 08:50:59 +0100 Subject: [PATCH 05/37] Add missing \since for QTextEdit::markdown The property was introduced by 23c2da3cc23a2e04a0b3b3c8ad7fa9cc6126ff23. Task-number: PYSIDE-1208 Change-Id: I2b9c5f116ffb154458de88d0efa0ac81f625121b Reviewed-by: Paul Wicking --- src/widgets/widgets/qtextedit.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index dd2ea3f18f1..ed6ffaee446 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1272,6 +1272,7 @@ QString QTextEdit::toHtml() const The default is \c MarkdownDialectGitHub. \sa plainText, html, QTextDocument::toMarkdown(), QTextDocument::setMarkdown() + \since 5.14 */ #endif From 5399f9443e30f7ca849b8096dbe9ee8c88a35c74 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 29 Jan 2020 11:06:35 +0100 Subject: [PATCH 06/37] 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(-) diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 84c75401b1a..02f49a4b1e1 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() From 1f8ced2d6df024ba007f9bb25e12bf4e23aee2db Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 28 Jan 2020 13:22:44 +0100 Subject: [PATCH 07/37] Fix line ending in custom build steps of vcxproj files We must use Windows line endings in .vcxproj files to separate command lines of custom build steps. This amends commit f65cfadd. Fixes: QTBUG-81553 Change-Id: I8d257f3846af7006df7f8d462b8f44efdce6a1fd Reviewed-by: Miguel Costa --- qmake/generators/win32/msbuild_objectmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 0515c7404f6..355260c974b 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -310,7 +310,7 @@ static QString commandLinesForOutput(QStringList commands) if (!commands.at(i).startsWith("rem", Qt::CaseInsensitive)) commands.insert(i + 1, errchk); } - return commands.join('\n'); + return commands.join("\r\n"); } static QString unquote(const QString &value) From ee41a5941b2a757598f950320003ffb4a155e39b Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Wed, 10 Jul 2019 15:05:26 +0200 Subject: [PATCH 08/37] Doc: Add see also link to QScreen::handle() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the method returns a pointer to a private type (QPA), add see also with link to QPA docs. Fixes: QTBUG-76978 Change-Id: If59670ca0a9a47b42b6441baa23525eb20f92979 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 7adf3db1b8e..ad128a88e98 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -149,6 +149,8 @@ QScreen::~QScreen() /*! Get the platform screen handle. + + \sa {Qt Platform Abstraction}{Qt Platform Abstraction (QPA)} */ QPlatformScreen *QScreen::handle() const { From 6bac3552acc5ec6e0e8594b31a04db10a21a88a4 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 13:41:44 +0100 Subject: [PATCH 09/37] Convert two QDateTime::toString() usages to QLocale::toString() Qt::LocalDate has been deprecated for ages as an alias for Qt::SystemLocaleDate, which we intend to remove at Qt 6; and all use of them can (and should) be converted to use QLocale::toString(). So do that. Task-number: QTBUG-80441 Change-Id: I0a40fa287cb347c704ec3673d17ef18381063f7f Reviewed-by: Thiago Macieira --- src/widgets/dialogs/qfilesystemmodel.cpp | 2 +- src/widgets/itemviews/qdirmodel.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 86afb277193..9b8c3036202 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -797,7 +797,7 @@ QString QFileSystemModelPrivate::time(const QModelIndex &index) const if (!index.isValid()) return QString(); #if QT_CONFIG(datestring) - return node(index)->lastModified().toString(Qt::SystemLocaleDate); + return QLocale::system().toString(node(index)->lastModified(), QLocale::ShortFormat); #else Q_UNUSED(index); return QString(); diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 13a1bbd8eb9..3dea8bd405e 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1319,7 +1319,7 @@ QString QDirModelPrivate::type(const QModelIndex &index) const QString QDirModelPrivate::time(const QModelIndex &index) const { #if QT_CONFIG(datestring) - return node(index)->info.lastModified().toString(Qt::LocalDate); + return QLocale::system().toString(node(index)->info.lastModified(), QLocale::ShortFormat); #else Q_UNUSED(index); return QString(); From 45967dfbd8192a14a324a75377d1860891845fbf Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 18:03:59 +0100 Subject: [PATCH 10/37] 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(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index a8d643d4839..cde85870944 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(); From 2130d282b1a2671049c90dd4e99e512b8009de9a Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 18:21:58 +0100 Subject: [PATCH 11/37] 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 --- examples/embedded/flightinfo/flightinfo.cpp | 4 ++-- examples/sql/books/initdb.h | 4 ++-- .../customsortfiltermodel/mysortfilterproxymodel.cpp | 8 ++++---- .../customsortfiltermodel/mysortfilterproxymodel.h | 8 ++++---- examples/widgets/widgets/calendarwidget/window.cpp | 6 +++--- examples/widgets/widgets/calendarwidget/window.h | 7 ++++--- src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp | 4 ++-- src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp | 2 +- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/examples/embedded/flightinfo/flightinfo.cpp b/examples/embedded/flightinfo/flightinfo.cpp index f46fc9693fa..f7df368dd77 100644 --- a/examples/embedded/flightinfo/flightinfo.cpp +++ b/examples/embedded/flightinfo/flightinfo.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 demonstration applications of the Qt Toolkit. @@ -198,7 +198,7 @@ private slots: public slots: - void request(const QString &flightCode, const QDate &date) { + void request(const QString &flightCode, QDate date) { setWindowTitle("Loading..."); diff --git a/examples/sql/books/initdb.h b/examples/sql/books/initdb.h index 773e3fb74cb..e1f690a234d 100644 --- a/examples/sql/books/initdb.h +++ b/examples/sql/books/initdb.h @@ -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 demonstration applications of the Qt Toolkit. @@ -71,7 +71,7 @@ QVariant addGenre(QSqlQuery &q, const QString &name) return q.lastInsertId(); } -QVariant addAuthor(QSqlQuery &q, const QString &name, const QDate &birthdate) +QVariant addAuthor(QSqlQuery &q, const QString &name, QDate birthdate) { q.addBindValue(name); q.addBindValue(birthdate); diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp index 4753d04d9b4..430a086fd64 100644 --- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp +++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.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 examples of the Qt Toolkit. @@ -60,7 +60,7 @@ MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent) //! [0] //! [1] -void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date) +void MySortFilterProxyModel::setFilterMinimumDate(QDate date) { minDate = date; invalidateFilter(); @@ -68,7 +68,7 @@ void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date) //! [1] //! [2] -void MySortFilterProxyModel::setFilterMaximumDate(const QDate &date) +void MySortFilterProxyModel::setFilterMaximumDate(QDate date) { maxDate = date; invalidateFilter(); @@ -122,7 +122,7 @@ bool MySortFilterProxyModel::lessThan(const QModelIndex &left, //! [5] //! [6] //! [7] -bool MySortFilterProxyModel::dateInRange(const QDate &date) const +bool MySortFilterProxyModel::dateInRange(QDate date) const { return (!minDate.isValid() || date > minDate) && (!maxDate.isValid() || date < maxDate); diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h index e2aff3c829f..5fdabbd5df4 100644 --- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h +++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h @@ -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 examples of the Qt Toolkit. @@ -63,17 +63,17 @@ public: MySortFilterProxyModel(QObject *parent = 0); QDate filterMinimumDate() const { return minDate; } - void setFilterMinimumDate(const QDate &date); + void setFilterMinimumDate(QDate date); QDate filterMaximumDate() const { return maxDate; } - void setFilterMaximumDate(const QDate &date); + void setFilterMaximumDate(QDate date); protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; private: - bool dateInRange(const QDate &date) const; + bool dateInRange(QDate date) const; QDate minDate; QDate maxDate; diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp index b8a3d03552f..ae10223dd42 100644 --- a/examples/widgets/widgets/calendarwidget/window.cpp +++ b/examples/widgets/widgets/calendarwidget/window.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 examples of the Qt Toolkit. @@ -126,7 +126,7 @@ void Window::selectedDateChanged() //! [2] //! [3] -void Window::minimumDateChanged(const QDate &date) +void Window::minimumDateChanged(QDate date) { calendar->setMinimumDate(date); maximumDateEdit->setDate(calendar->maximumDate()); @@ -134,7 +134,7 @@ void Window::minimumDateChanged(const QDate &date) //! [3] //! [4] -void Window::maximumDateChanged(const QDate &date) +void Window::maximumDateChanged(QDate date) { calendar->setMaximumDate(date); minimumDateEdit->setDate(calendar->minimumDate()); diff --git a/examples/widgets/widgets/calendarwidget/window.h b/examples/widgets/widgets/calendarwidget/window.h index 83ea494fc2e..1b673b8ce0a 100644 --- a/examples/widgets/widgets/calendarwidget/window.h +++ b/examples/widgets/widgets/calendarwidget/window.h @@ -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 examples of the Qt Toolkit. @@ -52,6 +52,7 @@ #define WINDOW_H #include +#include QT_BEGIN_NAMESPACE class QCalendarWidget; @@ -79,8 +80,8 @@ private slots: void horizontalHeaderChanged(int index); void verticalHeaderChanged(int index); void selectedDateChanged(); - void minimumDateChanged(const QDate &date); - void maximumDateChanged(const QDate &date); + void minimumDateChanged(QDate date); + void maximumDateChanged(QDate date); void weekdayFormatChanged(); void weekendFormatChanged(); void reformatHeaders(); 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 9813cc98d59..e070ada0697 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 506022f082f..145cd10d846 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: From d7a5d6a98d237f48edd71458cf6fb24d5c9f01e1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Jan 2020 10:32:18 +0100 Subject: [PATCH 12/37] Windows style: Fix wrong color of non-editable combo box MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QPalette::Button instead of Base as does QFusionStyle so that style sheets specifying colors for the non-editable case work correctly. Fixes: QTBUG-81573 Change-Id: I84cecb38a48a1450c82498558aa350f3e60a5df6 Reviewed-by: André de la Rocha Reviewed-by: Oliver Wolff --- src/widgets/styles/qwindowsstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 8496a2c2236..4f8cc56e059 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -2119,7 +2119,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp #if QT_CONFIG(combobox) case CC_ComboBox: if (const QStyleOptionComboBox *cmb = qstyleoption_cast(opt)) { - QBrush editBrush = cmb->palette.brush(QPalette::Base); + QBrush editBrush = cmb->palette.brush(QPalette::Button); if ((cmb->subControls & SC_ComboBoxFrame)) { if (cmb->frame) { QPalette shadePal = opt->palette; From 17affdfbcbb1774dd71782d63889689909fb4bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 21 Jan 2020 15:14:14 +0100 Subject: [PATCH 13/37] Blacklist failing tests on macOS 10.14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These tests fail locally, and have been reported to fail on the CI system. Change-Id: Ia76bb15c288af4171ebe47b3c30f3651a63df3f2 Task-number: QTBUG-75786 Reviewed-by: Tor Arne Vestbø --- tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST | 1 + tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST index e760042def7..31dbb38a5dd 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST @@ -1,3 +1,4 @@ # QTBUG-74760 [sorting] opensuse-42.3 +osx diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST index 9b76ea02ff1..f59544f3366 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST @@ -16,3 +16,5 @@ opensuse-42.3 [itemsInRect_cosmeticAdjust] # QTBUG-66815 ubuntu-16.04 +[fitInView] +osx From 128db60f4cb35950d3293309ed7ed6229c40c1e7 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 30 Jan 2020 15:37:03 +0200 Subject: [PATCH 14/37] Doc: Update out dated QImage::constScanLine documentation Change-Id: I0c09a9a6168422c7e41ded289a3e5ba39b84b0ee Reviewed-by: Eirik Aavitsland --- src/gui/image/qimage.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d8ed0829af3..01abad96a01 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1621,7 +1621,9 @@ const uchar *QImage::scanLine(int i) const Returns a pointer to the pixel data at the scanline with index \a i. The first scanline is at index 0. - The scanline data is aligned on a 32-bit boundary. + The scanline data is as minimum 32-bit aligned. For 64-bit formats + it follows the native alignment of 64-bit integers (64-bit for most + platforms, but notably 32-bit on i386). Note that QImage uses \l{Implicit Data Sharing} {implicit data sharing}, but this function does \e not perform a deep copy of the From caef33ae2df64eb397eadfc4ce4735545ff93ea5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 30 Jan 2020 15:23:58 +0100 Subject: [PATCH 15/37] Fix NEON support on Android armeabi-v7a Task-number: QTBUG-81461 Change-Id: Ic3e8367aee990291fc676204b9299530953fc87a Reviewed-by: BogDan Vatra --- src/gui/image/image.pri | 2 +- src/gui/painting/painting.pri | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 1f42f28d1e5..01e48c17ddd 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -97,7 +97,7 @@ qtConfig(png) { MIPS_DSPR2_ASM += image/qimage_mips_dspr2_asm.S } else { # see https://developer.android.com/ndk/guides/abis - arm64-v8a { + arm64-v8a | armeabi-v7a { SOURCES += image/qimage_neon.cpp } x86 | x86_64 { diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index fcf6488eddf..c68e8d6e9a5 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -166,7 +166,7 @@ gcc:equals(QT_GCC_MAJOR_VERSION, 5) { DEFINES += QT_COMPILER_SUPPORTS_SSE4_1 QT_COMPILER_SUPPORTS_SSE4_2 SOURCES += painting/qdrawhelper_sse4.cpp painting/qimagescale_sse4.cpp } - arm64-v8a { + arm64-v8a | armeabi-v7a { SOURCES += painting/qdrawhelper_neon.cpp painting/qimagescale_neon.cpp HEADERS += painting/qdrawhelper_neon_p.h } From 495db2cd2bb9130864f2dd1291788288765dfe7a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 30 Jan 2020 13:59:27 +0100 Subject: [PATCH 16/37] Add function for initializing plugin resources for static builds Also move the setting of default RCC_DIR into qtFlattenResources as we need a valid RCC_DIR there. Fixes: QTBUG-81699 Fixes: QTBUG-81713 Change-Id: I7558d99f3aca75d2e9cad0ec89fbb0aa0758dcc7 Reviewed-by: Simon Hausmann --- mkspecs/features/resources.prf | 35 +----------------- mkspecs/features/resources_functions.prf | 45 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index 6d9f27b86b3..151051163df 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -1,6 +1,5 @@ qtPrepareTool(QMAKE_RCC, rcc, _DEP) -isEmpty(RCC_DIR):RCC_DIR = . isEmpty(QMAKE_MOD_RCC):QMAKE_MOD_RCC = qrc !contains(QMAKE_RESOURCE_FLAGS, -root):!isEmpty(QMAKE_RESOURCE_ROOT):QMAKE_RESOURCE_FLAGS += -root $$QMAKE_RESOURCE_ROOT @@ -8,39 +7,7 @@ isEmpty(QMAKE_MOD_RCC):QMAKE_MOD_RCC = qrc load(resources_functions) qtFlattenResources() - -!isEmpty(RESOURCES):contains(TEMPLATE, .*lib):plugin:static { - pluginBaseName = $$basename(TARGET) - pluginName = $$lower($$replace(pluginBaseName, [-], _)) - resource_init_function = $${pluginName}_plugin_resource_init - DEFINES += "QT_PLUGIN_RESOURCE_INIT_FUNCTION=$$resource_init_function" - RESOURCE_INIT_CPP = $$OUT_PWD/$${pluginName}_plugin_resources.cpp - - GENERATED_SOURCES += $$RESOURCE_INIT_CPP - QMAKE_DISTCLEAN += $$RESOURCE_INIT_CPP - - isEmpty(BUILDS)|build_pass { - RESOURCE_INIT_CONT = \ - "// This file is autogenerated by qmake. It contains a function that" \ - "// references all resources the plugin includes and the function is" \ - "// referenced by Qt_(MOC_)EXPORT_PLUGIN to ensure the inclusion in" \ - "// the statically linked plugin." \ - "$${LITERAL_HASH}include " \ - "void $${resource_init_function}() " \ - "{" \ - - for (resource, RESOURCES) { - resource_name = $$replace($$list($$basename(resource)),\.qrc$, ) - resource_name = $$replace(resource_name, [^a-zA-Z0-9_], _) - RESOURCE_INIT_CONT += " Q_INIT_RESOURCE($$resource_name);" - } - - RESOURCE_INIT_CONT += \ - "}" - - write_file($$RESOURCE_INIT_CPP, RESOURCE_INIT_CONT)|error() - } -} +qtEnsurePluginResourcesCpp() rcc.input = RESOURCES rcc.name = RCC ${QMAKE_FILE_IN} diff --git a/mkspecs/features/resources_functions.prf b/mkspecs/features/resources_functions.prf index b7a15fd1d95..f0ca2ed793e 100644 --- a/mkspecs/features/resources_functions.prf +++ b/mkspecs/features/resources_functions.prf @@ -9,6 +9,7 @@ defineReplace(xml_escape) { } defineTest(qtFlattenResources) { + isEmpty(RCC_DIR):RCC_DIR = . immediate = qmake_immediate$$QMAKE_RESOURCES_IMMEDIATE_NR defined(QMAKE_RESOURCES_IMMEDIATE_NR, var): \ QMAKE_RESOURCES_IMMEDIATE_NR = $$num_add($$QMAKE_RESOURCES_IMMEDIATE_NR, 1) @@ -72,9 +73,53 @@ defineTest(qtFlattenResources) { RESOURCES -= $$resource RESOURCES += $$resource_file } + export(RCC_DIR) export(QMAKE_RESOURCES_IMMEDIATE_NR) export(RESOURCES) export(OTHER_FILES) export($${immediate}.files) return(true) } + +defineTest(qtEnsurePluginResourcesCpp) { + contains(DEFINES, QT_PLUGIN_RESOURCE_INIT_FUNCTION=.*): \ + return(true) + + !isEmpty(RESOURCES):contains(TEMPLATE, .*lib):plugin:static { + pluginBaseName = $$basename(TARGET) + pluginName = $$lower($$replace(pluginBaseName, [-], _)) + resource_init_function = $${pluginName}_plugin_resource_init + DEFINES += "QT_PLUGIN_RESOURCE_INIT_FUNCTION=$$resource_init_function" + RESOURCE_INIT_CPP = $$OUT_PWD/$${pluginName}_plugin_resources.cpp + + GENERATED_SOURCES += $$RESOURCE_INIT_CPP + QMAKE_DISTCLEAN += $$RESOURCE_INIT_CPP + + isEmpty(BUILDS)|build_pass { + RESOURCE_INIT_CONT = \ + "// This file is autogenerated by qmake. It contains a function that" \ + "// references all resources the plugin includes and the function is" \ + "// referenced by Qt_(MOC_)EXPORT_PLUGIN to ensure the inclusion in" \ + "// the statically linked plugin." \ + "$${LITERAL_HASH}include " \ + "void $${resource_init_function}() " \ + "{" \ + + for (resource, RESOURCES) { + resource_name = $$replace($$list($$basename(resource)),\.qrc$, ) + resource_name = $$replace(resource_name, [^a-zA-Z0-9_], _) + RESOURCE_INIT_CONT += " Q_INIT_RESOURCE($$resource_name);" + } + + RESOURCE_INIT_CONT += \ + "}" + + write_file($$RESOURCE_INIT_CPP, RESOURCE_INIT_CONT)|error() + } + + export(DEFINES) + export(GENERATED_SOURCES) + export(QMAKE_DISTCLEAN) + } + return(true) +} From 3041393d2e6dc094652334fcb4bc35597632d228 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 24 Jan 2020 15:48:41 +0100 Subject: [PATCH 17/37] 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(-) diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index 4b4152c519c..d7319c15325 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(); From 9ede07613dc5b7759f398d5a8839b2ffdb4675a2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Jan 2020 16:59:59 -0800 Subject: [PATCH 18/37] 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(-) diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index b2bf77c0da8..ce2b7e8faa8 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 From c7f59cad196dae2ee83e2073e546428695f0e1f0 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 29 Jan 2020 19:58:01 +0100 Subject: [PATCH 19/37] Examples: fix compile without printsupport Checking for QT_CONFIG(printdialog) is not enough when printsupport is completely disabled since then the macro will throw an error. Therefore add an additional check 'defined(QT_PRINTSUPPORT_LIB)' before using the QT_CONFIG macro. Fixes: QTBUG-81626 Change-Id: Ie9898f057cdd6bf9daf4ba9135987cb6e901e7bf Reviewed-by: Friedemann Kleint --- examples/widgets/dialogs/licensewizard/licensewizard.cpp | 2 +- examples/widgets/graphicsview/chip/view.cpp | 2 +- examples/widgets/itemviews/pixelator/mainwindow.cpp | 2 +- examples/widgets/mainwindows/dockwidgets/mainwindow.cpp | 2 +- examples/widgets/richtext/orderform/mainwindow.cpp | 2 +- examples/widgets/richtext/textedit/textedit.cpp | 2 +- examples/widgets/touch/fingerpaint/scribblearea.cpp | 2 +- examples/widgets/tutorials/notepad/notepad.cpp | 4 ++-- examples/widgets/widgets/imageviewer/imageviewer.cpp | 2 +- examples/widgets/widgets/scribble/scribblearea.cpp | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/widgets/dialogs/licensewizard/licensewizard.cpp b/examples/widgets/dialogs/licensewizard/licensewizard.cpp index c082afa8768..2eaadd1cba4 100644 --- a/examples/widgets/dialogs/licensewizard/licensewizard.cpp +++ b/examples/widgets/dialogs/licensewizard/licensewizard.cpp @@ -369,7 +369,7 @@ void ConclusionPage::setVisible(bool visible) void ConclusionPage::printButtonClicked() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer; QPrintDialog dialog(&printer, this); if (dialog.exec()) diff --git a/examples/widgets/graphicsview/chip/view.cpp b/examples/widgets/graphicsview/chip/view.cpp index 21998dc2dfd..d6fec778c20 100644 --- a/examples/widgets/graphicsview/chip/view.cpp +++ b/examples/widgets/graphicsview/chip/view.cpp @@ -264,7 +264,7 @@ void View::toggleAntialiasing() void View::print() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer; QPrintDialog dialog(&printer, this); if (dialog.exec() == QDialog::Accepted) { diff --git a/examples/widgets/itemviews/pixelator/mainwindow.cpp b/examples/widgets/itemviews/pixelator/mainwindow.cpp index f6b67e4dba8..abd4a8b1ab3 100644 --- a/examples/widgets/itemviews/pixelator/mainwindow.cpp +++ b/examples/widgets/itemviews/pixelator/mainwindow.cpp @@ -167,7 +167,7 @@ void MainWindow::openImage(const QString &fileName) void MainWindow::printImage() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex()) > 90000) { QMessageBox::StandardButton answer; answer = QMessageBox::question(this, tr("Large Image Size"), diff --git a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp b/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp index a62765cdabc..dba4a081df9 100644 --- a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp +++ b/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp @@ -128,7 +128,7 @@ void MainWindow::newLetter() //! [3] void MainWindow::print() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QTextDocument *document = textEdit->document(); QPrinter printer; diff --git a/examples/widgets/richtext/orderform/mainwindow.cpp b/examples/widgets/richtext/orderform/mainwindow.cpp index 0b6a2cac6c9..ee6758c9cb8 100644 --- a/examples/widgets/richtext/orderform/mainwindow.cpp +++ b/examples/widgets/richtext/orderform/mainwindow.cpp @@ -248,7 +248,7 @@ void MainWindow::openDialog() //! [17] void MainWindow::printFile() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QTextEdit *editor = static_cast(letters->currentWidget()); //! [18] QPrinter printer; diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index 85fb83ab893..f99fa306dfe 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -545,7 +545,7 @@ bool TextEdit::fileSaveAs() void TextEdit::filePrint() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer(QPrinter::HighResolution); QPrintDialog *dlg = new QPrintDialog(&printer, this); if (textEdit->textCursor().hasSelection()) diff --git a/examples/widgets/touch/fingerpaint/scribblearea.cpp b/examples/widgets/touch/fingerpaint/scribblearea.cpp index 0b0c4476d91..e490495cd93 100644 --- a/examples/widgets/touch/fingerpaint/scribblearea.cpp +++ b/examples/widgets/touch/fingerpaint/scribblearea.cpp @@ -170,7 +170,7 @@ void ScribbleArea::resizeImage(QImage *image, const QSize &newSize) //! [21] void ScribbleArea::print() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer(QPrinter::HighResolution); QPrintDialog printDialog(&printer, this); diff --git a/examples/widgets/tutorials/notepad/notepad.cpp b/examples/widgets/tutorials/notepad/notepad.cpp index 2ccd6501a13..5fd0d69cea4 100644 --- a/examples/widgets/tutorials/notepad/notepad.cpp +++ b/examples/widgets/tutorials/notepad/notepad.cpp @@ -92,7 +92,7 @@ Notepad::Notepad(QWidget *parent) : connect(ui->actionAbout, &QAction::triggered, this, &Notepad::about); // Disable menu actions for unavailable features -#if !QT_CONFIG(printer) +#if !defined(QT_PRINTSUPPORT_LIB) || !QT_CONFIG(printer) ui->actionPrint->setEnabled(false); #endif @@ -171,7 +171,7 @@ void Notepad::saveAs() void Notepad::print() { -#if QT_CONFIG(printer) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) QPrinter printDev; #if QT_CONFIG(printdialog) QPrintDialog dialog(&printDev, this); diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp index 83cf8bb7bca..70a4cda9844 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp @@ -201,7 +201,7 @@ void ImageViewer::print() //! [5] //! [6] { Q_ASSERT(imageLabel->pixmap()); -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) //! [6] //! [7] QPrintDialog dialog(&printer, this); //! [7] //! [8] diff --git a/examples/widgets/widgets/scribble/scribblearea.cpp b/examples/widgets/widgets/scribble/scribblearea.cpp index 75371b523fe..d3937f90d8a 100644 --- a/examples/widgets/widgets/scribble/scribblearea.cpp +++ b/examples/widgets/widgets/scribble/scribblearea.cpp @@ -210,7 +210,7 @@ void ScribbleArea::resizeImage(QImage *image, const QSize &newSize) //! [21] void ScribbleArea::print() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer(QPrinter::HighResolution); QPrintDialog printDialog(&printer, this); From b4db334c03395f7f8f210984d6f30d85cc6e5da9 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 29 Jan 2020 20:06:45 +0100 Subject: [PATCH 20/37] Doc/Printsupport: misc fixes - use new signal/slot syntax - fix includes - adjust style Change-Id: Icdc9b33e72e24c39cc6e96b4f2cafa78e179efbf Reviewed-by: Paul Wicking --- .../doc/snippets/printing-qprinter/errors.cpp | 6 ++++- .../doc/snippets/printing-qprinter/object.cpp | 7 +++++- .../doc/snippets/widgetprinting.cpp | 22 ++++++++++--------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/printsupport/doc/snippets/printing-qprinter/errors.cpp b/src/printsupport/doc/snippets/printing-qprinter/errors.cpp index 40acf9293c7..c07bb8b76d0 100644 --- a/src/printsupport/doc/snippets/printing-qprinter/errors.cpp +++ b/src/printsupport/doc/snippets/printing-qprinter/errors.cpp @@ -48,7 +48,11 @@ ** ****************************************************************************/ -#include +#include +#include +#if QT_CONFIG(printdialog) +#include +#endif int main(int argc, char **argv) { diff --git a/src/printsupport/doc/snippets/printing-qprinter/object.cpp b/src/printsupport/doc/snippets/printing-qprinter/object.cpp index c4987af4a69..6e246ff6154 100644 --- a/src/printsupport/doc/snippets/printing-qprinter/object.cpp +++ b/src/printsupport/doc/snippets/printing-qprinter/object.cpp @@ -48,9 +48,14 @@ ** ****************************************************************************/ -#include #include "object.h" +#include +#include +#if QT_CONFIG(printdialog) +#include +#endif + Object::Object(QObject *parent) : QObject(parent) { diff --git a/src/printsupport/doc/snippets/widgetprinting.cpp b/src/printsupport/doc/snippets/widgetprinting.cpp index 6e0256cb922..d64a1536fb0 100644 --- a/src/printsupport/doc/snippets/widgetprinting.cpp +++ b/src/printsupport/doc/snippets/widgetprinting.cpp @@ -48,7 +48,6 @@ ** ****************************************************************************/ -#include #include #include #if QT_CONFIG(printdialog) @@ -61,11 +60,12 @@ class Window : public QWidget Q_OBJECT public: - Window() { + Window() + { myWidget = new QPushButton("Print Me"); - connect(myWidget, SIGNAL(clicked()), this, SLOT(print())); + connect(myWidget, &QPushButton::clicked, this, &Window::print); myWidget2 = new QPushButton("Print Document"); - connect(myWidget2, SIGNAL(clicked()), this, SLOT(printFile())); + connect(myWidget2, &QPushButton::clicked, this, &Window::printFile); editor = new QTextEdit(this); QVBoxLayout *layout = new QVBoxLayout; @@ -76,8 +76,9 @@ public: } private slots: - void print() { - #if !defined(QT_NO_PRINTER) + void print() + { + #if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) QPrinter printer(QPrinter::HighResolution); printer.setOutputFileName("test.pdf"); @@ -85,8 +86,8 @@ private slots: //! [0] QPainter painter; painter.begin(&printer); - double xscale = printer.pageRect().width()/double(myWidget->width()); - double yscale = printer.pageRect().height()/double(myWidget->height()); + double xscale = printer.pageRect().width() / double(myWidget->width()); + double yscale = printer.pageRect().height() / double(myWidget->height()); double scale = qMin(xscale, yscale); painter.translate(printer.paperRect().x() + printer.pageRect().width()/2, printer.paperRect().y() + printer.pageRect().height()/2); @@ -98,8 +99,9 @@ private slots: #endif } - void printFile() { - #if QT_CONFIG(printdialog) + void printFile() + { + #if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) //! [1] QPrinter printer; From 287b570ad5c00eb491f86eab0c4b8d3f6d96f666 Mon Sep 17 00:00:00 2001 From: Mike Achtelik Date: Wed, 22 Jan 2020 13:17:20 +0100 Subject: [PATCH 21/37] Handle exceptions when accessing android clipboard In some circumstances android throws an exception or returns null, when trying to access the clipboard. Fixes: QTBUG-80689 Change-Id: I92c134e2a002fc648ff966e15a19eb3307c428a1 Reviewed-by: BogDan Vatra --- .../org/qtproject/qt5/android/QtNative.java | 130 +++++++++++------- 1 file changed, 79 insertions(+), 51 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 7db16002ff9..c1c4d5559db 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -740,54 +740,66 @@ public class QtNative public static boolean hasClipboardText() { - if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { - ClipData primaryClip = m_clipboardManager.getPrimaryClip(); - for (int i = 0; i < primaryClip.getItemCount(); ++i) - if (primaryClip.getItemAt(i).getText() != null) - return true; + try { + if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { + ClipData primaryClip = m_clipboardManager.getPrimaryClip(); + for (int i = 0; i < primaryClip.getItemCount(); ++i) + if (primaryClip.getItemAt(i).getText() != null) + return true; + } + } catch (Exception e) { + Log.e(QtTAG, "Failed to get clipboard data", e); } return false; } private static String getClipboardText() { - if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { - ClipData primaryClip = m_clipboardManager.getPrimaryClip(); - for (int i = 0; i < primaryClip.getItemCount(); ++i) - if (primaryClip.getItemAt(i).getText() != null) - return primaryClip.getItemAt(i).getText().toString(); + try { + if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { + ClipData primaryClip = m_clipboardManager.getPrimaryClip(); + for (int i = 0; i < primaryClip.getItemCount(); ++i) + if (primaryClip.getItemAt(i).getText() != null) + return primaryClip.getItemAt(i).getText().toString(); + } + } catch (Exception e) { + Log.e(QtTAG, "Failed to get clipboard data", e); } return ""; } private static void updatePrimaryClip(ClipData clipData) { - if (m_usePrimaryClip) { - ClipData clip = m_clipboardManager.getPrimaryClip(); - if (Build.VERSION.SDK_INT >= 26) { - if (m_addItemMethod == null) { - Class[] cArg = new Class[2]; - cArg[0] = ContentResolver.class; - cArg[1] = ClipData.Item.class; - try { - m_addItemMethod = m_clipboardManager.getClass().getMethod("addItem", cArg); - } catch (Exception e) { + try { + if (m_usePrimaryClip) { + ClipData clip = m_clipboardManager.getPrimaryClip(); + if (Build.VERSION.SDK_INT >= 26) { + if (m_addItemMethod == null) { + Class[] cArg = new Class[2]; + cArg[0] = ContentResolver.class; + cArg[1] = ClipData.Item.class; + try { + m_addItemMethod = m_clipboardManager.getClass().getMethod("addItem", cArg); + } catch (Exception e) { + } } } - } - if (m_addItemMethod != null) { - try { - m_addItemMethod.invoke(m_activity.getContentResolver(), clipData.getItemAt(0)); - } catch (Exception e) { - e.printStackTrace(); + if (m_addItemMethod != null) { + try { + m_addItemMethod.invoke(m_activity.getContentResolver(), clipData.getItemAt(0)); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + clip.addItem(clipData.getItemAt(0)); } + m_clipboardManager.setPrimaryClip(clip); } else { - clip.addItem(clipData.getItemAt(0)); + m_clipboardManager.setPrimaryClip(clipData); + m_usePrimaryClip = true; } - m_clipboardManager.setPrimaryClip(clip); - } else { - m_clipboardManager.setPrimaryClip(clipData); - m_usePrimaryClip = true; + } catch (Exception e) { + Log.e(QtTAG, "Failed to set clipboard data", e); } } @@ -801,22 +813,30 @@ public class QtNative public static boolean hasClipboardHtml() { - if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { - ClipData primaryClip = m_clipboardManager.getPrimaryClip(); - for (int i = 0; i < primaryClip.getItemCount(); ++i) - if (primaryClip.getItemAt(i).getHtmlText() != null) - return true; + try { + if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { + ClipData primaryClip = m_clipboardManager.getPrimaryClip(); + for (int i = 0; i < primaryClip.getItemCount(); ++i) + if (primaryClip.getItemAt(i).getHtmlText() != null) + return true; + } + } catch (Exception e) { + Log.e(QtTAG, "Failed to get clipboard data", e); } return false; } private static String getClipboardHtml() { - if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { - ClipData primaryClip = m_clipboardManager.getPrimaryClip(); - for (int i = 0; i < primaryClip.getItemCount(); ++i) - if (primaryClip.getItemAt(i).getHtmlText() != null) - return primaryClip.getItemAt(i).getHtmlText().toString(); + try { + if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { + ClipData primaryClip = m_clipboardManager.getPrimaryClip(); + for (int i = 0; i < primaryClip.getItemCount(); ++i) + if (primaryClip.getItemAt(i).getHtmlText() != null) + return primaryClip.getItemAt(i).getHtmlText().toString(); + } + } catch (Exception e) { + Log.e(QtTAG, "Failed to get clipboard data", e); } return ""; } @@ -832,11 +852,15 @@ public class QtNative public static boolean hasClipboardUri() { - if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { - ClipData primaryClip = m_clipboardManager.getPrimaryClip(); - for (int i = 0; i < primaryClip.getItemCount(); ++i) - if (primaryClip.getItemAt(i).getUri() != null) - return true; + try { + if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { + ClipData primaryClip = m_clipboardManager.getPrimaryClip(); + for (int i = 0; i < primaryClip.getItemCount(); ++i) + if (primaryClip.getItemAt(i).getUri() != null) + return true; + } + } catch (Exception e) { + Log.e(QtTAG, "Failed to get clipboard data", e); } return false; } @@ -844,11 +868,15 @@ public class QtNative private static String[] getClipboardUris() { ArrayList uris = new ArrayList(); - if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { - ClipData primaryClip = m_clipboardManager.getPrimaryClip(); - for (int i = 0; i < primaryClip.getItemCount(); ++i) - if (primaryClip.getItemAt(i).getUri() != null) - uris.add(primaryClip.getItemAt(i).getUri().toString()); + try { + if (m_clipboardManager != null && m_clipboardManager.hasPrimaryClip()) { + ClipData primaryClip = m_clipboardManager.getPrimaryClip(); + for (int i = 0; i < primaryClip.getItemCount(); ++i) + if (primaryClip.getItemAt(i).getUri() != null) + uris.add(primaryClip.getItemAt(i).getUri().toString()); + } + } catch (Exception e) { + Log.e(QtTAG, "Failed to get clipboard data", e); } String[] strings = new String[uris.size()]; strings = uris.toArray(strings); From f998e630e74a8921e2e48e84fc0153ff81850def Mon Sep 17 00:00:00 2001 From: Alexandra Cherdantseva Date: Wed, 29 Jan 2020 17:38:41 +0300 Subject: [PATCH 22/37] wasm: fix QWasmString::toQString assertion for emscripten 1.39.4 In emscripten 1.39.4 `maxBytesToWrite` argument is required for function `stringToUTF16(str, outPtr, maxBytesToWrite)` Fixes: QTBUG-81728 Change-Id: I634134a30454ae09a9a05593428397b40464b31f Reviewed-by: jian liang Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmstring.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmstring.cpp b/src/plugins/platforms/wasm/qwasmstring.cpp index 05b571c4594..b1be405eeb2 100644 --- a/src/plugins/platforms/wasm/qwasmstring.cpp +++ b/src/plugins/platforms/wasm/qwasmstring.cpp @@ -52,9 +52,10 @@ QString QWasmString::toQString(const val &v) val::global("Module")["stringToUTF16"]); static const val length("length"); - result.resize(v[length].as()); + int len = v[length].as(); + result.resize(len); auto ptr = quintptr(result.utf16()); - stringToUTF16(v, val(ptr)); + stringToUTF16(v, val(ptr), val((len + 1) * 2)); return result; } From d8df846631a54c624ccd6fd5a533c8ddc8f2ab35 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 28 Jan 2020 15:47:48 +0100 Subject: [PATCH 23/37] glgen: Fix compile error Fixes compile error introduced in ff2b2032a08. Change-Id: Iee1016f7cf05638db575475c5c0d632f8edb3a8c Reviewed-by: Sona Kurazyan --- util/glgen/codegenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/glgen/codegenerator.cpp b/util/glgen/codegenerator.cpp index 08327a62f56..79e889a13e9 100644 --- a/util/glgen/codegenerator.cpp +++ b/util/glgen/codegenerator.cpp @@ -184,7 +184,7 @@ void CodeGenerator::writeCoreFactoryImplementation(const QString &fileName) cons // Get the set of version functions classes we need to create QList versions = m_parser->versions(); - std::sort(m_versions.begin(), m_versions.end(), std::greater()); + std::sort(versions.begin(), versions.end(), std::greater()); // Outout the #include statements stream << QStringLiteral("#if !defined(QT_OPENGL_ES_2)") << endl; From 90fbd086c6d164136ff4b3a26577bf40cb951754 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 18:33:23 +0100 Subject: [PATCH 24/37] Pass QDate and QTime by value in manual calendar test code They're value types, pass them as such. Change-Id: I78e93165d431ac4eff145f47a9385d6bf5cd0c15 Reviewed-by: Friedemann Kleint --- tests/manual/qlocale/calendar.cpp | 4 ++-- tests/manual/qlocale/calendar.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/manual/qlocale/calendar.cpp b/tests/manual/qlocale/calendar.cpp index 4295e13342f..f127c81656b 100644 --- a/tests/manual/qlocale/calendar.cpp +++ b/tests/manual/qlocale/calendar.cpp @@ -94,13 +94,13 @@ void CalendarWidget::selectedDateChanged() currentDateEdit->setDate(calendar->selectedDate()); } -void CalendarWidget::minimumDateChanged(const QDate &date) +void CalendarWidget::minimumDateChanged(QDate date) { calendar->setMinimumDate(date); maximumDateEdit->setDate(calendar->maximumDate()); } -void CalendarWidget::maximumDateChanged(const QDate &date) +void CalendarWidget::maximumDateChanged(QDate date) { calendar->setMaximumDate(date); minimumDateEdit->setDate(calendar->minimumDate()); diff --git a/tests/manual/qlocale/calendar.h b/tests/manual/qlocale/calendar.h index aee73ef82ab..6a72a4e2d2a 100644 --- a/tests/manual/qlocale/calendar.h +++ b/tests/manual/qlocale/calendar.h @@ -55,8 +55,8 @@ private slots: void horizontalHeaderChanged(int index); void verticalHeaderChanged(int index); void selectedDateChanged(); - void minimumDateChanged(const QDate &date); - void maximumDateChanged(const QDate &date); + void minimumDateChanged(QDate date); + void maximumDateChanged(QDate date); void updateWeekendDays(); void weekdayFormatChanged(); void weekendFormatChanged(); From 2b1068af97f1483b7bdb3d7a9257ab59fc4b2b59 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 18:28:07 +0100 Subject: [PATCH 25/37] 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 +- src/plugins/sqldrivers/ibase/qsql_ibase.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm index 31ede1352bf..7bdae662c78 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 cde85870944..a5761055ed5 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 2636928e699..2f7cbb4017b 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 0fec5355b2c..0aaf469ed97 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(); diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp index 0f39f6aa0d3..3368c74373a 100644 --- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp +++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp @@ -250,7 +250,7 @@ static QDateTime fromTimeStamp(char *buffer) return QDateTime(d, t); } -static ISC_TIME toTime(const QTime &t) +static ISC_TIME toTime(QTime t) { static const QTime midnight(0, 0, 0, 0); return (ISC_TIME)midnight.msecsTo(t) * 10; @@ -266,7 +266,7 @@ static QTime fromTime(char *buffer) return t; } -static ISC_DATE toDate(const QDate &t) +static ISC_DATE toDate(QDate t) { static const QDate basedate(1858, 11, 17); ISC_DATE date; From 5ac1516edd17eb4ddd94fe43a04fa4d736c50041 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 30 Jan 2020 15:16:18 +0100 Subject: [PATCH 26/37] 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(-) diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index c868e879b7e..0c9bb80cb2e 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; From d52ed0a8ead988d859cc85b944e0226325f87722 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 31 Jan 2020 21:19:48 +0100 Subject: [PATCH 27/37] Sql driver doc: fix typo Fix a small typo in the link to vcredist.exe Change-Id: I8b2724bd01889ac439bcd1a762a7c74df9882492 Reviewed-by: Sze Howe Koh Reviewed-by: Paul Wicking --- src/sql/doc/src/sql-driver.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index 3a0fcfa1e73..f6fc90a7e92 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -194,8 +194,8 @@ When you distribute your application, remember to include libmysql.dll in your installation package. It must be placed in the same folder as the application executable. \e libmysql.dll additionally needs the - MSVC runtime libraries which can be installed with vcredist.exe - (\l {https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads}{vcredist.exe} + MSVC runtime libraries which can be installed with + \l {https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads}{vcredist.exe} \target QOCI \section2 QOCI for the Oracle Call Interface (OCI) From aadf21b25cad7026f07a5fe7bf19fbedfb1866b7 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 31 Jan 2020 16:47:46 +0100 Subject: [PATCH 28/37] 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 +- src/gui/image/qicon.cpp | 2 +- src/gui/kernel/qpixelformat.cpp | 2 +- src/gui/kernel/qplatformwindow.cpp | 2 +- src/gui/painting/qbackingstore.cpp | 2 +- src/gui/rhi/qrhi.cpp | 8 ++++---- src/network/ssl/qsslpresharedkeyauthenticator.cpp | 2 +- src/plugins/platforms/ios/qiostextinputoverlay.mm | 2 +- src/plugins/platforms/ios/qiosviewcontroller.mm | 2 +- src/plugins/platforms/wasm/qwasmintegration.cpp | 2 +- src/testlib/qtestcase.cpp | 4 ++-- src/widgets/kernel/qopenglwidget.cpp | 2 +- src/widgets/styles/qfusionstyle.cpp | 2 +- src/widgets/styles/qstyleoption.cpp | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index e26508e6318..076b2394ba2 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 b1f3b74cd49..a0423616864 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 f0b81cce660..ab3054d5beb 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() diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 84e387e3173..191217cdc48 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1527,7 +1527,7 @@ QDebug operator<<(QDebug dbg, const QIcon &i) \internal \since 5.6 Attempts to find a suitable @Nx file for the given \a targetDevicePixelRatio - Returns the the \a baseFileName if no such file was found. + Returns the \a baseFileName if no such file was found. Given base foo.png and a target dpr of 2.5, this function will look for foo@3x.png, then foo@2x, then fall back to foo.png if not found. diff --git a/src/gui/kernel/qpixelformat.cpp b/src/gui/kernel/qpixelformat.cpp index c28fe7ac63c..3100d133988 100644 --- a/src/gui/kernel/qpixelformat.cpp +++ b/src/gui/kernel/qpixelformat.cpp @@ -485,7 +485,7 @@ QT_BEGIN_NAMESPACE /*! \fn ByteOrder QPixelFormat::byteOrder() const - The byte order is almost always set the the byte order of the current + The byte order is almost always set the byte order of the current system. However, it can be useful to describe some YUV formats. This function should never return QPixelFormat::CurrentSystemEndian as this value is translated to a endian value in the constructor. diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 65accc9f681..def34f272cc 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -747,7 +747,7 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeo QPlatformWindow subclasses can re-implement this function to provide display refresh synchronized updates. The event should be delivered using QPlatformWindow::deliverUpdateRequest() - to not get out of sync with the the internal state of QWindow. + to not get out of sync with the internal state of QWindow. The default implementation posts an UpdateRequest event to the window after 5 ms. The additional time is there to give the event diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 0a49269c365..2147d9d61d7 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -281,7 +281,7 @@ QSize QBackingStore::size() const bool QBackingStore::scroll(const QRegion &area, int dx, int dy) { // Disable scrolling for non-integer scroll deltas. For this case - // the the existing rendered pixels can't be re-used, and we return + // the existing rendered pixels can't be re-used, and we return // false to signal that a repaint is needed. const qreal nativeDx = QHighDpi::toNativePixels(qreal(dx), d_ptr->window); const qreal nativeDy = QHighDpi::toNativePixels(qreal(dy), d_ptr->window); diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 8ef98d2e427..ca835941d63 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -1653,7 +1653,7 @@ QRhiTextureUploadDescription::QRhiTextureUploadDescription(const QRhiTextureUplo Constructs a texture upload description with the specified \a list of entries. \note \a list can also contain multiple QRhiTextureUploadEntry elements - with the the same layer and level. This makes sense when those uploads are + with the same layer and level. This makes sense when those uploads are partial, meaning their subresource description has a source size or image smaller than the subresource dimensions, and can be more efficient than issuing separate uploadTexture()'s. @@ -3468,7 +3468,7 @@ QRhiResource::Type QRhiGraphicsPipeline::resourceType() const \l{QSurfaceFormat::sRGBColorSpace}{sRGBColorSpace} on the QSurfaceFormat of the QWindow in addition. - \value UsedAsTransferSource Indicates the the swapchain will be used as the + \value UsedAsTransferSource Indicates the swapchain will be used as the source of a readback in QRhiResourceUpdateBatch::readBackTexture(). \value NoVSync Requests disabling waiting for vertical sync, also avoiding @@ -3585,7 +3585,7 @@ QRhiResource::Type QRhiSwapChain::resourceType() const \fn QRhiRenderTarget *QRhiSwapChain::currentFrameRenderTarget() \return a render target that can used with beginPass() in order to render - the the swapchain's current backbuffer. Only valid within a + the swapchain's current backbuffer. Only valid within a QRhi::beginFrame() - QRhi::endFrame() block where beginFrame() was called with this swapchain. @@ -4406,7 +4406,7 @@ void QRhiResourceUpdateBatch::generateMips(QRhiTexture *tex, int layer) recorded. \note the return value is not owned by the caller and must never be - destroyed. Instead, the batch is returned the the pool for reuse by passing + destroyed. Instead, the batch is returned the pool for reuse by passing it to QRhiCommandBuffer::beginPass(), QRhiCommandBuffer::endPass(), or QRhiCommandBuffer::resourceUpdate(), or by calling QRhiResourceUpdateBatch::release() on it. diff --git a/src/network/ssl/qsslpresharedkeyauthenticator.cpp b/src/network/ssl/qsslpresharedkeyauthenticator.cpp index 01e1501763f..ed6dbb87cfb 100644 --- a/src/network/ssl/qsslpresharedkeyauthenticator.cpp +++ b/src/network/ssl/qsslpresharedkeyauthenticator.cpp @@ -141,7 +141,7 @@ QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(const QS /*! \fn QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(QSslPreSharedKeyAuthenticator &&authenticator) - Move-assigns the the QSslPreSharedKeyAuthenticator object \a authenticator to this + Move-assigns the QSslPreSharedKeyAuthenticator object \a authenticator to this object, and returns a reference to the moved instance. */ diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index 0561a826c64..3da4ba5480d 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -511,7 +511,7 @@ static void executeBlockWithoutAnimation(Block block) - (void)createLoupe { - // We magnify the the desktop view. But the loupe itself will be added as a child + // We magnify the desktop view. But the loupe itself will be added as a child // of the desktop view's parent, so it doesn't become a part of what we magnify. _loupeLayer = [[self createLoupeLayer] retain]; _loupeLayer.targetView = _desktopView; diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index ce2aa96ca59..cd4af46ef75 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -452,7 +452,7 @@ if (!focusWindow->screen() || focusWindow->screen()->handle() != self.platformScreen) return; - // All decisions are based on the the top level window + // All decisions are based on the top level window focusWindow = qt_window_private(focusWindow)->topLevelWindow(); #ifndef Q_OS_TVOS diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index fd53cd0baef..ee3f6afb731 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -133,7 +133,7 @@ QWasmIntegration::QWasmIntegration() Q_UNUSED(userData); // This resize event is called when the HTML window is resized. Depending - // on the page layout the the canvas(es) might also have been resized, so we + // on the page layout the canvas(es) might also have been resized, so we // update the Qt screen sizes (and canvas render sizes). if (QWasmIntegration *integration = QWasmIntegration::get()) integration->resizeAllScreens(); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 9ab12c5c68d..70733a692a1 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1301,7 +1301,7 @@ char *toPrettyCString(const char *p, int length) // 3 bytes: "" and a character // 4 bytes: an hex escape sequence (\xHH) if (dst - buffer.data() > 246) { - // plus the the quote, the three dots and NUL, it's 255 in the worst case + // plus the quote, the three dots and NUL, it's 255 in the worst case trimmed = true; break; } @@ -1394,7 +1394,7 @@ char *toPrettyUnicode(QStringView string) *dst++ = '"'; for ( ; p != end; ++p) { if (dst - buffer.data() > 245) { - // plus the the quote, the three dots and NUL, it's 250, 251 or 255 + // plus the quote, the three dots and NUL, it's 250, 251 or 255 trimmed = true; break; } diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index bc5ca21b973..d244162ba39 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -379,7 +379,7 @@ QT_BEGIN_NAMESPACE This is naturally not the only possible solution. One alternative is to use the \l{QOpenGLContext::aboutToBeDestroyed()}{aboutToBeDestroyed()} signal of QOpenGLContext. By connecting a slot, using direct connection, to this signal, - it is possible to perform cleanup whenever the the underlying native context + it is possible to perform cleanup whenever the underlying native context handle, or the entire QOpenGLContext instance, is going to be released. The following snippet is in principle equivalent to the previous one: diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 3bffd7873f5..1646ec75832 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2414,7 +2414,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption QStyle::State oldState = static_cast(styleObject->property("_q_stylestate").value()); uint oldActiveControls = styleObject->property("_q_stylecontrols").toUInt(); - // a scrollbar is transient when the the scrollbar itself and + // a scrollbar is transient when the scrollbar itself and // its sibling are both inactive (ie. not pressed/hovered/moved) bool transient = !option->activeSubControls && !(option->state & State_On); diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 237d496e0eb..be33069c075 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1630,7 +1630,7 @@ QStyleOptionProgressBar::QStyleOptionProgressBar(int version) the default orentation is Qt::Horizontal \deprecated - Use the QStyle::State_Horizontal flag instead (in the the QStyleOption::state member). + Use the QStyle::State_Horizontal flag instead (in the QStyleOption::state member). \sa QProgressBar::orientation */ From 479d0c61d0999502142b3ea45786b6b07a469fa3 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Sun, 2 Feb 2020 13:41:14 +0100 Subject: [PATCH 29/37] Bump version Change-Id: I5ded7891d0d371b2fa8a38d7c6fba765268eb1ce --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index f19e8e64f57..88e232942b4 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -6,4 +6,4 @@ DEFINES += QT_NO_JAVA_STYLE_ITERATORS QT_SOURCE_TREE = $$PWD QT_BUILD_TREE = $$shadowed($$PWD) -MODULE_VERSION = 5.14.1 +MODULE_VERSION = 5.14.2 From a049325cc708b483ed1aadc6589419f4d74b19f3 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 20 Jan 2020 15:54:42 +0100 Subject: [PATCH 30/37] 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(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 5a7f8242de0..c1dd04f03c9 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 From 77e8023eaf671b3ce9eae16f9b84f8571f441828 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Mon, 3 Feb 2020 13:05:39 +0200 Subject: [PATCH 31/37] Android: use the correct string resources for ok and cancel Fixes: QTBUG-76942 Change-Id: I0c0ccad4980a458ab291ca8ee533fadbedc90456 Reviewed-by: BogDan Vatra --- .../org/qtproject/qt5/android/bindings/QtActivityLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java index fad95884252..c3074c353e2 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java @@ -62,7 +62,7 @@ public class QtActivityLoader extends QtLoader { protected void downloadUpgradeMinistro(String msg) { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(m_activity); downloadDialog.setMessage(msg); - downloadDialog.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { + downloadDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { try { @@ -76,7 +76,7 @@ public class QtActivityLoader extends QtLoader { } }); - downloadDialog.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { + downloadDialog.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { m_activity.finish(); From c29fac453f3eaac73b29eb0a66d130220d073fc6 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 31 Jan 2020 14:30:20 +0100 Subject: [PATCH 32/37] Markdown importer: use Unicode decoding Given we feed UTF-8 data into the importer, it must be able to cope with Unicode. Build md4c with UTF-8 support, advertise it at usage site, and change a couple of broken decodings. Driveby: the textedit example used the wrong codec to decode a Markdown file. While the Markdown spec doesn't deal with encodings, using the default one for HTML is certainly wrong. Port the loading of both markdown and plaintext to UTF-8, as that what _saving_ via QTextDocumentWriter would use by default. Change-Id: I51c6214cfe45ebfc5a67a7366f7866a5328366ec Reviewed-by: Shawn Rutledge --- examples/widgets/richtext/textedit/textedit.cpp | 8 ++++---- src/3rdparty/md4c.pri | 1 + src/gui/text/qtextmarkdownimporter.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index f99fa306dfe..7708b25a241 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -419,18 +419,18 @@ bool TextEdit::load(const QString &f) QByteArray data = file.readAll(); QTextCodec *codec = Qt::codecForHtml(data); QString str = codec->toUnicode(data); - QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename); - textEdit->document()->setBaseUrl(baseUrl); if (Qt::mightBeRichText(str)) { + QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename); + textEdit->document()->setBaseUrl(baseUrl); textEdit->setHtml(str); } else { #if QT_CONFIG(textmarkdownreader) QMimeDatabase db; if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/markdown")) - textEdit->setMarkdown(str); + textEdit->setMarkdown(QString::fromUtf8(data)); else #endif - textEdit->setPlainText(QString::fromLocal8Bit(data)); + textEdit->setPlainText(QString::fromUtf8(data)); } setCurrentFileName(f); diff --git a/src/3rdparty/md4c.pri b/src/3rdparty/md4c.pri index e0150dc6ed0..8de2991ac24 100644 --- a/src/3rdparty/md4c.pri +++ b/src/3rdparty/md4c.pri @@ -1,3 +1,4 @@ INCLUDEPATH += $$PWD/md4c HEADERS += $$PWD/md4c/md4c.h SOURCES += $$PWD/md4c/md4c.c +DEFINES += MD4C_USE_UTF8 diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 88965046ce0..b6a275f59c1 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -397,8 +397,8 @@ int QTextMarkdownImporter::cbEnterSpan(int spanType, void *det) break; case MD_SPAN_A: { MD_SPAN_A_DETAIL *detail = static_cast(det); - QString url = QString::fromLatin1(detail->href.text, int(detail->href.size)); - QString title = QString::fromLatin1(detail->title.text, int(detail->title.size)); + QString url = QString::fromUtf8(detail->href.text, int(detail->href.size)); + QString title = QString::fromUtf8(detail->title.text, int(detail->title.size)); charFmt.setAnchorHref(url); charFmt.setAnchorNames(QStringList(title)); charFmt.setForeground(m_palette.link()); From 2d265dce58d26047f196d79eabfe41edab45c799 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 31 Jan 2020 14:32:24 +0100 Subject: [PATCH 33/37] Markdown importer: properly set hyperlinks The "title" in markdown is the tooltip, not the name attribute of a link. Also, tell the char format that it's an anchor. Change-Id: I2978848ec6705fe16376d6fe17f31007cce4b801 Reviewed-by: Shawn Rutledge --- src/gui/text/qtextmarkdownimporter.cpp | 4 +- src/gui/text/qtextmarkdownwriter.cpp | 76 ++++++++++++++++++- .../text/qtextmarkdownwriter/data/links.md | 25 ++++++ .../tst_qtextmarkdownwriter.cpp | 1 + 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 tests/auto/gui/text/qtextmarkdownwriter/data/links.md diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index b6a275f59c1..7e18a108955 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -399,8 +399,10 @@ int QTextMarkdownImporter::cbEnterSpan(int spanType, void *det) MD_SPAN_A_DETAIL *detail = static_cast(det); QString url = QString::fromUtf8(detail->href.text, int(detail->href.size)); QString title = QString::fromUtf8(detail->title.text, int(detail->title.size)); + charFmt.setAnchor(true); charFmt.setAnchorHref(url); - charFmt.setAnchorNames(QStringList(title)); + if (!title.isEmpty()) + charFmt.setToolTip(title); charFmt.setForeground(m_palette.link()); qCDebug(lcMD) << "anchor" << url << title; } break; diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index c9a63920c37..7bd321beccc 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -56,10 +56,13 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcMDW, "qt.text.markdown.writer") static const QChar Space = QLatin1Char(' '); +static const QChar Tab = QLatin1Char('\t'); static const QChar Newline = QLatin1Char('\n'); +static const QChar CarriageReturn = QLatin1Char('\r'); static const QChar LineBreak = QChar(0x2028); static const QChar DoubleQuote = QLatin1Char('"'); static const QChar Backtick = QLatin1Char('`'); +static const QChar Backslash = QLatin1Char('\\'); static const QChar Period = QLatin1Char('.'); QTextMarkdownWriter::QTextMarkdownWriter(QTextStream &stream, QTextDocument::MarkdownFeatures features) @@ -291,6 +294,72 @@ static void maybeEscapeFirstChar(QString &s) } } +struct LineEndPositions { + const QChar *lineEnd; + const QChar *nextLineBegin; +}; + +static LineEndPositions findLineEnd(const QChar *begin, const QChar *end) +{ + LineEndPositions result{ end, end }; + + while (begin < end) { + if (*begin == Newline) { + result.lineEnd = begin; + result.nextLineBegin = begin + 1; + break; + } else if (*begin == CarriageReturn) { + result.lineEnd = begin; + result.nextLineBegin = begin + 1; + if (((begin + 1) < end) && begin[1] == Newline) + ++result.nextLineBegin; + break; + } + + ++begin; + } + + return result; +} + +static bool isBlankLine(const QChar *begin, const QChar *end) +{ + while (begin < end) { + if (*begin != Space && *begin != Tab) + return false; + ++begin; + } + return true; +} + +static QString createLinkTitle(const QString &title) +{ + QString result; + result.reserve(title.size() + 2); + result += DoubleQuote; + + const QChar *data = title.data(); + const QChar *end = data + title.size(); + + while (data < end) { + const auto lineEndPositions = findLineEnd(data, end); + + if (!isBlankLine(data, lineEndPositions.lineEnd)) { + while (data < lineEndPositions.nextLineBegin) { + if (*data == DoubleQuote) + result += Backslash; + result += *data; + ++data; + } + } + + data = lineEndPositions.nextLineBegin; + } + + result += DoubleQuote; + return result; +} + int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ignoreFormat, bool ignoreEmpty) { if (block.text().isEmpty() && ignoreEmpty) @@ -445,7 +514,12 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign col += s.length(); } else if (fmt.hasProperty(QTextFormat::AnchorHref)) { QString s = QLatin1Char('[') + fragmentText + QLatin1String("](") + - fmt.property(QTextFormat::AnchorHref).toString() + QLatin1Char(')'); + fmt.property(QTextFormat::AnchorHref).toString(); + if (fmt.hasProperty(QTextFormat::TextToolTip)) { + s += Space; + s += createLinkTitle(fmt.property(QTextFormat::TextToolTip).toString()); + } + s += QLatin1Char(')'); if (wrap && col + s.length() > ColumnLimit) { m_stream << Newline << wrapIndentString; col = m_wrappedLineIndent; diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/links.md b/tests/auto/gui/text/qtextmarkdownwriter/data/links.md new file mode 100644 index 00000000000..33cdb2b3ab9 --- /dev/null +++ b/tests/auto/gui/text/qtextmarkdownwriter/data/links.md @@ -0,0 +1,25 @@ +A series of links. + +[link](/uri) + +[link]() + +[link](/uri "title") + +[link](/uri "àbcdè") + +[link](/uri "title title \" title title") + +[link](/url "title \""") + +[link](/url "title +title +title title +\"title\" title \" +title") + +* [link](/url "title") +* [link](/url) +* [link](/url "title +title title") +* nonlink diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index d15e856a20d..31592c7f0f9 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -368,6 +368,7 @@ void tst_QTextMarkdownWriter::rewriteDocument_data() QTest::newRow("example") << "example.md"; QTest::newRow("list items after headings") << "headingsAndLists.md"; QTest::newRow("word wrap") << "wordWrap.md"; + QTest::newRow("links") << "links.md"; } void tst_QTextMarkdownWriter::rewriteDocument() From e0f9b57462226b4f5842d1e857612d6c8fbe38fd Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 24 Jan 2020 16:01:33 +0100 Subject: [PATCH 34/37] 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(-) diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index d7319c15325..faaa15cf6b7 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); } From 3730452bfe098f8cdc68ec2183dd283a17f7ad39 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 10:53:01 +0100 Subject: [PATCH 35/37] 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(-) diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index faaa15cf6b7..4a38adf3091 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()); } From 71fa90a37c4f250aa4a6ae8e6bd957dd372566c8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 6 Jan 2020 13:15:06 +0100 Subject: [PATCH 36/37] 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 +-- .../auto/corelib/text/qlocale/tst_qlocale.cpp | 30 +++++++++------- util/locale_database/cldr2qlocalexml.py | 1 + 5 files changed, 59 insertions(+), 28 deletions(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 26db674a99d..11e788c2008 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 7bdae662c78..5381f0f975d 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 bb240095232..7e26e86fdf3 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 diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index 8f434acb29e..60ed22488f0 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -1869,14 +1869,16 @@ void tst_QLocale::toDateTime() // Format number string according to system locale settings. // Expected in format is US "1,234.56". -QString systemLocaleFormatNumber(const QString &numberString) +QString systemLocaleFormatNumber(QString &&numberString) { QLocale locale = QLocale::system(); - QString numberStringCopy = numberString; - return numberStringCopy.replace(QChar(','), QChar('G')) - .replace(QChar('.'), QChar('D')) - .replace(QChar('G'), locale.groupSeparator()) - .replace(QChar('D'), locale.decimalPoint()); + QString numberStringMunged = + numberString.replace(QChar(','), QChar('G')).replace(QChar('.'), QChar('D')); + if (locale.numberOptions() & QLocale::OmitGroupSeparator) + numberStringMunged.remove(QLatin1Char('G')); + else + numberStringMunged.replace(QChar('G'), locale.groupSeparator()); + return numberStringMunged.replace(QChar('D'), locale.decimalPoint()); } void tst_QLocale::macDefaultLocale() @@ -1899,12 +1901,14 @@ void tst_QLocale::macDefaultLocale() // independently of the locale. Verify that they have one of the // allowed values and are not the same. QVERIFY(locale.decimalPoint() == QChar('.') || locale.decimalPoint() == QChar(',')); - QVERIFY(locale.groupSeparator() == QChar(',') - || locale.groupSeparator() == QChar('.') - || locale.groupSeparator() == QChar('\xA0') // no-breaking space - || locale.groupSeparator() == QChar('\'') - || locale.groupSeparator() == QChar()); - QVERIFY(locale.decimalPoint() != locale.groupSeparator()); + if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)) { + QVERIFY(locale.groupSeparator() == QChar(',') + || locale.groupSeparator() == QChar('.') + || locale.groupSeparator() == QChar('\xA0') // no-breaking space + || locale.groupSeparator() == QChar('\'') + || locale.groupSeparator() == QChar()); + QVERIFY(locale.decimalPoint() != locale.groupSeparator()); + } // make sure we are using the system to parse them QCOMPARE(locale.toString(1234.56), systemLocaleFormatNumber(QString("1,234.56"))); diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py index 072ea9e4ede..a1df872e017 100755 --- a/util/locale_database/cldr2qlocalexml.py +++ b/util/locale_database/cldr2qlocalexml.py @@ -305,6 +305,7 @@ def _generateLocaleInfo(path, language_code, script_code, country_code, variant_ result['decimal'] = get_number_in_system(path, "numbers/symbols/decimal", numbering_system) result['group'] = get_number_in_system(path, "numbers/symbols/group", numbering_system) + assert result['decimal'] != result['group'] result['list'] = get_number_in_system(path, "numbers/symbols/list", numbering_system) result['percent'] = get_number_in_system(path, "numbers/symbols/percentSign", numbering_system) try: From 056230cc9c3309823a93df0e34c92affb29df9e4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Jan 2020 14:32:06 -0800 Subject: [PATCH 37/37] 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(-) diff --git a/src/corelib/global/qfloat16tables.cpp b/src/corelib/global/qfloat16tables.cpp index 3d764937d7d..b87986d6b82 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,