From 8141d64527c5e7a1723e2caeeebb0cde4e591207 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 12 Mar 2016 11:34:48 +0100 Subject: qgrayraster: fix UBs involving << with a negative LHS Left-shifts of negative values are undefined in C++. In particular, they don't behave arithmetically. Reported by UBSan: qgrayraster.c:510:19: runtime error: left shift of negative value -1/-42 qgrayraster.c:537:26: runtime error: left shift of negative value -1/-4/-128 qgrayraster.c:538:26: runtime error: left shift of negative value -1/-4/-128 qgrayraster.c:641:28: runtime error: left shift of negative value -1/-42 qgrayraster.c:676:44: runtime error: left shift of negative value -1/-4/-5/-14/-129 qgrayraster.c:807:19: runtime error: left shift of negative value -1/-42 qgrayraster.c:1101:9: runtime error: left shift of negative value -32/-46/-224/-8160 qgrayraster.c:1102:9: runtime error: left shift of negative value -32/-2626 qgrayraster.c:1454:36: runtime error: left shift of negative value -32/-96/-224/-466/-2626/-8160 qgrayraster.c:1535:30: runtime error: left shift of negative value -32/-46/-224/-2626/-8160 Fix by using ordinary multiplication instead, because negative left-hand-side values don't look like they are an error. Change-Id: I2e96de51adb4a030de8a49869ddd98a31dab31b3 Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qgrayraster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c index b536028fe3..5ce1895541 100644 --- a/src/gui/painting/qgrayraster.c +++ b/src/gui/painting/qgrayraster.c @@ -202,13 +202,13 @@ #define ONE_PIXEL ( 1L << PIXEL_BITS ) #define PIXEL_MASK ( -1L << PIXEL_BITS ) #define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) -#define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS ) +#define SUBPIXELS( x ) ( (TPos)(x) * ( 1 << PIXEL_BITS ) ) #define FLOOR( x ) ( (x) & -ONE_PIXEL ) #define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL ) #define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL ) #if PIXEL_BITS >= 6 -#define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) ) +#define UPSCALE( x ) ( (x) * ( 1 << ( PIXEL_BITS - 6 ) ) ) #define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) ) #else #define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) ) -- cgit v1.2.3 From 8a33077853e851e2795476cd502444c2d8535f9a Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 28 Jul 2016 12:25:59 +0200 Subject: QUrl: fix resolved() for data URLs They look relative because the path doesn't start with a '/' but they have a scheme so they shouldn't be combined as if it was one absolute and one relative URL. [ChangeLog][QtCore][QUrl] QUrl::resolved() no longer treats a URL with a scheme as a relative URL if it matches this URL's scheme. This special casing was incompatible with RFC 3986 and broke resolving data: URLs, for instance. Change-Id: I3758d3a2141cea7c6d13514243eb8dee5d510dd0 Reviewed-by: Thiago Macieira --- src/corelib/io/qurl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 2672de24f2..1fe529d48d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3167,8 +3167,7 @@ QUrl QUrl::resolved(const QUrl &relative) const if (!relative.d) return *this; QUrl t; - // be non strict and allow scheme in relative url - if (!relative.d->scheme.isEmpty() && relative.d->scheme != d->scheme) { + if (!relative.d->scheme.isEmpty()) { t = relative; t.detach(); } else { -- cgit v1.2.3 From f0685992a3412b059a0952ac591f40856ffffb6f Mon Sep 17 00:00:00 2001 From: Konstantin Shegunov Date: Sun, 24 Jul 2016 22:14:49 +0300 Subject: Docs changed to reflect that valueName is required with value parsing When the option expects a value the valueName parameter of the constructor isn't optional; it must be set. This requirement is made explicit in the documentation. Task-number: QTBUG-54855 Change-Id: I190884aff2fa8e96bc5c5e82cdfed85be761d6e3 Reviewed-by: Thiago Macieira Reviewed-by: David Faure --- src/corelib/tools/qcommandlineoption.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp index 8c0ba8cb2b..93d20577c3 100644 --- a/src/corelib/tools/qcommandlineoption.cpp +++ b/src/corelib/tools/qcommandlineoption.cpp @@ -144,7 +144,7 @@ QCommandLineOption::QCommandLineOption(const QStringList &names) The description is set to \a description. It is customary to add a "." at the end of the description. - In addition, the \a valueName can be set if the option expects a value. + In addition, the \a valueName needs to be set if the option expects a value. The default value for the option is set to \a defaultValue. In Qt versions before 5.4, this constructor was \c explicit. In Qt 5.4 @@ -180,7 +180,7 @@ QCommandLineOption::QCommandLineOption(const QString &name, const QString &descr The description is set to \a description. It is customary to add a "." at the end of the description. - In addition, the \a valueName can be set if the option expects a value. + In addition, the \a valueName needs to be set if the option expects a value. The default value for the option is set to \a defaultValue. In Qt versions before 5.4, this constructor was \c explicit. In Qt 5.4 -- cgit v1.2.3 From 068ce0b10c700df35ce10dee71e76d24a23694f5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 12 Mar 2016 11:34:48 +0100 Subject: QRasterizer: fix UBs involving << with a negative LHS Left-shifts of negative values are undefined in C++. In particular, they don't behave arithmetically. Reported by UBSan: qrasterizer.cpp:609:48: runtime error: left shift of negative value -640/-2240 qrasterizer.cpp:982:38: runtime error: left shift of negative value -2 Fix by using ordinary multiplication instead, because negative left-hand-side values don't look like they are an error. No errors were actually reported for a.y << 10, but I changed it nonetheless, since all a missing error means is that the test data didn't excercise this code path with negative Y values. Change-Id: I1fa9deca263f12206a3f7eab6ad875fc3242269d Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qrasterizer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index 34d72bf493..9411a20000 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE typedef int Q16Dot16; #define Q16Dot16ToFloat(i) ((i)/65536.) #define FloatToQ16Dot16(i) (int)((i) * 65536.) -#define IntToQ16Dot16(i) ((i) << 16) +#define IntToQ16Dot16(i) ((i) * (1 << 16)) #define Q16Dot16ToInt(i) ((i) >> 16) #define Q16Dot16Factor 65536 @@ -606,7 +606,7 @@ void QScanConverter::mergeLine(QT_FT_Vector a, QT_FT_Vector b) int iBottom = qMin(m_bottom, int((b.y - 32 - rounding) >> 6)); if (iTop <= iBottom) { - Q16Dot16 aFP = Q16Dot16Factor/2 + (a.x << 10) - rounding; + Q16Dot16 aFP = Q16Dot16Factor/2 + (a.x * (1 << 10)) - rounding; if (b.x == a.x) { Line line = { qBound(m_leftFP, aFP, m_rightFP), 0, iTop, iBottom, winding }; @@ -618,7 +618,7 @@ void QScanConverter::mergeLine(QT_FT_Vector a, QT_FT_Vector b) Q16Dot16 xFP = aFP + Q16Dot16Multiply(slopeFP, IntToQ16Dot16(iTop) - + Q16Dot16Factor/2 - (a.y << 10)); + + Q16Dot16Factor/2 - (a.y * (1 << 10))); if (clip(xFP, iTop, iBottom, slopeFP, m_leftFP, winding)) return; -- cgit v1.2.3 From 8740a87841689c97dc92f7600b33c260e4bf7f2c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 30 Jul 2016 22:20:26 +0300 Subject: QAbstractItemView: Fix UB (invalid downcast) Just use QWidgetPrivate::get() instead. Fixes UBSan error: qabstractitemview.cpp:3814:61: runtime error: downcast of address 0x2b859001aa70 which does not point to an object of type 'QAbstractItemView' 0x2b859001aa70: note: object is of type 'QWidget' Change-Id: I0460fd8a0681e122d440755ebf07018d273b93f8 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/itemviews/qabstractitemview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index f31f2f5256..cb40eae9a2 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3821,7 +3821,7 @@ void QAbstractItemView::doAutoScroll() int horizontalValue = horizontalScroll->value(); QPoint pos = d->viewport->mapFromGlobal(QCursor::pos()); - QRect area = static_cast(d->viewport)->d_func()->clipRect(); // access QWidget private by bending C++ rules + QRect area = QWidgetPrivate::get(d->viewport)->clipRect(); // do the scrolling if we are in the scroll margins if (pos.y() - area.top() < margin) -- cgit v1.2.3 From b37539442f58fc7c0ba54380f07b132a15a037e8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 30 Jul 2016 09:27:37 +0300 Subject: QColor: Fix UB (left shift of negative number) If hex2int(const char*) is called with invalid input, it is expected to return a negative value. However, it didn't check the return value of h2i() before attempting a left-shift on it, leading to UB when the first digit was already invalid. UBSan agrees: qcolor_p.cpp:55:23: runtime error: left shift of negative value -1 This is particularly worrisome as the function can be called with unsanitized input. Fix by checking each value for non-negativity, returning -1 early when errors are detected. Also port to QtMiscUtils::fromHex() and add some docs. Change-Id: I33dbc157ffb4fbfba27113a0a008eef35c1055f7 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/painting/qcolor_p.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index 4ebe74ce4f..b63c34aab7 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -34,31 +34,37 @@ #include "qglobal.h" #include "qrgb.h" #include "qstringlist.h" +#include "private/qtools_p.h" #include QT_BEGIN_NAMESPACE -static inline int h2i(char hex) -{ - if (hex >= '0' && hex <= '9') - return hex - '0'; - if (hex >= 'a' && hex <= 'f') - return hex - 'a' + 10; - if (hex >= 'A' && hex <= 'F') - return hex - 'A' + 10; - return -1; -} - +/*! + \internal + If s[0..1] is a valid hex number, returns its integer value, + otherwise returns -1. + */ static inline int hex2int(const char *s) { - return (h2i(s[0]) << 4) | h2i(s[1]); + const int hi = QtMiscUtils::fromHex(s[0]); + if (hi < 0) + return -1; + const int lo = QtMiscUtils::fromHex(s[1]); + if (lo < 0) + return -1; + return (hi << 4) | lo; } +/*! + \internal + If s is a valid hex digit, returns its integer value, + multiplied by 0x11, otherwise returns -1. + */ static inline int hex2int(char s) { - int h = h2i(s); - return (h << 4) | h; + const int h = QtMiscUtils::fromHex(s); + return h < 0 ? h : (h << 4) | h; } bool qt_get_hex_rgb(const char *name, QRgb *rgb) -- cgit v1.2.3 From 4ac28eda8edaff06ee7cb310108bfb9d9f1984ff Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 31 Jul 2016 07:40:41 +0300 Subject: QTreeWidget: Fix UB (member call) Before actually deleting QTreeWidgetItems from QTree{Model,Widget{,Item}} dtors, their 'view' members need to be set to nullptr, lest they attempt to delist themselves from the list of top-level items. For the QTreeModel::headerItem, this was forgottten. Found by UBSan: qtreewidget.cpp:1488:70: runtime error: member call on address 0x7ffd843dd470 which does not point to an object of type 'QAbstractItemView' 0x7ffd843dd470: note: object is of type 'QWidget' #0 0x2b83d5b48323 in QTreeWidgetItem::~QTreeWidgetItem() src/widgets/itemviews/qtreewidget.cpp:1488 #1 0x2b83d5b48860 in QTreeWidgetItem::~QTreeWidgetItem() src/widgets/itemviews/qtreewidget.cpp:1535 #2 0x2b83d5b41659 in QTreeModel::~QTreeModel() src/widgets/itemviews/qtreewidget.cpp:143 #3 0x2b83d5b41bc0 in QTreeModel::~QTreeModel() src/widgets/itemviews/qtreewidget.cpp:146 #4 0x2b83df220747 in QObjectPrivate::deleteChildren() src/corelib/kernel/qobject.cpp:2010 #5 0x2b83d4603dd0 in QWidget::~QWidget() src/widgets/kernel/qwidget.cpp:1675 #6 0x2b83d4d76066 in QFrame::~QFrame() src/widgets/widgets/qframe.cpp:256 #7 0x2b83d5270442 in QAbstractScrollArea::~QAbstractScrollArea() src/widgets/widgets/qabstractscrollarea.cpp:575 #8 0x2b83d5733eb9 in QAbstractItemView::~QAbstractItemView() src/widgets/itemviews/qabstractitemview.cpp:617 #9 0x2b83d598b216 in QTreeView::~QTreeView() src/widgets/itemviews/qtreeview.cpp:206 #10 0x2b83d5b218b6 in QTreeWidget::~QTreeWidget() src/widgets/itemviews/qtreewidget.cpp:2549 #11 0x4eef42 in tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget() tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp:1089 Change-Id: I57c277adee8c99eb07b274d6d8ea1f6fbf3575be Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/itemviews/qtreewidget.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index f33dd6af17..e0f6a3d5d1 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -140,6 +140,7 @@ QTreeModel::QTreeModel(QTreeModelPrivate &dd, QTreeWidget *parent) QTreeModel::~QTreeModel() { clear(); + headerItem->view = Q_NULLPTR; delete headerItem; rootItem->view = 0; delete rootItem; -- cgit v1.2.3 From 3f1048cca783749c7da9a9f8b3a61959ed35a0de Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 28 Jul 2016 13:41:43 +0200 Subject: Android: Fix CJK text with Android 7.0 In Android 7, some fonts are packed in .ttc files. We fix this simply by including them when populating the font database. Freetype supports this and in fact, QBasicFontDatabase::populateFontDatabase() also adds *.ttc. [ChangeLog][Android] Fixed CJK font resolution on Android 7. Task-number: QTBUG-53511 Change-Id: Iebe51b0e6ba2d6987693306cd9a12013ce886b58 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidplatformfontdatabase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp index 5725f5793e..86d50f487b 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp @@ -54,7 +54,8 @@ void QAndroidPlatformFontDatabase::populateFontDatabase() QStringList nameFilters; nameFilters << QLatin1String("*.ttf") - << QLatin1String("*.otf"); + << QLatin1String("*.otf") + << QLatin1String("*.ttc"); foreach (const QFileInfo &fi, dir.entryInfoList(nameFilters, QDir::Files)) { const QByteArray file = QFile::encodeName(fi.absoluteFilePath()); -- cgit v1.2.3 From 6f423555eba55ccdf7287071e10576bc1b687fd2 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 1 Aug 2016 13:39:53 +0200 Subject: REG: Fix unwanted cache flush in Freetype engine The Freetype cache was almost completely disabled by 134c6db8587a8ce156d4fa31ffa62605821851b2 because after that change, the lockedAlphaMapForGlyph() function would no longer cut off early for empty glyphs like spaces, but rather go through all alpha map functions before it realized that there was nothing to render. This would in turn invalidate the cache for every empty glyph, causing all glyphs to be rerendered for every isolated word. This change adds back a cut off. This is only needed in the lockedAlphaMapForGlyph() function, since the superclass implementation of the other alpha map functions already contains a cut off for width/height == 0. [ChangeLog][Qt Gui][Text] Fixed a performance regression in Freetype engine that was introduced in Qt 5.5. Change-Id: I381285939909e99cc5fb5f3497fecf9fa871f29a Task-number: QTBUG-49452 Reviewed-by: Simon Hausmann --- src/gui/text/qfontengine_ft.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 4de41dfa99..7c878da27f 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1716,7 +1716,7 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, QFixed subPixe static inline QImage alphaMapFromGlyphData(QFontEngineFT::Glyph *glyph, QFontEngine::GlyphFormat glyphFormat) { - if (glyph == Q_NULLPTR) + if (glyph == Q_NULLPTR || glyph->height == 0 || glyph->width == 0) return QImage(); QImage::Format format = QImage::Format_Invalid; @@ -1764,11 +1764,15 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe currentlyLockedAlphaMap = alphaMapFromGlyphData(glyph, neededFormat); + const bool glyphHasGeometry = glyph != Q_NULLPTR && glyph->height != 0 && glyph->width != 0; if (!cacheEnabled && glyph != &emptyGlyph) { currentlyLockedAlphaMap = currentlyLockedAlphaMap.copy(); delete glyph; } + if (!glyphHasGeometry) + return Q_NULLPTR; + if (currentlyLockedAlphaMap.isNull()) return QFontEngine::lockedAlphaMapForGlyph(glyphIndex, subPixelPosition, neededFormat, t, offset); -- cgit v1.2.3 From 49c892328223dfa2502b462d8e5e8e181f4f6cd5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 25 Jul 2016 13:24:59 +0200 Subject: QSortFilterProxyModel: Don't forward the hint from source's layoutChanged signal We can't forward a VerticalSortHint or HorizontalSortHint hint, because we might be filtering extra items. The documentation of QAbstractItemModel::LayoutChangeHint states: Note that VerticalSortHint and HorizontalSortHint carry the meaning that items are being moved within the same parent, not moved to a different parent in the model, and not filtered out or in. And some of the views rely on this assumption (QQmlDelegateModel for example) What happens in the test is the following: - 'model' emit the dataChanged signal when its data is changed. - 'proxi1' QSortFilterProxyModelPrivate::_q_sourceDataChanged does not forward the dataChanged signal imediatly, it will instead first re-sort the model and call layoutAboutToBeChanged / layouChanged with the VerticalSortHint - 'proxy2' would forward the layoutAboutToBeChanged with the hint, but in QSortFilterProxyModelPrivate::_q_sourceLayoutChanged, it will redo the mapping which will cause the changed data to be filtered. So proxy2 can't forward the VerticalSortHint as it removed rows in the process. Change-Id: I20b6983e9d18bf7509fe6144c74f37d24e4a18c2 Reviewed-by: Tobias Koenig Reviewed-by: David Faure --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 0771fd0e30..f264ad015d 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -1322,6 +1322,7 @@ void QSortFilterProxyModelPrivate::_q_sourceReset() void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint) { Q_Q(QSortFilterProxyModel); + Q_UNUSED(hint); // We can't forward Hint because we might filter additional rows or columns saved_persistent_indexes.clear(); QList parents; @@ -1340,7 +1341,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QListlayoutAboutToBeChanged(parents, hint); + emit q->layoutAboutToBeChanged(parents); if (persistent.indexes.isEmpty()) return; @@ -1350,6 +1351,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList &sourceParents, QAbstractItemModel::LayoutChangeHint hint) { Q_Q(QSortFilterProxyModel); + Q_UNUSED(hint); // We can't forward Hint because we might filter additional rows or columns // Optimize: We only actually have to clear the mapping related to the contents of // sourceParents, not everything. @@ -1379,7 +1381,7 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QListlayoutChanged(parents, hint); + emit q->layoutChanged(parents); } void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted( -- cgit v1.2.3 From d38f86e50b01c6dd60f5a97355031e08d6a47d18 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 30 Jul 2016 09:36:04 +0300 Subject: QColor: remove 158 avoidable relocations Instead of storing a pointer to a string, store the string in the RGBData struct. It's not as efficient as in other such cases, because one string is particularly long, but it's still more than acceptable. Text size increases slightly, but data size decreases a lot (can't say by how much, exactly, as I'm on a UBSan build). Change-Id: I1df2985fd1ebfccd84b48315d8d319dd9e25c8e7 Reviewed-by: Gunnar Sletta --- src/gui/painting/qcolor_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index b63c34aab7..2b9ef6030e 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -130,7 +130,7 @@ bool qt_get_hex_rgb(const QChar *str, int len, QRgb *rgb) #define rgb(r,g,b) (0xff000000 | (r << 16) | (g << 8) | b) static const struct RGBData { - const char *name; + const char name[21]; uint value; } rgbTbl[] = { { "aliceblue", rgb(240, 248, 255) }, -- cgit v1.2.3 From a81be85b63f8caf817bb7c4a840ff3a3aaf49a83 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 1 Aug 2016 10:05:28 +0300 Subject: QDataWidgetMapper: Fix UB (member call) As found by UBSan: qdatawidgetmapper.cpp:212:59: runtime error: member call on address 0x2b6cc8095be0 which does not point to an object of type 'QFocusHelper' 0x2b6cc8095be0: note: object is of type 'QLineEdit' Just make QDataWidgetMapperPrivate a friend of QWidget. Change-Id: I33d8d430c3a03b7173358d0f96dc7f850d11697c Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Friedemann Kleint --- src/widgets/itemviews/qdatawidgetmapper.cpp | 18 ++---------------- src/widgets/kernel/qwidget.h | 1 + 2 files changed, 3 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp index ee7b3613a2..058a570437 100644 --- a/src/widgets/itemviews/qdatawidgetmapper.cpp +++ b/src/widgets/itemviews/qdatawidgetmapper.cpp @@ -199,20 +199,6 @@ void QDataWidgetMapperPrivate::_q_commitData(QWidget *w) commit(widgetMap.at(idx)); } -class QFocusHelper: public QWidget -{ -public: - bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE - { - return QWidget::focusNextPrevChild(next); - } - - static inline void focusNextPrevChild(QWidget *w, bool next) - { - static_cast(w)->focusNextPrevChild(next); - } -}; - void QDataWidgetMapperPrivate::_q_closeEditor(QWidget *w, QAbstractItemDelegate::EndEditHint hint) { int idx = findWidget(w); @@ -224,10 +210,10 @@ void QDataWidgetMapperPrivate::_q_closeEditor(QWidget *w, QAbstractItemDelegate: populate(widgetMap[idx]); break; } case QAbstractItemDelegate::EditNextItem: - QFocusHelper::focusNextPrevChild(w, true); + w->focusNextChild(); break; case QAbstractItemDelegate::EditPreviousItem: - QFocusHelper::focusNextPrevChild(w, false); + w->focusPreviousChild(); break; case QAbstractItemDelegate::SubmitModelCache: case QAbstractItemDelegate::NoHint: diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 2af1550ad1..c8e08a5bc4 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -668,6 +668,7 @@ protected: void destroy(bool destroyWindow = true, bool destroySubWindows = true); + friend class QDataWidgetMapperPrivate; // for access to focusNextPrevChild virtual bool focusNextPrevChild(bool next); inline bool focusNextChild() { return focusNextPrevChild(true); } inline bool focusPreviousChild() { return focusNextPrevChild(false); } -- cgit v1.2.3 From 08f38d22149f062006316997a04fee57c33bc577 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 28 Jul 2016 19:51:53 +0300 Subject: tst_QAbstractItemView: Fix UB (invalid downcast, member call) As reported by UBSan: tst_qabstractitemview.cpp:336:23: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView' 0x7ffe6fe96e10: note: object is of type 'QListView' tst_qabstractitemview.cpp:337:5: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView' 0x7ffe6fe96e10: note: object is of type 'QListView' tst_qabstractitemview.cpp:338:23: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView' 0x7ffe6fe96e10: note: object is of type 'QListView' [etc ...] Fix by making the test a friend of QAbstractItemView instead. Change-Id: I1a08977042296eb34e9dbdb5c0595662dbd2e5ef Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/itemviews/qabstractitemview.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index ff1848b149..82bc7cb9ae 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -39,6 +39,8 @@ #include #include +class tst_QAbstractItemView; + QT_BEGIN_NAMESPACE @@ -359,6 +361,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged()) #endif + friend class ::tst_QAbstractItemView; friend class QTreeViewPrivate; // needed to compile with MSVC friend class QListModeViewBase; friend class QListViewPrivate; -- cgit v1.2.3 From 5dc83974f7e6f72d715c4c940ca57741a550aa1c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 28 Jul 2016 19:51:53 +0300 Subject: tst_QTreeView: Fix UB (invalid downcast, member call) As reported by UBSan: tst_qtreeview.cpp:2187:36: runtime error: downcast of address 0x7ffc15749f20 which does not point to an object of type 'PublicView' 0x7ffc15749f20: note: object is of type 'QTreeView' Fix by making the test a friend of QTreeView (and, for Clang, of QAbstractItemView) instead. Change-Id: I5b748696ab441a91058f4d45a18bd5ed75a6e560 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/itemviews/qabstractitemview.h | 2 ++ src/widgets/itemviews/qtreeview.h | 3 +++ 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index 82bc7cb9ae..8d712280d3 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -40,6 +40,7 @@ #include class tst_QAbstractItemView; +class tst_QTreeView; QT_BEGIN_NAMESPACE @@ -362,6 +363,7 @@ private: #endif friend class ::tst_QAbstractItemView; + friend class ::tst_QTreeView; friend class QTreeViewPrivate; // needed to compile with MSVC friend class QListModeViewBase; friend class QListViewPrivate; diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h index 546cc488cb..9257bb66fa 100644 --- a/src/widgets/itemviews/qtreeview.h +++ b/src/widgets/itemviews/qtreeview.h @@ -36,6 +36,8 @@ #include +class tst_QTreeView; + QT_BEGIN_NAMESPACE @@ -213,6 +215,7 @@ protected: void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) Q_DECL_OVERRIDE; private: + friend class ::tst_QTreeView; friend class QAccessibleTable; friend class QAccessibleTree; friend class QAccessibleTableCell; -- cgit v1.2.3 From b92a63f7073b35a31f66af280bd50ddff1d15b50 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 27 Jul 2016 08:34:54 +0200 Subject: Fix typo in QMessageBox documentation Change-Id: I879817bf0209db331a9b1ef206bad7aa5b8a678f Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qmessagebox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index dbbf6cdc71..f32f7b0417 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -697,7 +697,7 @@ void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button If the \l{QMessageBox::StandardButtons} {standard buttons} are not flexible enough for your message box, you can use the addButton() - overload that takes a text and a ButtonRoleto to add custom + overload that takes a text and a ButtonRole to add custom buttons. The ButtonRole is used by QMessageBox to determine the ordering of the buttons on screen (which varies according to the platform). You can test the value of clickedButton() after calling -- cgit v1.2.3 From 879fd5bb5ce94d9d98b966448029c030832eb582 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 14 Jun 2016 12:34:53 +0200 Subject: QTzTimeZonePrivate: skip redundant check, tidy up Various transition functions checked on m_tranTimes.size() > 0 inside a block which was conditioned on this already; simplify the code by knowing this is true already. Tidied up an initializer at the same time. Change-Id: I3e933a69e1b71b94bfd4451e4d761844da669d33 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_tz.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index 29544a5c37..c13c9a5223 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -896,13 +896,12 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch && !m_posixRule.isEmpty() && forMSecsSinceEpoch >= 0) { const int year = QDateTime::fromMSecsSinceEpoch(forMSecsSinceEpoch, Qt::UTC).date().year(); - const int lastMSecs = (m_tranTimes.size() > 0) ? m_tranTimes.last().atMSecsSinceEpoch : 0; - QVector posixTrans = calculatePosixTransitions(m_posixRule, year - 1, - year + 1, lastMSecs); + QVector posixTrans = + calculatePosixTransitions(m_posixRule, year - 1, year + 1, + m_tranTimes.last().atMSecsSinceEpoch); for (int i = posixTrans.size() - 1; i >= 0; --i) { if (posixTrans.at(i).atMSecsSinceEpoch <= forMSecsSinceEpoch) { - QTimeZonePrivate::Data data; - data = posixTrans.at(i); + QTimeZonePrivate::Data data = posixTrans.at(i); data.atMSecsSinceEpoch = forMSecsSinceEpoch; return data; } @@ -940,9 +939,9 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSince if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch && !m_posixRule.isEmpty() && afterMSecsSinceEpoch >= 0) { const int year = QDateTime::fromMSecsSinceEpoch(afterMSecsSinceEpoch, Qt::UTC).date().year(); - const int lastMSecs = (m_tranTimes.size() > 0) ? m_tranTimes.last().atMSecsSinceEpoch : 0; - QVector posixTrans = calculatePosixTransitions(m_posixRule, year - 1, - year + 1, lastMSecs); + QVector posixTrans = + calculatePosixTransitions(m_posixRule, year - 1, year + 1, + m_tranTimes.last().atMSecsSinceEpoch); for (int i = 0; i < posixTrans.size(); ++i) { if (posixTrans.at(i).atMSecsSinceEpoch > afterMSecsSinceEpoch) return posixTrans.at(i); @@ -966,9 +965,9 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecs if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch && !m_posixRule.isEmpty() && beforeMSecsSinceEpoch > 0) { const int year = QDateTime::fromMSecsSinceEpoch(beforeMSecsSinceEpoch, Qt::UTC).date().year(); - const int lastMSecs = (m_tranTimes.size() > 0) ? m_tranTimes.last().atMSecsSinceEpoch : 0; - QVector posixTrans = calculatePosixTransitions(m_posixRule, year - 1, - year + 1, lastMSecs); + QVector posixTrans = + calculatePosixTransitions(m_posixRule, year - 1, year + 1, + m_tranTimes.last().atMSecsSinceEpoch); for (int i = posixTrans.size() - 1; i >= 0; --i) { if (posixTrans.at(i).atMSecsSinceEpoch < beforeMSecsSinceEpoch) return posixTrans.at(i); -- cgit v1.2.3 From dbb5c95f4d80644c6273b3adbe0148cdf30710d2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 1 Aug 2016 16:15:13 +0200 Subject: Windows QPA: Handle key event sequences of surrogates Emoji characters as input by the virtual keyboard are received as a sequence of surrogates. Store state internally when a high surrogate is received and send off the sequence when the matching low surrogate is received via input method. Task-number: QTBUG-50617 Change-Id: I91e763ec3e0747d6852f7c5c2057a67b0c24e0f5 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 16 ++++++++++++++++ src/plugins/platforms/windows/qwindowskeymapper.h | 1 + 2 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 403ac6ecfb..1e58b9b3d4 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -37,6 +37,7 @@ #include "qwindowswindow.h" #include "qwindowsinputcontext.h" +#include #include #include #include @@ -1072,6 +1073,21 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) { // Found a ?_CHAR uch = QChar(ushort(wm_char.wParam)); + if (uch.isHighSurrogate()) { + m_lastHighSurrogate = uch; + return true; + } else if (uch.isLowSurrogate() && !m_lastHighSurrogate.isNull()) { + if (QObject *focusObject = QGuiApplication::focusObject()) { + const QChar chars[2] = {m_lastHighSurrogate, uch}; + QInputMethodEvent event; + event.setCommitString(QString(chars, 2)); + QCoreApplication::sendEvent(focusObject, &event); + } + m_lastHighSurrogate = QChar(); + return true; + } else { + m_lastHighSurrogate = QChar(); + } if (msgType == WM_SYSKEYDOWN && uch.isLetter() && (msg.lParam & KF_ALTDOWN)) uch = uch.toLower(); // (See doc of WM_SYSCHAR) Alt-letter if (!code && !uch.row()) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.h b/src/plugins/platforms/windows/qwindowskeymapper.h index 3a3170e4ae..81ae1a3297 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.h +++ b/src/plugins/platforms/windows/qwindowskeymapper.h @@ -97,6 +97,7 @@ private: void deleteLayouts(); QWindow *m_keyGrabber; + QChar m_lastHighSurrogate; static const size_t NumKeyboardLayoutItems = 256; KeyboardLayoutItem keyLayout[NumKeyboardLayoutItems]; }; -- cgit v1.2.3 From 2a24c3c268d443fb260d731d9f65b57726a40354 Mon Sep 17 00:00:00 2001 From: Clemens Sielaff Date: Sun, 24 Jul 2016 11:21:34 +1200 Subject: Fixed Bug in QVariant comparison when containing QStringLists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As it were, QStringLists were not handled explicitly when comparing QVariants. If both QStringLists contained only a single entry, they were treated as QStrings - if both QStringLists were empty, there were equal (correctly so) - but if one of the QStringLists had more than one entry, the compare function fell through to returning always 1. As discussed here: https://stackoverflow.com/a/38492467/3444217 Added rich comparison tests for all non-numerical, non-recursive QVariants that support them (except QModelIndex and QPersistentModelIndex) Task-number: QTBUG-54893 Change-Id: Icc5480d9ba056ee5efe83da566c5829caa1509d7 Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qvariant.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 7596699843..4f256cccda 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3560,6 +3560,8 @@ int QVariant::compare(const QVariant &v) const return v1.toTime() < v2.toTime() ? -1 : 1; case QVariant::DateTime: return v1.toDateTime() < v2.toDateTime() ? -1 : 1; + case QVariant::StringList: + return v1.toStringList() < v2.toStringList() ? -1 : 1; } int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); if (r == 0) { -- cgit v1.2.3 From ed38f516bf1a9185ed331c2e5a38648e64a3982a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 2 Aug 2016 20:29:55 +0300 Subject: QStringListModel: begin/endResetModel() are no signals ... so don't use emit on them. Just confuses readers. Change-Id: I24365fc533b5b35f8942d6014dbc68387aa23e22 Reviewed-by: Friedemann Kleint --- src/corelib/itemmodels/qstringlistmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index b0919c5d78..c6a1fac9c8 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -301,9 +301,9 @@ QStringList QStringListModel::stringList() const */ void QStringListModel::setStringList(const QStringList &strings) { - emit beginResetModel(); + beginResetModel(); lst = strings; - emit endResetModel(); + endResetModel(); } /*! -- cgit v1.2.3 From f200d5e824761d583ecdcf5cf952b14ec5693049 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 13 Jul 2016 10:41:09 +0200 Subject: Doc: Fix references to Control, Meta key enums MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also make use of qdoc's \note command. Change-Id: I276300cfcfde06e82b04793dbf25df8ec73e9838 Reviewed-by: Leena Miettinen Reviewed-by: Topi Reiniö --- src/gui/kernel/qkeysequence.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index a0818b8d20..f3ebf00224 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -219,9 +219,9 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni code point of the character; for example, 'A' gives the same key sequence as Qt::Key_A. - \b{Note:} On OS X, references to "Ctrl", Qt::CTRL, Qt::Control + \note On OS X, references to "Ctrl", Qt::CTRL, Qt::Key_Control and Qt::ControlModifier correspond to the \uicontrol Command keys on the - Macintosh keyboard, and references to "Meta", Qt::META, Qt::Meta and + Macintosh keyboard, and references to "Meta", Qt::META, Qt::Key_Meta and Qt::MetaModifier correspond to the \uicontrol Control keys. Developers on OS X can use the same shortcut descriptions across all platforms, and their applications will automatically work as expected on OS X. -- cgit v1.2.3 From bc4ce55fff78610c15d6c8a0cb97526889cb5de3 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 4 Aug 2016 11:43:44 +0300 Subject: Don't call virtual functions with data from an old model Change-Id: I4f1ec56ce722110042f72761bbc2976e580b7149 Reviewed-by: David Faure Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/itemviews/qabstractitemview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index cb40eae9a2..d36431c716 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -769,8 +769,10 @@ void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel) QModelIndex oldCurrentIndex; if (d->selectionModel) { - oldSelection = d->selectionModel->selection(); - oldCurrentIndex = d->selectionModel->currentIndex(); + if (d->selectionModel->model() == selectionModel->model()) { + oldSelection = d->selectionModel->selection(); + oldCurrentIndex = d->selectionModel->currentIndex(); + } disconnect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection))); -- cgit v1.2.3 From b643d6f347a72ebe97f63dce1d63414d8ced6405 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 3 Aug 2016 14:20:54 +0200 Subject: Fix 64-bit bilinear scaled image sampling A constraint ensuring we do not sample beyond the current scan-line was missing in the SSE2 optimized sampling. Discovered with lancelot. Change-Id: Ib0ece8f8bfaa034733873dc5b8baaaad5d4c0380 Reviewed-by: Erik Verbruggen --- src/gui/painting/qdrawhelper.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index f0e5810b54..a0f7155c67 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -2815,10 +2815,16 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co sbuf2[i * 2 + 1] = ((const uint*)s2)[x2]; fx += fdx; } + int fastLen; + if (fdx > 0) + fastLen = qMin(len, int((image_x2 - (fx >> 16)) / data->m11)); + else + fastLen = qMin(len, int((image_x1 - (fx >> 16)) / data->m11)); + fastLen -= 3; const __m128i v_fdx = _mm_set1_epi32(fdx*4); __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx); - for (; i < len-3; i+=4) { + for (; i < fastLen; i += 4) { int offset = _mm_extract_epi16(v_fx, 1); sbuf1[i * 2 + 0] = ((const uint*)s1)[offset]; sbuf1[i * 2 + 1] = ((const uint*)s1)[offset + 1]; -- cgit v1.2.3 From 457d91bb07a8ad0d1a582016566ba5119bb1ac95 Mon Sep 17 00:00:00 2001 From: charlycha Date: Tue, 9 Feb 2016 06:36:07 +0100 Subject: raspberry pi: manage eglfs display id with env var Specify the display to use by setting environment variable QT_QPA_EGLFS_DISPMANX_ID Possible values are : 0: MAIN LCD 1: AUX LCD 2: HDMI 3: SDTV 4: FORCE LCD 5: FORCE TV 6: FORCE OTHER Change-Id: I146db9a7f423bd4c6c1716c64d3df4d2388e85f9 Reviewed-by: Andy Nichols --- .../eglfs_brcm/qeglfsbrcmintegration.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.cpp index 4813d9be04..544ac31877 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.cpp @@ -87,9 +87,23 @@ void QEglFSBrcmIntegration::platformInit() bcm_host_init(); } +static int getDisplayId() +{ + // As defined in vc_dispmanx_types.h + // DISPMANX_ID_MAIN_LCD 0 + // DISPMANX_ID_AUX_LCD 1 + // DISPMANX_ID_HDMI 2 + // DISPMANX_ID_SDTV 3 + // DISPMANX_ID_FORCE_LCD 4 + // DISPMANX_ID_FORCE_TV 5 + // DISPMANX_ID_FORCE_OTHER 6 /* non-default display */ + static const int dispmanxId = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISPMANX_ID"); + return (dispmanxId >= 0 && dispmanxId <= 6) ? dispmanxId : 0; +} + EGLNativeDisplayType QEglFSBrcmIntegration::platformDisplay() const { - dispman_display = vc_dispmanx_display_open(0/* LCD */); + dispman_display = vc_dispmanx_display_open(getDisplayId()); return EGL_DEFAULT_DISPLAY; } @@ -101,7 +115,7 @@ void QEglFSBrcmIntegration::platformDestroy() QSize QEglFSBrcmIntegration::screenSize() const { uint32_t width, height; - graphics_get_display_size(0 /* LCD */, &width, &height); + graphics_get_display_size(getDisplayId(), &width, &height); return QSize(width, height); } -- cgit v1.2.3 From 595c6abf9d2cb666f2502bbf89ab3a7052717027 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Thu, 28 Jul 2016 17:28:27 +0300 Subject: QLocalSocket/Tcp: open device before making a connection According to QLocalSocket's documentation, connectToServer() must initiate a connection attempt after opening the device. Otherwise, if a connection succeeds immediately, connected() signal will be emitted on closed device. So, this patch ensures that TCP-based implementation behaves correctly. Change-Id: I4cc9474815e091a1491a429a6dc17f9cf0154f58 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/network/socket/qlocalsocket_tcp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index c0140e574e..461ece837f 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -239,8 +239,8 @@ void QLocalSocket::connectToServer(OpenMode openMode) QLatin1String("QLocalSocket::connectToServer")); return; } - d->tcpSocket->connectToHost(QHostAddress::LocalHost, port, openMode); QIODevice::open(openMode); + d->tcpSocket->connectToHost(QHostAddress::LocalHost, port, openMode); } bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor, -- cgit v1.2.3 From 35117590c8f4634ddfdbe75966dd43adeca69369 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Fri, 3 Jun 2016 07:33:55 +0200 Subject: Remove unneeded ';' after some macros The unneeded ';' triggered warnings in pedantic compilation mode. Change-Id: Id2324823e138560bb25234306601253d7bbd713e Reviewed-by: Richard J. Moore Reviewed-by: Friedemann Kleint Reviewed-by: Allan Sandfeld Jensen --- src/gui/image/qpixmap_blitter_p.h | 2 +- src/gui/opengl/qopengltextureblitter_p.h | 4 ++-- src/gui/painting/qblittable_p.h | 2 +- src/gui/painting/qdatabuffer_p.h | 2 +- src/gui/painting/qpaintengine_blitter_p.h | 2 +- src/network/ssl/qsslsocket_mac_p.h | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 6dbcbd91be..e1444f6279 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE class Q_GUI_EXPORT QBlittablePlatformPixmap : public QPlatformPixmap { -// Q_DECLARE_PRIVATE(QBlittablePlatformPixmap); +// Q_DECLARE_PRIVATE(QBlittablePlatformPixmap) public: QBlittablePlatformPixmap(); ~QBlittablePlatformPixmap(); diff --git a/src/gui/opengl/qopengltextureblitter_p.h b/src/gui/opengl/qopengltextureblitter_p.h index ebf3a4bfbb..65149d2cb0 100644 --- a/src/gui/opengl/qopengltextureblitter_p.h +++ b/src/gui/opengl/qopengltextureblitter_p.h @@ -83,8 +83,8 @@ public: static QMatrix3x3 sourceTransform(const QRectF &subTexture, const QSize &textureSize, Origin origin); private: - Q_DISABLE_COPY(QOpenGLTextureBlitter); - Q_DECLARE_PRIVATE(QOpenGLTextureBlitter); + Q_DISABLE_COPY(QOpenGLTextureBlitter) + Q_DECLARE_PRIVATE(QOpenGLTextureBlitter) QScopedPointer d_ptr; }; diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h index 47218f2f35..1a5c507348 100644 --- a/src/gui/painting/qblittable_p.h +++ b/src/gui/painting/qblittable_p.h @@ -57,7 +57,7 @@ class QBlittablePrivate; class Q_GUI_EXPORT QBlittable { - Q_DECLARE_PRIVATE(QBlittable); + Q_DECLARE_PRIVATE(QBlittable) public: enum Capability { diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index 3fe39efdde..2a6b1bde4c 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE template class QDataBuffer { - Q_DISABLE_COPY(QDataBuffer); + Q_DISABLE_COPY(QDataBuffer) public: QDataBuffer(int res) { diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index ab44851ec7..e960fbcfa8 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -56,7 +56,7 @@ class QBlittable; class Q_GUI_EXPORT QBlitterPaintEngine : public QRasterPaintEngine { - Q_DECLARE_PRIVATE(QBlitterPaintEngine); + Q_DECLARE_PRIVATE(QBlitterPaintEngine) public: QBlitterPaintEngine(QBlittablePlatformPixmap *p); diff --git a/src/network/ssl/qsslsocket_mac_p.h b/src/network/ssl/qsslsocket_mac_p.h index 7a622db185..e8d9d34693 100644 --- a/src/network/ssl/qsslsocket_mac_p.h +++ b/src/network/ssl/qsslsocket_mac_p.h @@ -68,7 +68,7 @@ public: private: SSLContextRef context; - Q_DISABLE_COPY(QSecureTransportContext); + Q_DISABLE_COPY(QSecureTransportContext) }; class QSslSocketBackendPrivate : public QSslSocketPrivate @@ -115,7 +115,7 @@ private: QSecureTransportContext context; - Q_DISABLE_COPY(QSslSocketBackendPrivate); + Q_DISABLE_COPY(QSslSocketBackendPrivate) }; QT_END_NAMESPACE -- cgit v1.2.3 From 9c8a8e90a6514c23bcbeb14073a9d6bdd926d68b Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 11 Jul 2016 17:23:21 +0300 Subject: QString: fix append(const QStringRef &str) Use QStringRef::isNull instead of QStringRef::string() for validation. Non-NULL str.string() may yet leave us with a useless str.unicode(), which is the actual problem here; whereas !str.isNull() does really confirm that str.unicode() is sensible. Such test prevents situation like: const QString a; QString b; b.append(a); // b.isNull() == true b.append(QStringRef(&a)); // b.isNull() == false Auto test updated: create QStringRef from QString directly, without any condition. Change-Id: I082cd58ef656d8a53e3c1223aca01feea82fffb9 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/tools/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b5119444b7..9aeec77632 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9375,7 +9375,7 @@ QString &QString::append(const QStringRef &str) { if (str.string() == this) { str.appendTo(this); - } else if (str.string()) { + } else if (!str.isNull()) { int oldSize = size(); resize(oldSize + str.size()); memcpy(data() + oldSize, str.unicode(), str.size() * sizeof(QChar)); -- cgit v1.2.3 From 91a2c8630b2204831566ab8e523c747f9d8ec927 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 2 Aug 2016 14:07:37 +0200 Subject: QUrl::resolved: keep treating file:name.txt as relative for now 8a33077 made QUrl::resolved() follow its documentation ("If relative is not a relative URL, this function will return relative directly.", where relative means scheme is empty). However there is much code out there (e.g. qtdeclarative) which relies on QUrl::fromLocalFile("fileName.txt") to be treated as relative, so for now, we still allow this (in Qt 5.6.x). For Qt 5.8, this commit will be reverted. [ChangeLog][QtCore][QUrl] [EDITORIAL: replaces 8a33077] QUrl::resolved() no longer treats a URL with a scheme as a relative URL if it matches this URL's scheme. For now it still treats "file:name.txt" as relative for compatibility, but be warned that in Qt 5.8 it will no longer consider those to be relative. Both isRelative() and RFC 3986 say that such URLs are not relative, so starting from Qt 5.8, resolved() will return them as is. Change-Id: Iff01e5b470319f6c46526086d765187e2259bdf5 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qurl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 1fe529d48d..a5643d123d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3167,7 +3167,8 @@ QUrl QUrl::resolved(const QUrl &relative) const if (!relative.d) return *this; QUrl t; - if (!relative.d->scheme.isEmpty()) { + // Compatibility hack (mostly for qtdeclarative) : treat "file:relative.txt" as relative even though QUrl::isRelative() says false + if (!relative.d->scheme.isEmpty() && (!relative.isLocalFile() || QDir::isAbsolutePath(relative.d->path))) { t = relative; t.detach(); } else { -- cgit v1.2.3