From a1f4321bbba2f3bff24d753ce766be738dbfa61a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 3 Dec 2019 15:12:51 +0100 Subject: [PATCH 01/22] QTextDocument: Give fontFamily() precedence over fontFamilies() If the singular fontFamily() is given, then this is obviously the one to be preferred over any plural fontFamilies(). Make sure it always ends up first in the list of emitted font families. Change-Id: I1e3b1ba29721c8298b1a0d4a1e1da49ba5b4e7ac Fixes: QTBUG-80475 Reviewed-by: Lars Knoll --- src/gui/text/qtextdocument.cpp | 39 +++++++------------ src/gui/text/qtextdocument_p.h | 1 - .../text/qtextdocument/tst_qtextdocument.cpp | 21 ++++++++++ 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 4b35509ace6..25c153910d2 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2297,6 +2297,17 @@ QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc) defaultCharFormat.clearProperty(QTextFormat::TextUnderlineStyle); } +static QStringList resolvedFontFamilies(const QTextCharFormat &format) +{ + QStringList fontFamilies = format.fontFamilies().toStringList(); + const QString mainFontFamily = format.fontFamily(); + if (!mainFontFamily.isEmpty() && !fontFamilies.startsWith(mainFontFamily)) { + fontFamilies.removeAll(mainFontFamily); + fontFamilies.prepend(mainFontFamily); + } + return fontFamilies; +} + /*! Returns the document in HTML format. The conversion may not be perfect, especially for complex documents, due to the limitations @@ -2325,11 +2336,7 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) if (mode == ExportEntireDocument) { html += QLatin1String(" style=\""); - QStringList fontFamilies = defaultCharFormat.fontFamilies().toStringList(); - if (!fontFamilies.isEmpty()) - emitFontFamily(fontFamilies); - else - emitFontFamily(defaultCharFormat.fontFamily()); + emitFontFamily(resolvedFontFamilies(defaultCharFormat)); if (defaultCharFormat.hasProperty(QTextFormat::FontPointSize)) { html += QLatin1String(" font-size:"); @@ -2391,14 +2398,10 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) bool attributesEmitted = false; { - const QStringList families = format.fontFamilies().toStringList(); - const QString family = format.fontFamily(); - if (!families.isEmpty() && families != defaultCharFormat.fontFamilies().toStringList()) { + const QStringList families = resolvedFontFamilies(format); + if (!families.isEmpty() && families != resolvedFontFamilies(defaultCharFormat)) { emitFontFamily(families); attributesEmitted = true; - } else if (!family.isEmpty() && family != defaultCharFormat.fontFamily()) { - emitFontFamily(family); - attributesEmitted = true; } } @@ -2661,20 +2664,6 @@ void QTextHtmlExporter::emitPageBreakPolicy(QTextFormat::PageBreakFlags policy) html += QLatin1String(" page-break-after:always;"); } -void QTextHtmlExporter::emitFontFamily(const QString &family) -{ - html += QLatin1String(" font-family:"); - - QLatin1String quote("\'"); - if (family.contains(QLatin1Char('\''))) - quote = QLatin1String("""); - - html += quote; - html += family.toHtmlEscaped(); - html += quote; - html += QLatin1Char(';'); -} - void QTextHtmlExporter::emitFontFamily(const QStringList &families) { html += QLatin1String(" font-family:"); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index f4e7a25f225..40252c93ebd 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -396,7 +396,6 @@ private: void emitBorderStyle(QTextFrameFormat::BorderStyle style); void emitPageBreakPolicy(QTextFormat::PageBreakFlags policy); - void emitFontFamily(const QString &family); void emitFontFamily(const QStringList &families); void emitBackgroundAttribute(const QTextFormat &format); diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 33d4976b2a8..e075c107b73 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -194,6 +194,8 @@ private slots: void fontTagFace(); void clearUndoRedoStacks(); + void mergeFontFamilies(); + private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); @@ -3579,6 +3581,25 @@ void tst_QTextDocument::fontTagFace() } } +void tst_QTextDocument::mergeFontFamilies() +{ + QTextDocument td; + td.setHtml(QLatin1String( + "" + "Hello world" + "")); + + QTextCharFormat newFormat; + newFormat.setFontFamily(QLatin1String("Jokerman")); + + QTextCursor cursor = QTextCursor(&td); + cursor.setPosition(0); + cursor.setPosition(QByteArray("Hello World").length(), QTextCursor::KeepAnchor); + cursor.mergeCharFormat(newFormat); + + QVERIFY(td.toHtml().contains(QLatin1String("font-family:'Jokerman','MS Shell Dlg 2';"))); +} + void tst_QTextDocument::clearUndoRedoStacks() { QTextDocument doc; From c027d9b61e15ab021a6fb5503e3206929055da02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 2 Jan 2020 12:22:02 +0100 Subject: [PATCH 02/22] Remove commented out code added by mistake in 7ac4e55cb979d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibd53518be9d2b29dd880912bdb81c06435543789 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index d8c931e9a17..b7f15a2bf12 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -396,8 +396,6 @@ QVariant QCocoaIntegration::styleHint(StyleHint hint) const return QCoreTextFontEngine::fontSmoothingGamma(); case ShowShortcutsInContextMenus: return QVariant(false); - // case CursorFlashTime: - // return 50000; default: break; } From a6f56251ca6090cb0ba4c4989d7ccc638b1dbe2b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 2 Jan 2020 12:24:15 +0100 Subject: [PATCH 03/22] Fix some qdoc warnings src/corelib/tools/qhash.cpp:2596: (qdoc) warning: clang found diagnostics parsing \fn template template QMultiHash::QMultiHash(InputIterator begin, InputIterator end) error: 'QMultiHash' is not a class, namespace, or enumeration src/corelib/kernel/qobject.cpp:4593: (qdoc) warning: Undocumented parameter 'EXPORT_MACRO' in QObject::Q_NAMESPACE_EXPORT src/corelib/global/qfloat16.cpp:129: (qdoc) warning: Cannot tie this documentation to anything src/corelib/text/qlocale.qdoc:1204: (qdoc) warning: Overrides a previous doc src/corelib/text/qlocale.qdoc:1187: (qdoc) warning: (The previous doc is here) src/network/kernel/qhostinfo.cpp:597: (qdoc) warning: clang found diagnostics parsing \fn QHostInfo(QHostInfo &&other) src/printsupport/dialogs/qabstractprintdialog.cpp:346: (qdoc) warning: clang found diagnostics parsing \fn int QAbstractPrintDialog::exec(): error: out-of-line definition of 'exec' does not match any declaration in 'QAbstractPrintDialog' src/testlib/qsignalspy.qdoc:101: (qdoc) warning: clang found diagnostics parsing \fn QSignalSpy(const QObject *obj, const QMetaMethod &signal): error: expected unqualified-id src/testlib/doc/src/qttest-best-practices.qdoc:28: (qdoc) warning: Can't link to 'Q_VERIFY2()' src/widgets/kernel/qactiongroup.cpp:291: (qdoc) warning: Undocumented parameter 'b' in QActionGroup::setExclusive() src/widgets/kernel/qactiongroup.cpp:305: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/widgets/kernel/qshortcut.cpp:542: (qdoc) warning: No such parameter 'context' in QShortcut::QShortcut() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'minimumTime' in QDateTimeEdit::setTimeRange() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'maximumTime' in QDateTimeEdit::setTimeRange() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'less' in QDateTimeEdit::setTimeRange() Change-Id: I9799b5135e84c4d811674b2d114ef27315bc12df Reviewed-by: Paul Wicking --- src/corelib/global/qfloat16.cpp | 8 ++++---- src/corelib/kernel/qobject.cpp | 2 +- src/corelib/text/qlocale.qdoc | 8 -------- src/corelib/tools/qhash.cpp | 2 +- src/network/kernel/qhostinfo.cpp | 2 +- src/printsupport/dialogs/qabstractprintdialog.cpp | 7 ------- src/testlib/doc/src/qttest-best-practices.qdoc | 2 +- src/testlib/qsignalspy.qdoc | 2 +- src/widgets/kernel/qactiongroup.cpp | 5 +++-- src/widgets/kernel/qshortcut.cpp | 2 +- src/widgets/widgets/qdatetimeedit.cpp | 7 +++---- 11 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index 6c21b7de5a3..c868e879b7e 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -109,7 +109,7 @@ QT_BEGIN_NAMESPACE /*! \internal \since 5.14 - bool qfloat16::isInf() const noexcept + \fn bool qfloat16::isInf() const noexcept Tests whether this \c qfloat16 value is an infinity. @@ -119,7 +119,7 @@ QT_BEGIN_NAMESPACE /*! \internal \since 5.14 - bool qfloat16::isNaN() const noexcept + \fn bool qfloat16::isNaN() const noexcept Tests whether this \c qfloat16 value is "not a number". @@ -128,7 +128,7 @@ QT_BEGIN_NAMESPACE /*! \since 5.14 - bool qfloat16::isNormal() const noexcept + \fn bool qfloat16::isNormal() const noexcept Tests whether this \c qfloat16 value is finite and in normal form. @@ -138,7 +138,7 @@ QT_BEGIN_NAMESPACE /*! \internal \since 5.14 - bool qfloat16::isFinite() const noexcept + \fn bool qfloat16::isFinite() const noexcept Tests whether this \c qfloat16 value is finite. diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index cf107498dd7..cc50d9ccc71 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4612,7 +4612,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) It works exactly like the Q_NAMESPACE macro. However, the external \c{staticMetaObject} variable that gets defined in the namespace - is declared with the supplied \c{EXPORT_MACRO} qualifier. This is + is declared with the supplied \a EXPORT_MACRO qualifier. This is useful if the object needs to be exported from a dynamic library. \sa Q_NAMESPACE, {Creating Shared Libraries} diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc index 6c9d6f9d11f..dbcd71f1a01 100644 --- a/src/corelib/text/qlocale.qdoc +++ b/src/corelib/text/qlocale.qdoc @@ -1201,14 +1201,6 @@ \sa toShort() */ -/*! -\fn QString QLocale::toString(ushort i) const - -\overload - -\sa toUShort() -*/ - /*! \fn QString QLocale::toString(int i) const diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index a53d6db9975..6ec8019ba36 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -2597,7 +2597,7 @@ uint qHash(long double key, uint seed) noexcept \sa operator=() */ -/*! \fn template template QMultiHash::QMultiHash(InputIterator begin, InputIterator end) +/*! \fn template template QMultiHash::QMultiHash(InputIterator begin, InputIterator end) \since 5.14 Constructs a multi-hash with a copy of each of the elements in the iterator range diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index f9335c3bb97..9dbb1549149 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -595,7 +595,7 @@ QHostInfo::QHostInfo(const QHostInfo &other) } /*! - \fn QHostInfo(QHostInfo &&other) + \fn QHostInfo::QHostInfo(QHostInfo &&other) Move-constructs a new QHostInfo from \a other. diff --git a/src/printsupport/dialogs/qabstractprintdialog.cpp b/src/printsupport/dialogs/qabstractprintdialog.cpp index 1a2aa7afac5..b0d03037e6e 100644 --- a/src/printsupport/dialogs/qabstractprintdialog.cpp +++ b/src/printsupport/dialogs/qabstractprintdialog.cpp @@ -343,13 +343,6 @@ void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter) pd = printer->d_func(); } -/*! - \fn int QAbstractPrintDialog::exec() - - This virtual function is called to pop up the dialog. It must be - reimplemented in subclasses. -*/ - /*! \class QPrintDialog diff --git a/src/testlib/doc/src/qttest-best-practices.qdoc b/src/testlib/doc/src/qttest-best-practices.qdoc index 8ad67acce62..952fd3259d1 100644 --- a/src/testlib/doc/src/qttest-best-practices.qdoc +++ b/src/testlib/doc/src/qttest-best-practices.qdoc @@ -243,7 +243,7 @@ Instead of \c Q_ASSERT, the \l QCOMPARE() or \l QVERIFY() macro variants should be used. They cause the current test to report a failure and terminate, but allow the remaining test functions to be executed and the - entire test program to terminate normally. \l Q_VERIFY2() even allows a + entire test program to terminate normally. \l QVERIFY2() even allows a descriptive error message to be recorded in the test log. \section1 Writing Reliable Tests diff --git a/src/testlib/qsignalspy.qdoc b/src/testlib/qsignalspy.qdoc index d532ad478d6..d40c84907c3 100644 --- a/src/testlib/qsignalspy.qdoc +++ b/src/testlib/qsignalspy.qdoc @@ -98,7 +98,7 @@ \snippet code/doc_src_qsignalspy.cpp 6 */ -/*! \fn QSignalSpy(const QObject *obj, const QMetaMethod &signal) +/*! \fn QSignalSpy::QSignalSpy(const QObject *obj, const QMetaMethod &signal) \since 5.14 Constructs a new QSignalSpy that listens for emissions of the \a signal diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp index 1d9213de0c0..d359703db34 100644 --- a/src/widgets/kernel/qactiongroup.cpp +++ b/src/widgets/kernel/qactiongroup.cpp @@ -292,7 +292,8 @@ QList QActionGroup::actions() const \brief Enable or disable the group exclusion checking This is a convenience method that calls - setExclusionPolicy(ExclusionPolicy::Exclusive). + setExclusionPolicy(ExclusionPolicy::Exclusive) when \a b is true, + else setExclusionPolicy(QActionGroup::ExclusionPolicy::None). \sa QActionGroup::exclusionPolicy */ @@ -303,7 +304,7 @@ void QActionGroup::setExclusive(bool b) } /*! - \brief Returs true if the group is exclusive + \brief Returns true if the group is exclusive The group is exclusive if the ExclusionPolicy is either Exclusive or ExclusionOptional. diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index eec65c86259..f157ba2943f 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -475,7 +475,7 @@ QShortcut::QShortcut(QWidget *parent) match the \a key sequence. Depending on the ambiguity of the event, the shortcut will call the \a member function, or the \a ambiguousMember function, if the key press was in the shortcut's - \a context. + \a shortcutContext. */ QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, const char *member, const char *ambiguousMember, diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 9189319364d..da4aaadc979 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -335,7 +335,6 @@ void QDateTimeEdit::setCalendar(QCalendar calendar) /*! \since 4.4 \property QDateTimeEdit::minimumDateTime - \brief the minimum datetime of the date time edit Changing this property implicitly updates the \l minimumDate and \l @@ -637,8 +636,8 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max) Note that these only constrain the date time edit's value on, respectively, the \l minimumDate and \l maximumDate. When these date - properties do not coincide, times after \a maximumTime are allowed on dates - before \l maximumDate and times before \a minimumTime are allowed on dates + properties do not coincide, times after \a max are allowed on dates + before \l maximumDate and times before \a min are allowed on dates after \l minimumDate. \snippet code/src_gui_widgets_qdatetimeedit.cpp 5 @@ -649,7 +648,7 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max) If either \a min or \a max is invalid, this function does nothing. This function preserves the \l minimumDate and \l maximumDate properties. If those - properties coincide and max is \a less than \a min, \a min is used as \a max. + properties coincide and \a max is less than \a min, \a min is used as \a max. \sa minimumTime, maximumTime, setDateTimeRange(), QTime::isValid() */ From 05e5306787d3511ce9df2ffc8dbefe529f889eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 21 Jun 2019 14:43:39 +0200 Subject: [PATCH 04/22] styles example: Implement standarPalette() Instead of polishing the (possible) system palette. Makes the checkbox for "Use style's standard palette" actually work for the custom style, and is how styles are supposed to provide their own preferred palette. Change-Id: I3228ef45c023d0d058e48ff0fc14f094367b2008 Reviewed-by: Timur Pocheptsov --- examples/widgets/doc/src/styles.qdoc | 10 +-- .../widgets/styles/norwegianwoodstyle.cpp | 64 ++++++++++--------- .../widgets/styles/norwegianwoodstyle.h | 4 +- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/examples/widgets/doc/src/styles.qdoc b/examples/widgets/doc/src/styles.qdoc index a3a02768c66..7a7ae20e910 100644 --- a/examples/widgets/doc/src/styles.qdoc +++ b/examples/widgets/doc/src/styles.qdoc @@ -85,8 +85,8 @@ \snippet widgets/styles/norwegianwoodstyle.cpp 0 - The \c polish() function is reimplemented from QStyle. It takes a - QPalette as a reference and adapts the palette to fit the style. + The \c standardPalette() function is reimplemented from QStyle. + It returns a QPalette with the style's preferred colors and textures. Most styles don't need to reimplement that function. The Norwegian Wood style reimplements it to set a "wooden" palette. @@ -381,7 +381,7 @@ a certain \l{QPalette::ColorRole}{color role}, for all three \l{QPalette::ColorGroup}{color groups} (active, disabled, inactive). We used it to initialize the Norwegian Wood palette in - \c polish(QPalette &). + \c standardPalette. \snippet widgets/styles/norwegianwoodstyle.cpp 39 \snippet widgets/styles/norwegianwoodstyle.cpp 40 @@ -444,10 +444,6 @@ current style's \l{QStyle::standardPalette()}{standard palette} is used; otherwise, the system's default palette is honored. - For the Norwegian Wood style, this makes no difference because we - always override the palette with our own palette in \c - NorwegianWoodStyle::polish(). - \snippet widgets/styles/widgetgallery.cpp 9 \snippet widgets/styles/widgetgallery.cpp 10 diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp index bbdb626a186..31150cd994e 100644 --- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp +++ b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp @@ -62,42 +62,48 @@ NorwegianWoodStyle::NorwegianWoodStyle() : } //! [0] -void NorwegianWoodStyle::polish(QPalette &palette) +QPalette NorwegianWoodStyle::standardPalette() const { - QColor brown(212, 140, 95); - QColor beige(236, 182, 120); - QColor slightlyOpaqueBlack(0, 0, 0, 63); + if (!m_standardPalette.isBrushSet(QPalette::Disabled, QPalette::Mid)) { + QColor brown(212, 140, 95); + QColor beige(236, 182, 120); + QColor slightlyOpaqueBlack(0, 0, 0, 63); - QImage backgroundImage(":/images/woodbackground.png"); - QImage buttonImage(":/images/woodbutton.png"); - QImage midImage = buttonImage.convertToFormat(QImage::Format_RGB32); + QImage backgroundImage(":/images/woodbackground.png"); + QImage buttonImage(":/images/woodbutton.png"); + QImage midImage = buttonImage.convertToFormat(QImage::Format_RGB32); - QPainter painter; - painter.begin(&midImage); - painter.setPen(Qt::NoPen); - painter.fillRect(midImage.rect(), slightlyOpaqueBlack); - painter.end(); -//! [0] + QPainter painter; + painter.begin(&midImage); + painter.setPen(Qt::NoPen); + painter.fillRect(midImage.rect(), slightlyOpaqueBlack); + painter.end(); + //! [0] -//! [1] - palette = QPalette(brown); + //! [1] + QPalette palette(brown); - palette.setBrush(QPalette::BrightText, Qt::white); - palette.setBrush(QPalette::Base, beige); - palette.setBrush(QPalette::Highlight, Qt::darkGreen); - setTexture(palette, QPalette::Button, buttonImage); - setTexture(palette, QPalette::Mid, midImage); - setTexture(palette, QPalette::Window, backgroundImage); + palette.setBrush(QPalette::BrightText, Qt::white); + palette.setBrush(QPalette::Base, beige); + palette.setBrush(QPalette::Highlight, Qt::darkGreen); + setTexture(palette, QPalette::Button, buttonImage); + setTexture(palette, QPalette::Mid, midImage); + setTexture(palette, QPalette::Window, backgroundImage); - QBrush brush = palette.window(); - brush.setColor(brush.color().darker()); + QBrush brush = palette.window(); + brush.setColor(brush.color().darker()); - palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush); - palette.setBrush(QPalette::Disabled, QPalette::Text, brush); - palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); - palette.setBrush(QPalette::Disabled, QPalette::Base, brush); - palette.setBrush(QPalette::Disabled, QPalette::Button, brush); - palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); + palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush); + palette.setBrush(QPalette::Disabled, QPalette::Text, brush); + palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); + palette.setBrush(QPalette::Disabled, QPalette::Base, brush); + palette.setBrush(QPalette::Disabled, QPalette::Button, brush); + palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); + + m_standardPalette = palette; + } + + return m_standardPalette; } //! [1] diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.h b/examples/widgets/widgets/styles/norwegianwoodstyle.h index 5a1783eb4d1..62ca502d05c 100644 --- a/examples/widgets/widgets/styles/norwegianwoodstyle.h +++ b/examples/widgets/widgets/styles/norwegianwoodstyle.h @@ -66,7 +66,8 @@ class NorwegianWoodStyle : public QProxyStyle public: NorwegianWoodStyle(); - void polish(QPalette &palette) override; + QPalette standardPalette() const override; + void polish(QWidget *widget) override; void unpolish(QWidget *widget) override; int pixelMetric(PixelMetric metric, const QStyleOption *option, @@ -82,6 +83,7 @@ private: static void setTexture(QPalette &palette, QPalette::ColorRole role, const QImage &image); static QPainterPath roundRectPath(const QRect &rect); + mutable QPalette m_standardPalette; }; //! [0] From ee1b77e13240ae9e68af62ed9cfadabe3f8c936e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 13 Dec 2019 13:14:34 +0100 Subject: [PATCH 05/22] dumpcpp: Use tblCopy to ensure the path is detected correctly This amends faf742b05d0564a58bfe0290e53e0b2844bc59c1 Change-Id: Ia80a4274f61d895c297b2fae5df62c86db95c14c Reviewed-by: Joerg Bornemann --- mkspecs/features/win32/dumpcpp.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/win32/dumpcpp.prf b/mkspecs/features/win32/dumpcpp.prf index d19da3d0778..589d700e4e0 100644 --- a/mkspecs/features/win32/dumpcpp.prf +++ b/mkspecs/features/win32/dumpcpp.prf @@ -26,9 +26,9 @@ QMAKE_EXTRA_COMPILERS += dumpcpp_impl !build_pass:have_target:!contains(TEMPLATE, vc.*) { for(tlb, TYPELIBS) { tlbCopy = $$replace(tlb, \", ) - hdr = $$basename(tlb) + hdr = $$basename(tlbCopy) hdr = $$section(hdr, ., 0, -2) - tmp_command = $$QMAKE_DUMPCPP $$system_quote($$absolute_path($$tlb, $$_PRO_FILE_PWD_)) \ + tmp_command = $$QMAKE_DUMPCPP $$system_quote($$absolute_path($$tlbCopy, $$_PRO_FILE_PWD_)) \ -o $$system_quote($$OUT_PWD/$$hdr) qaxcontainer_compat: tmp_command += -compat !exists($$OUT_PWD/$${hdr}.h): system($$tmp_command) From ef4448f1294f0e8ff2e398f1b8917917c3ac0d0b Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 11 Dec 2019 08:13:32 +0100 Subject: [PATCH 06/22] Always add the extra Android apk and aab targets The extra targets should be added to the project regardless so that qmake can handle it appropriately. This enables make apk to work correctly then from a SUBDIRS project. Fixes: QTBUG-80351 Change-Id: If5903e0d2f543babfdb4ebbb13502e32ab97c6fc Reviewed-by: Joerg Bornemann --- mkspecs/features/android/android.prf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkspecs/features/android/android.prf b/mkspecs/features/android/android.prf index 26374cabcaf..af004bbb25c 100644 --- a/mkspecs/features/android/android.prf +++ b/mkspecs/features/android/android.prf @@ -41,10 +41,9 @@ build_pass { INSTALLS *= target } } else { - QMAKE_EXTRA_TARGETS *= aab apk apk_install_target - android-build-distclean.commands = \ $$QMAKE_DEL_TREE $$shell_quote($$shell_path($$OUT_PWD/android-build)) QMAKE_EXTRA_TARGETS *= android-build-distclean CLEAN_DEPS += android-build-distclean } +QMAKE_EXTRA_TARGETS *= aab apk apk_install_target From 240a8514f84e9be116acb34991b12a7aa2279914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 2 Jan 2020 13:58:49 +0100 Subject: [PATCH 07/22] Fix syncqt warning in qtestsupport_widgets.h Change-Id: I4f350e3c209dc9a39e849c9c39c41da700abeb60 Reviewed-by: Timur Pocheptsov --- src/widgets/kernel/qtestsupport_widgets.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/kernel/qtestsupport_widgets.h b/src/widgets/kernel/qtestsupport_widgets.h index ca1406b0b20..2b37a9e8583 100644 --- a/src/widgets/kernel/qtestsupport_widgets.h +++ b/src/widgets/kernel/qtestsupport_widgets.h @@ -40,7 +40,7 @@ #ifndef QTESTSUPPORT_WIDGETS_H #define QTESTSUPPORT_WIDGETS_H -#include "qtwidgetsglobal.h" +#include QT_BEGIN_NAMESPACE From 105e662221cc90d5002e06c97febf50c5c601336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 2 Jan 2020 13:21:58 +0100 Subject: [PATCH 08/22] macOS: Handle missing color space information in IOSurface backingstore Fixes: QTBUG-80972 Change-Id: Iab3f1a9cf03251340e5f32bcc73103428e93282d Reviewed-by: Timur Pocheptsov --- .../platforms/cocoa/qiosurfacegraphicsbuffer.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm index 285e316d4af..fc187e0f515 100644 --- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm @@ -89,9 +89,16 @@ QIOSurfaceGraphicsBuffer::~QIOSurfaceGraphicsBuffer() void QIOSurfaceGraphicsBuffer::setColorSpace(QCFType colorSpace) { - Q_ASSERT(colorSpace); - IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"), - QCFType(CGColorSpaceCopyPropertyList(colorSpace))); + static const auto kIOSurfaceColorSpace = CFSTR("IOSurfaceColorSpace"); + + qCDebug(lcQpaIOSurface) << "Tagging" << this << "with color space" << colorSpace; + + if (colorSpace) { + IOSurfaceSetValue(m_surface, kIOSurfaceColorSpace, + QCFType(CGColorSpaceCopyPropertyList(colorSpace))); + } else { + IOSurfaceRemoveValue(m_surface, kIOSurfaceColorSpace); + } } const uchar *QIOSurfaceGraphicsBuffer::data() const From dcef0b96eef04c4e17c2e51ea71aea1f78625864 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 19 Dec 2019 21:59:09 +0100 Subject: [PATCH 09/22] Fix CVE-2019-19242 in SQLite Task-number: QTBUG-80903 Change-Id: I78a72a574da5cf3503950afe47146ae6424f00c6 Reviewed-by: Christian Ehrlicher Reviewed-by: Volker Hilsheimer --- .../0002-Fix-CVE-2019-19242-in-SQLite.patch | 31 +++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 7 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/3rdparty/sqlite/patches/0002-Fix-CVE-2019-19242-in-SQLite.patch diff --git a/src/3rdparty/sqlite/patches/0002-Fix-CVE-2019-19242-in-SQLite.patch b/src/3rdparty/sqlite/patches/0002-Fix-CVE-2019-19242-in-SQLite.patch new file mode 100644 index 00000000000..92739192e4f --- /dev/null +++ b/src/3rdparty/sqlite/patches/0002-Fix-CVE-2019-19242-in-SQLite.patch @@ -0,0 +1,31 @@ +From 7905740b8e79479298e83d8e559fc49b46cf980e Mon Sep 17 00:00:00 2001 +From: Andy Shaw +Date: Thu, 19 Dec 2019 21:59:09 +0100 +Subject: [PATCH] Fix CVE-2019-19242 in SQLite + +Change-Id: I78a72a574da5cf3503950afe47146ae6424f00c6 +--- + src/3rdparty/sqlite/sqlite3.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index bd647ca1c2..d3e0c065b6 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -101055,7 +101055,12 @@ expr_code_doover: + ** constant. + */ + int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); +- int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); ++ int aff; ++ if( pExpr->y.pTab ){ ++ aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); ++ }else{ ++ aff = pExpr->affExpr; ++ } + if( aff>SQLITE_AFF_BLOB ){ + static const char zAff[] = "B\000C\000D\000E"; + assert( SQLITE_AFF_BLOB=='A' ); +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index bd647ca1c27..d3e0c065b69 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -101055,7 +101055,12 @@ expr_code_doover: ** constant. */ int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); - int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); + int aff; + if( pExpr->y.pTab ){ + aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); + }else{ + aff = pExpr->affExpr; + } if( aff>SQLITE_AFF_BLOB ){ static const char zAff[] = "B\000C\000D\000E"; assert( SQLITE_AFF_BLOB=='A' ); From a75d238b3194ae4973be7f6ce0508a526d4aa49e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 19 Dec 2019 22:31:15 +0100 Subject: [PATCH 10/22] Fix CVE-2019-19603 in SQLite This includes the patch needed to fix this CVE and a supporting one to include a new function added that it depends on. Task-number: QTBUG-80903 Change-Id: Ic7639d50c89a3ee7d45426588c3ab0efd0eebb72 Reviewed-by: Christian Ehrlicher Reviewed-by: Volker Hilsheimer --- .../0003-Fix-CVE-2019-19603-in-SQLite.patch | 95 +++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 32 +++++-- 2 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 src/3rdparty/sqlite/patches/0003-Fix-CVE-2019-19603-in-SQLite.patch diff --git a/src/3rdparty/sqlite/patches/0003-Fix-CVE-2019-19603-in-SQLite.patch b/src/3rdparty/sqlite/patches/0003-Fix-CVE-2019-19603-in-SQLite.patch new file mode 100644 index 00000000000..1b8deaa4a11 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0003-Fix-CVE-2019-19603-in-SQLite.patch @@ -0,0 +1,95 @@ +From 11a2f4647b67494fb731a6fd793f1b28074631d3 Mon Sep 17 00:00:00 2001 +From: Andy Shaw +Date: Thu, 19 Dec 2019 22:31:15 +0100 +Subject: [PATCH] Fix CVE-2019-19603 in SQLite + +This includes the patch needed to fix this CVE and a supporting one to +include a new function added that it depends on. + +Task-number: QTBUG-80903 +Change-Id: Ic7639d50c89a3ee7d45426588c3ab0efd0eebb72 +--- + src/3rdparty/sqlite/sqlite3.c | 32 ++++++++++++++++++++++++++------ + 1 file changed, 26 insertions(+), 6 deletions(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index d3e0c065b6..a430554db7 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -19519,6 +19519,12 @@ SQLITE_PRIVATE Module *sqlite3VtabCreateModule( + ); + # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) + #endif ++SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db); ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName); ++#else ++# define sqlite3ShadowTableName(A,B) 0 ++#endif + SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); + SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); + SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*); +@@ -108483,6 +108489,22 @@ SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3 *db){ + return (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==SQLITE_WriteSchema; + } + ++/* ++ ** Return TRUE if shadow tables should be read-only in the current ++ ** context. ++ */ ++int sqlite3ReadOnlyShadowTables(sqlite3 *db){ ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++ if( (db->flags & SQLITE_Defensive)!=0 ++ && db->pVtabCtx==0 ++ && db->nVdbeExec==0 ++ ){ ++ return 1; ++ } ++#endif ++ return 0; ++} ++ + /* + ** This routine is used to check if the UTF-8 string zName is a legal + ** unqualified name for a new schema object (table, index, view or +@@ -108516,8 +108538,8 @@ SQLITE_PRIVATE int sqlite3CheckObjectName( + } + } + }else{ +- if( pParse->nested==0 +- && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ++ if( (pParse->nested==0 && 0==sqlite3StrNICmp(zName, "sqlite_", 7)) ++ || (sqlite3ReadOnlyShadowTables(db) && sqlite3ShadowTableName(db, zName)) + ){ + sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", + zName); +@@ -109662,7 +109684,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ + ** zName is temporarily modified while this routine is running, but is + ** restored to its original value prior to this routine returning. + */ +-static int isShadowTableName(sqlite3 *db, char *zName){ ++int sqlite3ShadowTableName(sqlite3 *db, const char *zName){ + char *zTail; /* Pointer to the last "_" in zName */ + Table *pTab; /* Table that zName is a shadow of */ + Module *pMod; /* Module for the virtual table */ +@@ -109680,8 +109702,6 @@ static int isShadowTableName(sqlite3 *db, char *zName){ + if( pMod->pModule->xShadowName==0 ) return 0; + return pMod->pModule->xShadowName(zTail+1); + } +-#else +-# define isShadowTableName(x,y) 0 + #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ + + /* +@@ -109723,7 +109743,7 @@ SQLITE_PRIVATE void sqlite3EndTable( + p = pParse->pNewTable; + if( p==0 ) return; + +- if( pSelect==0 && isShadowTableName(db, p->zName) ){ ++ if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){ + p->tabFlags |= TF_Shadow; + } + +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index d3e0c065b69..a430554db7d 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -19519,6 +19519,12 @@ SQLITE_PRIVATE Module *sqlite3VtabCreateModule( ); # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) #endif +SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db); +#ifndef SQLITE_OMIT_VIRTUALTABLE +SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName); +#else +# define sqlite3ShadowTableName(A,B) 0 +#endif SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*); @@ -108483,6 +108489,22 @@ SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3 *db){ return (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==SQLITE_WriteSchema; } +/* + ** Return TRUE if shadow tables should be read-only in the current + ** context. + */ +int sqlite3ReadOnlyShadowTables(sqlite3 *db){ +#ifndef SQLITE_OMIT_VIRTUALTABLE + if( (db->flags & SQLITE_Defensive)!=0 + && db->pVtabCtx==0 + && db->nVdbeExec==0 + ){ + return 1; + } +#endif + return 0; +} + /* ** This routine is used to check if the UTF-8 string zName is a legal ** unqualified name for a new schema object (table, index, view or @@ -108516,8 +108538,8 @@ SQLITE_PRIVATE int sqlite3CheckObjectName( } } }else{ - if( pParse->nested==0 - && 0==sqlite3StrNICmp(zName, "sqlite_", 7) + if( (pParse->nested==0 && 0==sqlite3StrNICmp(zName, "sqlite_", 7)) + || (sqlite3ReadOnlyShadowTables(db) && sqlite3ShadowTableName(db, zName)) ){ sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName); @@ -109662,7 +109684,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ ** zName is temporarily modified while this routine is running, but is ** restored to its original value prior to this routine returning. */ -static int isShadowTableName(sqlite3 *db, char *zName){ +int sqlite3ShadowTableName(sqlite3 *db, const char *zName){ char *zTail; /* Pointer to the last "_" in zName */ Table *pTab; /* Table that zName is a shadow of */ Module *pMod; /* Module for the virtual table */ @@ -109680,8 +109702,6 @@ static int isShadowTableName(sqlite3 *db, char *zName){ if( pMod->pModule->xShadowName==0 ) return 0; return pMod->pModule->xShadowName(zTail+1); } -#else -# define isShadowTableName(x,y) 0 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ /* @@ -109723,7 +109743,7 @@ SQLITE_PRIVATE void sqlite3EndTable( p = pParse->pNewTable; if( p==0 ) return; - if( pSelect==0 && isShadowTableName(db, p->zName) ){ + if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){ p->tabFlags |= TF_Shadow; } From 3b697f496303bd005ae9d1d2c974efeed259d8a3 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 2 Jan 2020 09:07:08 +0100 Subject: [PATCH 11/22] Fix CVE-2019-19646 in SQLite Task-number: QTBUG-81020 Change-Id: I7176db20d4a44b1fb443a6108675f719e9643343 Reviewed-by: Volker Hilsheimer --- .../0004-Fix-CVE-2019-19646-in-SQLite.patch | 29 +++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 4 ++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/3rdparty/sqlite/patches/0004-Fix-CVE-2019-19646-in-SQLite.patch diff --git a/src/3rdparty/sqlite/patches/0004-Fix-CVE-2019-19646-in-SQLite.patch b/src/3rdparty/sqlite/patches/0004-Fix-CVE-2019-19646-in-SQLite.patch new file mode 100644 index 00000000000..db436ab4f69 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0004-Fix-CVE-2019-19646-in-SQLite.patch @@ -0,0 +1,29 @@ +From a83bbce4d6f31d93ea4d2a681aa52c148f148e26 Mon Sep 17 00:00:00 2001 +From: Andy Shaw +Date: Thu, 2 Jan 2020 09:07:08 +0100 +Subject: [PATCH] Fix CVE-2019-19646 in SQLite + +Task-number: QTBUG-81020 +Change-Id: I7176db20d4a44b1fb443a6108675f719e9643343 +--- + src/3rdparty/sqlite/sqlite3.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index 57e61b8313..980a149b1a 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -123765,7 +123765,9 @@ SQLITE_PRIVATE void sqlite3Pragma( + if( j==pTab->iPKey ) continue; + if( pTab->aCol[j].notNull==0 ) continue; + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); +- sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); ++ if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ ++ sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); ++ } + jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); + zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, + pTab->aCol[j].zName); +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index a430554db7d..712a103ef6d 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -123776,7 +123776,9 @@ SQLITE_PRIVATE void sqlite3Pragma( if( j==pTab->iPKey ) continue; if( pTab->aCol[j].notNull==0 ) continue; sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); - sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); + if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ + sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); + } jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, pTab->aCol[j].zName); From 1e89c132e1280276e1d3a82ec3464afec8c14c3a Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 2 Jan 2020 08:47:23 +0100 Subject: [PATCH 12/22] Fix CVE-2019-19645 in SQLite Task-number: QTBUG-81020 Change-Id: I58b1dd9e7a90ba998c3af7f25a4627d8bdd70970 Reviewed-by: Volker Hilsheimer --- .../0005-Fix-CVE-2019-19645-in-SQLite.patch | 83 +++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 11 ++- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/3rdparty/sqlite/patches/0005-Fix-CVE-2019-19645-in-SQLite.patch diff --git a/src/3rdparty/sqlite/patches/0005-Fix-CVE-2019-19645-in-SQLite.patch b/src/3rdparty/sqlite/patches/0005-Fix-CVE-2019-19645-in-SQLite.patch new file mode 100644 index 00000000000..e92c5668816 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0005-Fix-CVE-2019-19645-in-SQLite.patch @@ -0,0 +1,83 @@ +From 78c972eec5bab03a408b8ba1373572bcfe2db630 Mon Sep 17 00:00:00 2001 +From: Andy Shaw +Date: Thu, 2 Jan 2020 08:47:23 +0100 +Subject: [PATCH] Fix CVE-2019-19645 in SQLite + +Task-number: QTBUG-81020 +Change-Id: I58b1dd9e7a90ba998c3af7f25a4627d8bdd70970 +--- + src/3rdparty/sqlite/sqlite3.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index d3e0c065b6..57e61b8313 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -17946,6 +17946,7 @@ struct Select { + #define SF_IncludeHidden 0x20000 /* Include hidden columns in output */ + #define SF_ComplexResult 0x40000 /* Result contains subquery or function */ + #define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */ ++#define SF_View 0x0200000 /* SELECT statement is a view */ + + /* + ** The results of a SELECT can be distributed in several ways, as defined +@@ -103920,6 +103921,7 @@ static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ + static int renameUnmapSelectCb(Walker *pWalker, Select *p){ + Parse *pParse = pWalker->pParse; + int i; ++ if( p->selFlags & SF_View ) return WRC_Prune; + if( ALWAYS(p->pEList) ){ + ExprList *pList = p->pEList; + for(i=0; inExpr; i++){ +@@ -104024,6 +104026,7 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ + ** descend into sub-select statements. + */ + static int renameColumnSelectCb(Walker *pWalker, Select *p){ ++ if( p->selFlags & SF_View ) return WRC_Prune; + renameWalkWith(pWalker, p); + return WRC_Continue; + } +@@ -104489,8 +104492,9 @@ static void renameColumnFunc( + if( sParse.pNewTable ){ + Select *pSelect = sParse.pNewTable->pSelect; + if( pSelect ){ ++ pSelect->selFlags &= ~SF_View; + sParse.rc = SQLITE_OK; +- sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0); ++ sqlite3SelectPrep(&sParse, pSelect, 0); + rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); + if( rc==SQLITE_OK ){ + sqlite3WalkSelect(&sWalker, pSelect); +@@ -104602,6 +104606,7 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ + int i; + RenameCtx *p = pWalker->u.pRename; + SrcList *pSrc = pSelect->pSrc; ++ if( pSelect->selFlags & SF_View ) return WRC_Prune; + if( pSrc==0 ){ + assert( pWalker->pParse->db->mallocFailed ); + return WRC_Abort; +@@ -104681,10 +104686,13 @@ static void renameTableFunc( + + if( pTab->pSelect ){ + if( isLegacy==0 ){ ++ Select *pSelect = pTab->pSelect; + NameContext sNC; + memset(&sNC, 0, sizeof(sNC)); + sNC.pParse = &sParse; + ++ assert( pSelect->selFlags & SF_View ); ++ pSelect->selFlags &= ~SF_View; + sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); + if( sParse.nErr ) rc = sParse.rc; + sqlite3WalkSelect(&sWalker, pTab->pSelect); +@@ -109994,6 +110002,7 @@ SQLITE_PRIVATE void sqlite3CreateView( + ** allocated rather than point to the input string - which means that + ** they will persist after the current sqlite3_exec() call returns. + */ ++ pSelect->selFlags |= SF_View; + if( IN_RENAME_OBJECT ){ + p->pSelect = pSelect; + pSelect = 0; +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index 712a103ef6d..d5b43857ad4 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -17946,6 +17946,7 @@ struct Select { #define SF_IncludeHidden 0x20000 /* Include hidden columns in output */ #define SF_ComplexResult 0x40000 /* Result contains subquery or function */ #define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */ +#define SF_View 0x0200000 /* SELECT statement is a view */ /* ** The results of a SELECT can be distributed in several ways, as defined @@ -103926,6 +103927,7 @@ static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ Parse *pParse = pWalker->pParse; int i; + if( p->selFlags & SF_View ) return WRC_Prune; if( ALWAYS(p->pEList) ){ ExprList *pList = p->pEList; for(i=0; inExpr; i++){ @@ -104030,6 +104032,7 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ ** descend into sub-select statements. */ static int renameColumnSelectCb(Walker *pWalker, Select *p){ + if( p->selFlags & SF_View ) return WRC_Prune; renameWalkWith(pWalker, p); return WRC_Continue; } @@ -104495,8 +104498,9 @@ static void renameColumnFunc( if( sParse.pNewTable ){ Select *pSelect = sParse.pNewTable->pSelect; if( pSelect ){ + pSelect->selFlags &= ~SF_View; sParse.rc = SQLITE_OK; - sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0); + sqlite3SelectPrep(&sParse, pSelect, 0); rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); if( rc==SQLITE_OK ){ sqlite3WalkSelect(&sWalker, pSelect); @@ -104608,6 +104612,7 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ int i; RenameCtx *p = pWalker->u.pRename; SrcList *pSrc = pSelect->pSrc; + if( pSelect->selFlags & SF_View ) return WRC_Prune; if( pSrc==0 ){ assert( pWalker->pParse->db->mallocFailed ); return WRC_Abort; @@ -104687,10 +104692,13 @@ static void renameTableFunc( if( pTab->pSelect ){ if( isLegacy==0 ){ + Select *pSelect = pTab->pSelect; NameContext sNC; memset(&sNC, 0, sizeof(sNC)); sNC.pParse = &sParse; + assert( pSelect->selFlags & SF_View ); + pSelect->selFlags &= ~SF_View; sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); if( sParse.nErr ) rc = sParse.rc; sqlite3WalkSelect(&sWalker, pTab->pSelect); @@ -110014,6 +110022,7 @@ SQLITE_PRIVATE void sqlite3CreateView( ** allocated rather than point to the input string - which means that ** they will persist after the current sqlite3_exec() call returns. */ + pSelect->selFlags |= SF_View; if( IN_RENAME_OBJECT ){ p->pSelect = pSelect; pSelect = 0; From 8669b8e60fc6a46baaeeea264a1ed3008dd52ea2 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 11 Dec 2019 10:54:57 +0100 Subject: [PATCH 13/22] QVariant: Prefer direct conversion to QVariant{List,Map,Hash} If a type has both a converter to QVariantList and to QSequentialIterableImpl registered, we would have chosen the QSequentialIterableImpl version. In the case of types like QJSValue, this is more costly. With this change we therefore uses the direct conversion if it has been registered. The same applies to QAssociativeIterableImpl and QVariantHash/QVariantMap. Change-Id: I9c0b5068efe4bfbc5e0598a200e6db59201e9974 Reviewed-by: Ulf Hermann Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qvariant.h | 11 +++-- .../corelib/kernel/qvariant/tst_qvariant.cpp | 44 +++++++++++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index a4957472ec1..c95882d48f7 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -801,7 +801,8 @@ namespace QtPrivate { static QVariantList invoke(const QVariant &v) { const int typeId = v.userType(); - if (typeId == qMetaTypeId() || typeId == qMetaTypeId() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { + if (typeId == qMetaTypeId() || typeId == qMetaTypeId() || + (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId()) && !QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId()))) { QSequentialIterable iter = QVariantValueHelperInterface::invoke(v); QVariantList l; l.reserve(iter.size()); @@ -818,7 +819,7 @@ namespace QtPrivate { static QVariantHash invoke(const QVariant &v) { const int typeId = v.userType(); - if (typeId == qMetaTypeId() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { + if (typeId == qMetaTypeId() || ((QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) && !QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId()))) { QAssociativeIterable iter = QVariantValueHelperInterface::invoke(v); QVariantHash l; l.reserve(iter.size()); @@ -835,7 +836,7 @@ namespace QtPrivate { static QVariantMap invoke(const QVariant &v) { const int typeId = v.userType(); - if (typeId == qMetaTypeId() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { + if (typeId == qMetaTypeId() || (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId()) && !QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId()))) { QAssociativeIterable iter = QVariantValueHelperInterface::invoke(v); QVariantMap l; for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it) @@ -851,10 +852,8 @@ namespace QtPrivate { static QPair invoke(const QVariant &v) { const int typeId = v.userType(); - if (typeId == qMetaTypeId >()) - return QVariantValueHelper >::invoke(v); - if (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId())) { + if (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId()) && !(typeId == qMetaTypeId >())) { QtMetaTypePrivate::QPairVariantInterfaceImpl pi = v.value(); const QtMetaTypePrivate::VariantData d1 = pi.first(); diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index e7198711286..45eb61f6e4f 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -282,6 +282,8 @@ private slots: void fromStdVariant(); void qt4UuidDataStream(); + void preferDirectConversionOverInterfaces(); + private: void dataStream_data(QDataStream::Version version); void loadQVariantFromDataStream(QDataStream::Version version); @@ -5140,5 +5142,47 @@ void tst_QVariant::qt4UuidDataStream() QCOMPARE(result.value(), source); } +void tst_QVariant::preferDirectConversionOverInterfaces() +{ + using namespace QtMetaTypePrivate; + bool calledCorrectConverter = false; + QMetaType::registerConverter([](const MyType &) { + return QSequentialIterableImpl {}; + }); + QMetaType::registerConverter([&calledCorrectConverter](const MyType &) { + calledCorrectConverter = true; + return QVariantList {}; + }); + QMetaType::registerConverter([](const MyType &) { + return QAssociativeIterableImpl {}; + }); + QMetaType::registerConverter([&calledCorrectConverter](const MyType &) { + calledCorrectConverter = true; + return QVariantHash {}; + }); + QMetaType::registerConverter([&calledCorrectConverter](const MyType &) { + calledCorrectConverter = true; + return QVariantMap {}; + }); + auto holder = QVariant::fromValue(MyType {}); + + QVERIFY(holder.canConvert()); + QVERIFY(holder.canConvert()); + QVERIFY(holder.canConvert()); + QVERIFY(holder.canConvert()); + QVERIFY(holder.canConvert()); + + holder.value(); + QVERIFY(calledCorrectConverter); + calledCorrectConverter = false; + + holder.value(); + QVERIFY(calledCorrectConverter); + calledCorrectConverter = false; + + holder.value(); + QVERIFY(calledCorrectConverter); +} + QTEST_MAIN(tst_QVariant) #include "tst_qvariant.moc" From 7c0341daeef9c975b0e736b9d8a52b9649c6a06c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 3 Jan 2020 12:51:20 +0100 Subject: [PATCH 14/22] uic: Fix empty strings for Python Introduce a constant in the language namespace. Fixes: PYSIDE-1174 Change-Id: Ic3e58580b20c1d9a6ddf97f20709a3046d4b6f0c Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 12 +++++------- src/tools/uic/shared/language.cpp | 3 +++ src/tools/uic/shared/language.h | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 570a61a1f10..4fbf01262b6 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -731,7 +731,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) icon = QLatin1String(", ") + iconCall(picon); // Side effect: Writes icon definition m_output << m_indent << parentWidget << language::derefPointer << "addTab(" - << varName << icon << ", " << "QString())" << language::eol; + << varName << icon << ", " << language::emptyString << ')' << language::eol; autoTrOutput(ptitleString, pageDefaultString) << m_indent << parentWidget << language::derefPointer << "setTabText(" << parentWidget @@ -2086,7 +2086,7 @@ void WriteInitialization::initializeComboBox(DomWidget *w) m_output << iconValue << ", "; if (needsTranslation(text->elementString())) { - m_output << "QString())" << language::eol; + m_output << language::emptyString << ')' << language::eol; m_refreshOut << m_indent << varName << language::derefPointer << "setItemText(" << i << ", " << trCall(text->elementString()) << ')' << language::eol; @@ -2288,7 +2288,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) if (str && str->text().isEmpty()) { m_output << m_indent << varName << language::derefPointer << "headerItem()" << language::derefPointer << "setText(" - << i << ", QString())" << language::eol; + << i << ", " << language::emptyString << ')' << language::eol; } } } @@ -2451,10 +2451,8 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) QString WriteInitialization::trCall(const QString &str, const QString &commentHint, const QString &id) const { - if (str.isEmpty()) { - return language::language() == Language::Cpp - ? QLatin1String("QString()") : QLatin1String("\"\""); - } + if (str.isEmpty()) + return language::emptyString; QString result; QTextStream ts(&result); diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp index 235a8ed2fca..987d51e30ca 100644 --- a/src/tools/uic/shared/language.cpp +++ b/src/tools/uic/shared/language.cpp @@ -49,6 +49,7 @@ void setLanguage(Language l) qualifier = QLatin1String("::"); self = QLatin1String(""); // for testing: change to "this->"; eol = QLatin1String(";\n"); + emptyString = QLatin1String("QString()"); encoding = Encoding::Utf8; break; case Language::Python: @@ -59,6 +60,7 @@ void setLanguage(Language l) qualifier = QLatin1String("."); self = QLatin1String("self."); eol = QLatin1String("\n"); + emptyString = QLatin1String("\"\""); encoding = Encoding::Unicode; break; } @@ -71,6 +73,7 @@ QString qtQualifier; QString qualifier; QString self; QString eol; +QString emptyString; QString cppQualifier = QLatin1String("::"); QString cppTrue = QLatin1String("true"); diff --git a/src/tools/uic/shared/language.h b/src/tools/uic/shared/language.h index fc8af9715bb..7b019ec8fc4 100644 --- a/src/tools/uic/shared/language.h +++ b/src/tools/uic/shared/language.h @@ -49,6 +49,7 @@ extern QString qtQualifier; extern QString qualifier; extern QString self; extern QString eol; +extern QString emptyString; extern QString cppQualifier; extern QString cppTrue; From 77f1d0bfa542e166deaa196b3b3b854d33a3a1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 3 Jan 2020 13:22:06 +0100 Subject: [PATCH 15/22] macOS: Skip uninitialized buffers in IOSurface backingstore Task-number: QTBUG-80972 Change-Id: Ifb8eb84d6b802556ccd52ac129a91e142e265a81 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 8a815a7665e..2e15d115645 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -617,8 +617,10 @@ QImage QCALayerBackingStore::toImage() const void QCALayerBackingStore::backingPropertiesChanged() { qCDebug(lcQpaBackingStore) << "Updating color space of existing buffers"; - for (auto &buffer : m_buffers) - buffer->setColorSpace(colorSpace()); + for (auto &buffer : m_buffers) { + if (buffer) + buffer->setColorSpace(colorSpace()); + } } QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const From 8b0b2057d060c9f33cfeb0ea38a08ace22079f93 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 3 Jan 2020 13:08:52 +0100 Subject: [PATCH 16/22] uic: Add colon missing for "if()" constructs in Python Task-number: PYSIDE-1169 Change-Id: I63c5305b0ddad1c4fcd585b65c3c78c05b40bac1 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/cpp/cppwriteinitialization.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 4fbf01262b6..5dbe10082c7 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -2372,9 +2372,11 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) const auto &columns = w->elementColumn(); if (!columns.empty()) { - m_output << m_indent << "if (" << varName << language::derefPointer << "columnCount() < " - << columns.size() << ")\n" - << m_dindent << varName << language::derefPointer << "setColumnCount(" + m_output << m_indent << "if (" << varName << language::derefPointer + << "columnCount() < " << columns.size() << ')'; + if (language::language() == Language::Python) + m_output << ':'; + m_output << '\n' << m_dindent << varName << language::derefPointer << "setColumnCount(" << columns.size() << ')' << language::eol; } @@ -2400,8 +2402,11 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) const auto &rows = w->elementRow(); if (!rows.isEmpty()) { - m_output << m_indent << "if (" << varName << language::derefPointer << "rowCount() < " << rows.size() << ")\n" - << m_dindent << varName << language::derefPointer << "setRowCount(" + m_output << m_indent << "if (" << varName << language::derefPointer + << "rowCount() < " << rows.size() << ')'; + if (language::language() == Language::Python) + m_output << ':'; + m_output << '\n' << m_dindent << varName << language::derefPointer << "setRowCount(" << rows.size() << ')' << language::eol; } From 01f0df1cf559991e4b7fbee1cb14b068fb6895c8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 3 Jan 2020 15:02:44 +0100 Subject: [PATCH 17/22] uic: Add handling of resources imports for Python The Python-bases pyside2-uic would write an import for each resource file encountered, adding a "_rc" suffix. Add this handling. Task-number: PYSIDE-1171 Task-number: PYSIDE-1170 Change-Id: I870d61ca7262c0684de5359a5f990d23a4171032 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/main.cpp | 5 ++++ src/tools/uic/option.h | 2 ++ src/tools/uic/python/pythonwriteimports.cpp | 32 +++++++++++++++++++++ src/tools/uic/python/pythonwriteimports.h | 1 + 4 files changed, 40 insertions(+) diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index 9cf22d502d1..d6c63de869c 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -108,6 +108,10 @@ int runUic(int argc, char *argv[]) idBasedOption.setDescription(QStringLiteral("Use id based function for i18n")); parser.addOption(idBasedOption); + QCommandLineOption fromImportsOption(QStringLiteral("from-imports")); + fromImportsOption.setDescription(QStringLiteral("Python: generate imports relative to '.'")); + parser.addOption(fromImportsOption); + parser.addPositionalArgument(QStringLiteral("[uifile]"), QStringLiteral("Input file (*.ui), otherwise stdin.")); parser.process(app); @@ -118,6 +122,7 @@ int runUic(int argc, char *argv[]) driver.option().headerProtection = !parser.isSet(noProtOption); driver.option().implicitIncludes = !parser.isSet(noImplicitIncludesOption); driver.option().idBased = parser.isSet(idBasedOption); + driver.option().fromImports = parser.isSet(fromImportsOption); driver.option().postfix = parser.value(postfixOption); driver.option().translateFunction = parser.value(translateOption); driver.option().includeFile = parser.value(includeOption); diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h index 4fc442e94ab..8e882079c9f 100644 --- a/src/tools/uic/option.h +++ b/src/tools/uic/option.h @@ -45,6 +45,7 @@ struct Option unsigned int limitXPM_LineLength : 1; unsigned int implicitIncludes: 1; unsigned int idBased: 1; + unsigned int fromImports: 1; QString inputFile; QString outputFile; @@ -65,6 +66,7 @@ struct Option limitXPM_LineLength(0), implicitIncludes(1), idBased(0), + fromImports(0), prefix(QLatin1String("Ui_")) { indent.fill(QLatin1Char(' '), 4); } diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index 303615f77b4..be556966834 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -29,6 +29,7 @@ #include "pythonwriteimports.h" #include +#include #include #include @@ -46,6 +47,20 @@ from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont, from PySide2.QtWidgets import * )I"; +// Change the name of a qrc file "dir/foo.qrc" file to the Python +// module name "foo_rc" according to project conventions. +static QString pythonResource(QString resource) +{ + const int lastSlash = resource.lastIndexOf(QLatin1Char('/')); + if (lastSlash != -1) + resource.remove(0, lastSlash + 1); + if (resource.endsWith(QLatin1String(".qrc"))) { + resource.chop(4); + resource.append(QLatin1String("_rc")); + } + return resource; +} + namespace Python { WriteImports::WriteImports(Uic *uic) : m_uic(uic) @@ -60,6 +75,23 @@ void WriteImports::acceptUI(DomUI *node) TreeWalker::acceptCustomWidgets(customWidgets); output << '\n'; } + + if (auto resources = node->elementResources()) { + const auto includes = resources->elementInclude(); + for (auto include : includes) { + if (include->hasAttributeLocation()) + writeImport(pythonResource(include->attributeLocation())); + } + output << '\n'; + } +} + +void WriteImports::writeImport(const QString &module) +{ + + if (m_uic->option().fromImports) + m_uic->output() << "from . "; + m_uic->output() << "import " << module << '\n'; } QString WriteImports::qtModuleOf(const DomCustomWidget *node) const diff --git a/src/tools/uic/python/pythonwriteimports.h b/src/tools/uic/python/pythonwriteimports.h index 427cbb48b11..54624539624 100644 --- a/src/tools/uic/python/pythonwriteimports.h +++ b/src/tools/uic/python/pythonwriteimports.h @@ -46,6 +46,7 @@ public: void acceptCustomWidget(DomCustomWidget *node) override; private: + void writeImport(const QString &module); QString qtModuleOf(const DomCustomWidget *node) const; Uic *const m_uic; From 02ddf08db808304363454a9ef7cba9b41af3f112 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 2 Jan 2020 15:03:16 +0100 Subject: [PATCH 18/22] Note that zh's "Chinese" is in fact Mandarin Task-number: QTBUG-63457 Change-Id: If1e36c3b2230d8c45311add26c976843eb5b3d36 Reviewed-by: Liang Qi Reviewed-by: Paul Wicking --- src/corelib/text/qlocale.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc index dbcd71f1a01..592f9d0785a 100644 --- a/src/corelib/text/qlocale.qdoc +++ b/src/corelib/text/qlocale.qdoc @@ -174,7 +174,7 @@ \value Chewa Obsolete, please use Nyanja \value Chickasaw Since Qt 5.14 \value Chiga - \value Chinese + \value Chinese (Mandarin) \value Church \value Chuvash \value ClassicalMandaic Since Qt 5.1 From c62333424839b3229706a6ebb64ba271689a3b8c Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 22 Dec 2019 17:53:20 +0100 Subject: [PATCH 19/22] QPlainTextEdit: make sure firstVisibleBlock() is valid Under some circumstances it's possible that firstVisibleBlock() returns an invalid block within QPlainTextEditPrivate::_q_textChanged() which results in a nullptr access later on. Therefore add a check similar to other places and test the validity of the returned block before accessing it. Fixes: QTBUG-80929 Change-Id: I1fd4643b10b842acfe1c356048379f0ba225dddf Reviewed-by: Friedemann Kleint Reviewed-by: Timur Pocheptsov --- src/widgets/widgets/qplaintextedit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index e8da720b581..7e9e0fabe97 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -839,7 +839,8 @@ void QPlainTextEditPrivate::_q_textChanged() placeholderVisible = !placeholderText.isEmpty() && q->document()->isEmpty() - && q->firstVisibleBlock().layout()->preeditAreaText().isEmpty(); + && (!q->firstVisibleBlock().isValid() || + q->firstVisibleBlock().layout()->preeditAreaText().isEmpty()); if (placeholderCurrentyVisible != placeholderVisible) viewport->update(); From 9b647bf5acf6a5bd4bf87646feed7b19960fc274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= Date: Fri, 3 Jan 2020 16:26:37 +0100 Subject: [PATCH 20/22] uic: setWeight replace semi-colon by language::eol Change-Id: I87f9c2896cfd6f83f683cf731e4a62aef627d69c Reviewed-by: Friedemann Kleint --- src/tools/uic/cpp/cppwriteinitialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 5dbe10082c7..1444c681c0b 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1612,7 +1612,7 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) } if (f->hasElementWeight() && f->elementWeight() > 0) { m_output << m_indent << fontName << ".setWeight(" - << f->elementWeight() << ");" << Qt::endl; + << f->elementWeight() << ")" << language::eol; } if (f->hasElementStrikeOut()) { m_output << m_indent << fontName << ".setStrikeOut(" From 56674dca36f113369d3ed598192a392ceb723605 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 25 Dec 2019 19:37:53 +0100 Subject: [PATCH 21/22] QSS/QComboBox: set correct palette when drawing SC_ComboBoxArrow When the dropdown button of a combobox is drawn with QStyleSheetStyle, not only the background color is used for drawing but also QPalette::Light/Dark/Shadow. Since the palette was not properly set up in some cases, the shaded frame around the button was drawn with the default colors instead the ones derived from the given background. Therefore we have to properly set up the palette before drawing the drop down button by calling QRenderRule::configurePalette() Fixes: QTBUG-80950 Change-Id: Ibf98fa28612b5c7527ef9dd6ae06c417315f2632 Reviewed-by: Friedemann Kleint Reviewed-by: Timur Pocheptsov --- src/widgets/styles/qstylesheetstyle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 98c85684ae4..c694e9db97b 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3019,6 +3019,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC r = positionRect(w, subRule, subRule2, PseudoElement_ComboBoxArrow, r, opt->direction); subRule2.drawRule(p, r); } else { + rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button); cmbOpt.subControls = QStyle::SC_ComboBoxArrow; QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w); } From 2c3eaa7b87219d24facfe81a5b22cb218324f1ae Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 27 Dec 2019 18:01:49 +0100 Subject: [PATCH 22/22] Fix semi-transparent text on Linux with subpixel anti-aliasing The newly optimized rgbBlend function wasn't updated to handle SourceOver compositing when dealing with semi-transparent text color. The extra composition isn't SIMD optimized but short-cut for all opaque colors. Fixes: QTBUG-80982 Change-Id: I88c1e60fd5e80a8c7f9e6b0e7de8248c7c00ebc2 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qdrawhelper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index e8d129d0470..f8d5914f374 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6048,7 +6048,11 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba // Give up and do a naive gray alphablend. Needed to deal with ARGB32 and invalid ARGB32_premultiplied, see QTBUG-60571 blend_pixel(*dst, src, qRgbAvg(coverage)); } else if (!colorProfile) { - *dst = rgbBlend(*dst, src, coverage); + // First do naive blend with text-color + QRgb s = *dst; + blend_pixel(s, src); + // Then a naive blend with glyph shape + *dst = rgbBlend(*dst, s, coverage); } else if (srcLinear.isOpaque()) { rgbBlendPixel(dst, coverage, srcLinear, colorProfile); } else {