From bff683416c73329eb91bdb0bc282f4022c9fec7e Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 8 Jul 2016 14:41:49 +0200 Subject: [PATCH 01/24] QDateTimeEditPrivate:: only ask for fieldInfo() if section index is real On construction, currentSectionIndex has the fake value FirstSectionIndex, which upsets fieldInfo(), leading to a qWarning(). Make interpret(), when deciding whether to delegate to base or handle the value itself, treat fake index value as an invalid state. Task-number: QTBUG-54654 Change-Id: I6d0f71874839abfafcbfaaa0018362288f32a3cd Reviewed-by: Andy Shaw --- src/widgets/widgets/qdatetimeedit.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 96a37197e92..98b0489dfcc 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2344,7 +2344,9 @@ void QDateTimeEditPrivate::interpret(EmitPolicy ep) const QValidator::State state = q->validate(tmp, pos); if (state != QValidator::Acceptable && correctionMode == QAbstractSpinBox::CorrectToPreviousValue - && (state == QValidator::Invalid || !(fieldInfo(currentSectionIndex) & AllowPartial))) { + && (state == QValidator::Invalid + || currentSectionIndex < 0 + || !(fieldInfo(currentSectionIndex) & AllowPartial))) { setValue(value, ep); updateTimeSpec(); } else { From 8356caea45cfd24bb11ab673f16f6761768e6811 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 10 Oct 2016 14:20:43 +0200 Subject: [PATCH 02/24] Fix QPixelFormat::typeInterpretation() for Format_RGB888 RGB888 is byte oriented like the RGBA8888 formats. Task-number: QTBUG-56250 Change-Id: Idbd496e4913e5d168decdd41557e28a71574a85b Reviewed-by: Laszlo Agocs --- src/gui/image/qimage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 17d3c02e36c..856ba642043 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -5008,7 +5008,7 @@ static Q_CONSTEXPR QPixelFormat pixelformats[] = { /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha, /*ALPHA POSITION*/ QPixelFormat::AtBeginning, /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied, - /*INTERPRETATION*/ QPixelFormat::UnsignedInteger, + /*INTERPRETATION*/ QPixelFormat::UnsignedByte, /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian), //QImage::Format_RGB444: QPixelFormat(QPixelFormat::RGB, From 940ea856f0b5796b43d1053bc7549d50f9afd31c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: [PATCH 03/24] QtSql: compile with GCC 7 GCC 7 warns about implicit fall-throughs now. Fix by adding the missing comments. Change-Id: I7383f47e690b6334ef69c9df745c2205247ca7d0 Reviewed-by: Thiago Macieira Reviewed-by: Mark Brand --- src/sql/kernel/qsqldriver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index adaeb8c846b..7ff89cd5dcc 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -654,6 +654,7 @@ QString QSqlDriver::formatValue(const QSqlField &field, bool trimStrings) const break; } } + // fall through default: r = field.value().toString(); break; From 6d6074e04fa55a0e42c7d8970f6db1cc3913a26e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 9 Oct 2016 19:29:25 +0200 Subject: [PATCH 04/24] Plug leaks in tst_QXmlSimpleReader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QXmlInputSource objects were allocated on the heap, but never deleted. Fix by allocating them on the stack instead. Change-Id: Ifd8bd41d778c0634b7a426bbd22a367dfce511c9 Reviewed-by: David Faure Reviewed-by: Jędrzej Nowacki --- .../sax/qxmlsimplereader/tst_qxmlsimplereader.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp index dc5d776f6de..5fe693dd149 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -765,22 +765,22 @@ void tst_QXmlSimpleReader::dtdRecursionLimit() QVERIFY(file.open(QIODevice::ReadOnly)); QXmlSimpleReader xmlReader; { - QXmlInputSource *source = new QXmlInputSource(&file); + QXmlInputSource source(&file); TestHandler handler; xmlReader.setDeclHandler(&handler); xmlReader.setErrorHandler(&handler); - QVERIFY(!xmlReader.parse(source)); + QVERIFY(!xmlReader.parse(&source)); } file.close(); file.setFileName("xmldocs/1-levels-nested-dtd.xml"); QVERIFY(file.open(QIODevice::ReadOnly)); { - QXmlInputSource *source = new QXmlInputSource(&file); + QXmlInputSource source(&file); TestHandler handler; xmlReader.setDeclHandler(&handler); xmlReader.setErrorHandler(&handler); - QVERIFY(!xmlReader.parse(source)); + QVERIFY(!xmlReader.parse(&source)); // The error wasn't because of the recursion limit being reached, // it was because the document is not valid. QVERIFY(handler.recursionCount < 2); @@ -790,11 +790,11 @@ void tst_QXmlSimpleReader::dtdRecursionLimit() file.setFileName("xmldocs/internal-entity-polynomial-attribute.xml"); QVERIFY(file.open(QIODevice::ReadOnly)); { - QXmlInputSource *source = new QXmlInputSource(&file); + QXmlInputSource source(&file); TestHandler handler; xmlReader.setDeclHandler(&handler); xmlReader.setErrorHandler(&handler); - QVERIFY(!xmlReader.parse(source)); + QVERIFY(!xmlReader.parse(&source)); QCOMPARE(handler.recursionCount, 2); } } From f6498fd6776b08b6bd33395e3f716b6d5d79a8b8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 30 Sep 2016 22:21:37 +0200 Subject: [PATCH 05/24] Plug more than 4k leaks in tst_QGraphicsView The vast majority is due to leaking styles in a data-driven test with almost 100 rows (scrollBarRanges()). Fix by creating the style into a QScopedPointer. The remaining ~500 leaks were due to leaked QGraphicsScenes. They had no parent, and QGraphicsView::addScene() does not adopt them. Fix those by passing the resp. view as their (QObject) parent. Change-Id: I4316798019114ea3d7504d72cd83d534a21149c0 Reviewed-by: Allan Sandfeld Jensen --- .../qgraphicsview/tst_qgraphicsview.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index f5083795c76..da2606c160f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -2938,6 +2938,9 @@ void tst_QGraphicsView::scrollBarRanges() if (useStyledPanel && style == QStringLiteral("Macintosh") && platformName == QStringLiteral("cocoa")) QSKIP("Insignificant on OSX"); + + QScopedPointer stylePtr; + QGraphicsScene scene; QGraphicsView view(&scene); view.setRenderHint(QPainter::Antialiasing); @@ -2945,9 +2948,10 @@ void tst_QGraphicsView::scrollBarRanges() view.setFrameStyle(useStyledPanel ? QFrame::StyledPanel : QFrame::NoFrame); if (style == QString("motif")) - view.setStyle(new FauxMotifStyle); + stylePtr.reset(new FauxMotifStyle); else - view.setStyle(QStyleFactory::create(style)); + stylePtr.reset(QStyleFactory::create(style)); + view.setStyle(stylePtr.data()); view.setStyleSheet(" "); // enables style propagation ;-) int adjust = 0; @@ -3514,7 +3518,7 @@ void tst_QGraphicsView::task245469_itemsAtPointWithClip() static QGraphicsView *createSimpleViewAndScene() { QGraphicsView *view = new QGraphicsView; - QGraphicsScene *scene = new QGraphicsScene; + QGraphicsScene *scene = new QGraphicsScene(view); view->setScene(scene); view->setBackgroundBrush(Qt::blue); @@ -3642,7 +3646,7 @@ void tst_QGraphicsView::moveItemWhileScrolling() MoveItemScrollView() { setWindowFlags(Qt::X11BypassWindowManagerHint); - setScene(new QGraphicsScene(0, 0, 1000, 1000)); + setScene(new QGraphicsScene(0, 0, 1000, 1000, this)); rect = scene()->addRect(0, 0, 10, 10); rect->setPos(50, 50); rect->setPen(QPen(Qt::black, 0)); @@ -3708,7 +3712,7 @@ void tst_QGraphicsView::centerOnDirtyItem() toplevel.setWindowFlags(view.windowFlags() | Qt::WindowStaysOnTopHint); view.resize(200, 200); - QGraphicsScene *scene = new QGraphicsScene; + QGraphicsScene *scene = new QGraphicsScene(&view); view.setScene(scene); view.setSceneRect(-1000, -1000, 2000, 2000); From 9ad4157530e86a1bac7ab8ca50ba3ee9f839f536 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 10 Oct 2016 11:30:51 +0200 Subject: [PATCH 06/24] Fix gradient race condition / read-after-free A gradient table may be deallocated while in use because we don't keep track of references. To fix it we now reference count the cache entries. Task-number: QTBUG-14614 Change-Id: I772ebf565ccf41d476811ca9a51b721f10de8aeb Reviewed-by: Marc Mutz --- src/gui/painting/qdrawhelper_p.h | 2 + src/gui/painting/qpaintengine_raster.cpp | 51 ++++++++++++------------ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index d636eabe3f9..1c6cd5db8ae 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -329,6 +329,8 @@ struct QSpanData QGradientData gradient; QTextureData texture; }; + QExplicitlySharedDataPointer cachedGradient; + void init(QRasterBuffer *rb, const QRasterPaintEngine *pe); void setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 278d7bb99ef..f87b052df24 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4137,7 +4137,8 @@ void QRasterBuffer::flushToARGBImage(QImage *target) const class QGradientCache { - struct CacheInfo +public: + struct CacheInfo : public QSharedData { inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) : stops(qMove(s)), opacity(op), interpolationMode(mode) {} @@ -4148,12 +4149,9 @@ class QGradientCache QGradient::InterpolationMode interpolationMode; }; - typedef QMultiHash QGradientColorTableHash; + typedef QMultiHash > QGradientColorTableHash; -public: - typedef QPair ColorBufferPair; - - inline ColorBufferPair getBuffer(const QGradient &gradient, int opacity) { + inline QExplicitlySharedDataPointer getBuffer(const QGradient &gradient, int opacity) { quint64 hash_val = 0; const QGradientStops stops = gradient.stops(); @@ -4167,10 +4165,9 @@ public: return addCacheElement(hash_val, gradient, opacity); else { do { - const CacheInfo &cache_info = it.value(); - if (cache_info.stops == stops && cache_info.opacity == opacity && cache_info.interpolationMode == gradient.interpolationMode()) - return qMakePair(reinterpret_cast(cache_info.buffer32), - reinterpret_cast(cache_info.buffer64)); + const QExplicitlySharedDataPointer &cache_info = it.value(); + if (cache_info->stops == stops && cache_info->opacity == opacity && cache_info->interpolationMode == gradient.interpolationMode()) + return cache_info; ++it; } while (it != cache.constEnd() && it.key() == hash_val); // an exact match for these stops and opacity was not found, create new cache @@ -4184,18 +4181,16 @@ protected: inline void generateGradientColorTable(const QGradient& g, QRgba64 *colorTable, int size, int opacity) const; - ColorBufferPair addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { + QExplicitlySharedDataPointer addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { if (cache.size() == maxCacheSize()) { // may remove more than 1, but OK cache.erase(cache.begin() + (qrand() % maxCacheSize())); } - CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode()); - generateGradientColorTable(gradient, cache_entry.buffer64, paletteSize(), opacity); + QExplicitlySharedDataPointer cache_entry(new CacheInfo (gradient.stops(), opacity, gradient.interpolationMode())); + generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity); for (int i = 0; i < GRADIENT_STOPTABLE_SIZE; ++i) - cache_entry.buffer32[i] = cache_entry.buffer64[i].toArgb32(); - CacheInfo &cache_value = cache.insert(hash_val, cache_entry).value(); - return qMakePair(reinterpret_cast(cache_value.buffer32), - reinterpret_cast(cache_value.buffer64)); + cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32(); + return cache.insert(hash_val, cache_entry).value(); } QGradientColorTableHash cache; @@ -4414,6 +4409,7 @@ Q_GUI_EXPORT extern QImage qt_imageForBrush(int brushStyle, bool invert); void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode) { Qt::BrushStyle brushStyle = qbrush_style(brush); + cachedGradient.reset(); switch (brushStyle) { case Qt::SolidPattern: { type = Solid; @@ -4430,9 +4426,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QLinearGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha); - gradient.colorTable64 = colorBuffers.second; - gradient.colorTable32 = colorBuffers.first; + QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + cachedGradient = cacheInfo; + gradient.colorTable32 = cacheInfo->buffer32; + gradient.colorTable64 = cacheInfo->buffer64; gradient.spread = g->spread(); @@ -4451,9 +4448,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QRadialGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha); - gradient.colorTable64 = colorBuffers.second; - gradient.colorTable32 = colorBuffers.first; + QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + cachedGradient = cacheInfo; + gradient.colorTable32 = cacheInfo->buffer32; + gradient.colorTable64 = cacheInfo->buffer64; gradient.spread = g->spread(); @@ -4476,9 +4474,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QConicalGradient *g = static_cast(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha); - gradient.colorTable64 = colorBuffers.second; - gradient.colorTable32 = colorBuffers.first; + QExplicitlySharedDataPointer cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + cachedGradient = cacheInfo; + gradient.colorTable32 = cacheInfo->buffer32; + gradient.colorTable64 = cacheInfo->buffer64; gradient.spread = QGradient::RepeatSpread; From dafa7cc7b5bc35f06f63a78b8f29a7d71fc93f5d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Oct 2016 20:34:54 +0200 Subject: [PATCH 07/24] QFileDialog: add missing break statements in switch in labelText() It is of course wrong to potentially return the text of the Cancel button if the text of the Accept role button was asked for. Found independently by GCC 7 and Coverity. Coverity-Id: 11150 Change-Id: Ie30f7875daee16a78eeff4b314ce17cbd7cd3aa8 Reviewed-by: Edward Welbourne --- src/widgets/dialogs/qfiledialog.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 3aa9052917f..61f5f7b0d23 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -2042,10 +2042,12 @@ QString QFileDialog::labelText(DialogLabel label) const button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Save); if (button) return button->text(); + break; case Reject: button = d->qFileDialogUi->buttonBox->button(QDialogButtonBox::Cancel); if (button) return button->text(); + break; } return QString(); } From eec2d5e68af7b65342e4e5a95e47481a483be67e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 8 Oct 2016 00:48:02 +0200 Subject: [PATCH 08/24] QCalendarWidget: fix a missing break statement GCC 7 warns about implicit fall-throughs, and here it looks like a break was indeed missing. It surely isn't catastrophic that the other update code is executed, too, but it's also useless. Turns out Coverity knew it all along... Coverity-Id: 11162 Change-Id: I88fc0174a66ec337b2d93c006e70be8d5f3bbc33 Reviewed-by: Edward Welbourne --- src/widgets/widgets/qcalendarwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 89cde851e57..3823b9c10fa 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -2994,6 +2994,7 @@ bool QCalendarWidget::event(QEvent *event) switch (event->type()) { case QEvent::LayoutDirectionChange: d->updateButtonIcons(); + break; case QEvent::LocaleChange: d->m_model->setFirstColumnDay(locale().firstDayOfWeek()); d->cachedSizeHint = QSize(); From 2ecd95bbe907cc9199773bb7930f781058735e1c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Oct 2016 20:47:40 +0200 Subject: [PATCH 09/24] QCalendarWidget: fix misleading if-else cascade in QCalendarDayValidator::text() By the time we hit the last else, its if condition is trivially true, so don't check it (but leave it as a comment). Consequently, remove the trailing (dead) return of a default- constructed QString. Coverity-Id: 62766 Change-Id: I47e1a49f40e6ec95d29c5052c78bfadb63af3b84 Reviewed-by: Edward Welbourne --- src/widgets/widgets/qcalendarwidget.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 3823b9c10fa..7895dc04d92 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -205,10 +205,9 @@ QString QCalendarDayValidator::text(const QDate &date, int repeat) const return formatNumber(date.day(), 2); } else if (repeat == 3) { return m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat); - } else if (repeat >= 4) { + } else /* repeat >= 4 */ { return m_locale.dayName(date.dayOfWeek(), QLocale::LongFormat); } - return QString(); } ////////////////////////////////// From 1ab521e7f46ad4e3c925d4eececdf3a2ff8b493b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 11 Oct 2016 00:56:59 +0200 Subject: [PATCH 10/24] QFusionStyle: add missing break in switch in drawControl() The old code fell through into from the CE_RubberBand case into the CE_SizeGrip case if the cast of the the QStyleOption to a QStyleOptionRubberBand failed. Quite obviously, the drawing of a rubber band was requested by the caller, drawing a size grip instead must be considered a bug, regardless of any additional guards employed by the size grip case. So, fix by removing the conditional return in the success case and adding an unconditional break. The function ends after the switch, and all other cases also break instead of return, so consider the switch from return to break a contribution to the internal consistency of the function. Discovered independently by GCC 7 and Coverity. Coverity-Id: 11182 Change-Id: I2158f03b9eb018b952716ffa5e615c7b3cc49132 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qfusionstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index e9e1f349c58..dcc99496e31 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1077,8 +1077,8 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio painter->setPen(innerLine); painter->drawRoundedRect(option->rect.adjusted(1, 1, -2, -2), 1, 1); painter->restore(); - return; } + break; case CE_SizeGrip: painter->save(); { From c34c8a564ef029144db6d2be256de7e46f91199a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Oct 2016 21:43:05 +0200 Subject: [PATCH 11/24] QComboBox: add missing break in switch in keyPressEvent() If the Key_Space case falls through, it does because !d->lineEdit, which makes the following case dead code, because it is guarded by the same condition. Fix by adding the break, which ensures that if those two cases ever diverge, the code stays working by intention, not chance. Independently discovered by GCC 7 and Coverity. Coverity-Id: 11157 Change-Id: Id14114b4157549d0f6fa036e8aa2bf0fa5a863cf Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qcombobox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 181671c493d..450c27d5730 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -3160,6 +3160,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e) showPopup(); return; } + break; case Qt::Key_Enter: case Qt::Key_Return: case Qt::Key_Escape: From afe5bcdbd1dbf8c8a229d75d16b614f5e645d32f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 27 Sep 2016 11:25:10 +0200 Subject: [PATCH 12/24] tst_QWidget: Fix UB (invalid member access) in EnterTestMainDialog::eventFilter() Found by UBSan: tst_qwidget.cpp:10207:29: runtime error: member access within address 0x6060000e8880 which does not point to an object of type 'EnterTestModalDialog' 0x6060000e8880: note: object is of type 'QWidget' eb 00 80 45 10 4b 32 ab 11 2b 00 00 80 df 08 00 60 61 00 00 c0 4c 32 ab 11 2b 00 00 00 00 be be ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QWidget' #0 0x6ca13f in EnterTestMainDialog::eventFilter(QObject*, QEvent*) tst_qwidget.cpp:10207 #1 0x2b11b8bc90c3 in QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject*, QEvent*) qcoreapplication.cpp:1081 #2 0x2b11a3c49b4a in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3716 #3 0x2b11a3c8ec72 in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3704 #4 0x2b11b8bccd0f in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:988 #5 0x2b11aea5c34d in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.h:231 #6 0x2b11aea5c34d in QGuiApplicationPrivate::_q_updateFocusObject(QObject*) qguiapplication.cpp:3690 #7 0x2b11aea61360 in QGuiApplication::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) .moc/moc_qguiapplication.cpp:177 #8 0x2b11b8d1dc86 in QMetaObject::activate(QObject*, int, int, void**) qobject.cpp:3787 #9 0x2b11aea784a3 in QWindow::focusObjectChanged(QObject*) .moc/moc_qwindow.cpp:760 #10 0x2b11a3fb24f2 in QWidget::clearFocus() qwidget.cpp:6705 #11 0x2b11a3fc87b1 in QWidget::~QWidget() qwidget.cpp:1608 #12 0x2b11a526688c in QDialog::~QDialog() qdialog.cpp:352 #13 0x6c43e2 in EnterTestModalDialog::~EnterTestModalDialog() tst_qwidget.cpp:10160 #14 0x6c43e2 in EnterTestModalDialog::~EnterTestModalDialog() tst_qwidget.cpp:10160 #15 0x492be3 in EnterTestMainDialog::buttonPressed() tst_qwidget.cpp:10188 #16 0x492be3 in EnterTestMainDialog::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) .moc/tst_qwidget.moc:2056 #17 0x2b11b8d1dc86 in QMetaObject::activate(QObject*, int, int, void**) qobject.cpp:3787 #18 0x2b11a45cb833 in QAbstractButton::clicked(bool) .moc/moc_qabstractbutton.cpp:307 #19 0x2b11a45cd54b in QAbstractButtonPrivate::emitClicked() qabstractbutton.cpp:411 #20 0x2b11a45df73a in QAbstractButtonPrivate::click() qabstractbutton.cpp:404 [...] #41 0x6bb2cf in tst_QWidget::taskQTBUG_27643_enterEvents() tst_qwidget.cpp:10249 [...] Fix by checking the event type first, and accessing modal->button only if it's QEvent::Enter. Change-Id: I2c7df3a1f43ecbfe14741b5861729078a91a32d6 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index e00e575c364..cc1aaa7d51f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -10430,14 +10430,13 @@ public slots: bool eventFilter(QObject *o, QEvent *e) { - if (modal && modal->button && o == modal->button) { - switch (e->type()) { - case QEvent::Enter: + switch (e->type()) { + case QEvent::Enter: + if (modal && modal->button && o == modal->button) enters++; - break; - default: - break; - } + break; + default: + break; } return QDialog::eventFilter(o, e); } From eade394e993bb190bb71152ea0bd805beade6f59 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: [PATCH 13/24] QtDBus: compile with GCC 7 GCC 7 warns about implicit fall-throughs now. Fix by adding the missing comments. Change-Id: I629fb3aced9296c81496f19f6ff78c7a5a12e991 Reviewed-by: Thiago Macieira --- src/dbus/qdbusabstractinterface.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index d63a3176129..d12a7d127e0 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -755,18 +755,25 @@ QDBusMessage QDBusAbstractInterface::call(QDBus::CallMode mode, const QString &m switch (count) { case 8: argList.prepend(arg8); + // fall through case 7: argList.prepend(arg7); + // fall through case 6: argList.prepend(arg6); + // fall through case 5: argList.prepend(arg5); + // fall through case 4: argList.prepend(arg4); + // fall through case 3: argList.prepend(arg3); + // fall through case 2: argList.prepend(arg2); + // fall through case 1: argList.prepend(arg1); } @@ -813,18 +820,25 @@ QDBusPendingCall QDBusAbstractInterface::asyncCall(const QString &method, const switch (count) { case 8: argList.prepend(arg8); + // fall through case 7: argList.prepend(arg7); + // fall through case 6: argList.prepend(arg6); + // fall through case 5: argList.prepend(arg5); + // fall through case 4: argList.prepend(arg4); + // fall through case 3: argList.prepend(arg3); + // fall through case 2: argList.prepend(arg2); + // fall through case 1: argList.prepend(arg1); } From 0c8b5b9a0446fdd881bbceddbbe2afc9ec9f1a0b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: [PATCH 14/24] QtOpenGl: compile with GCC 7 GCC 7 warns about implicit fall-throughs now. Fix by adding the missing comments. Change-Id: I081d4db07c7f2b30ee6344a166aaec34ac639ee5 Reviewed-by: Edward Welbourne Reviewed-by: Sean Harmer --- src/opengl/qgl.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 652a498930e..071c8d63cb5 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1287,14 +1287,19 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co switch (versionString[2].toLatin1()) { case '5': versionFlags |= QGLFormat::OpenGL_Version_1_5; + // fall through case '4': versionFlags |= QGLFormat::OpenGL_Version_1_4; + // fall through case '3': versionFlags |= QGLFormat::OpenGL_Version_1_3; + // fall through case '2': versionFlags |= QGLFormat::OpenGL_Version_1_2; + // fall through case '1': versionFlags |= QGLFormat::OpenGL_Version_1_1; + // fall through default: break; } @@ -1319,10 +1324,13 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co switch (versionString[2].toLatin1()) { case '3': versionFlags |= QGLFormat::OpenGL_Version_3_3; + // fall through case '2': versionFlags |= QGLFormat::OpenGL_Version_3_2; + // fall through case '1': versionFlags |= QGLFormat::OpenGL_Version_3_1; + // fall through case '0': break; default: @@ -1347,10 +1355,13 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co switch (versionString[2].toLatin1()) { case '3': versionFlags |= QGLFormat::OpenGL_Version_4_3; + // fall through case '2': versionFlags |= QGLFormat::OpenGL_Version_4_2; + // fall through case '1': versionFlags |= QGLFormat::OpenGL_Version_4_1; + // fall through case '0': break; default: From 77372e0b66393c1f9673e41418683c96a361dfe4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: [PATCH 15/24] harfbuzz: compile with GCC 7 GCC 7 warns about implicit fall-throughs now. Fix by adding the missing comment. Didn't send a patch to upstream, because upstream harfbuzz-old hasn't seen a commit in four years, and this code is no longer in harfbuzz-ng. Change-Id: Ic97efbe01edd37738dcdf43528e82511197d7fb2 Reviewed-by: Konstantin Ritt --- src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp index f7a4195308c..c234f199184 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp @@ -156,12 +156,14 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast) // ### wrong in rtl context! case HB_Combining_BelowLeft: p.y += offset; + // fall through case HB_Combining_BelowLeftAttached: p.x += attachmentRect.x - markMetrics.x; p.y += (attachmentRect.y + attachmentRect.height) - markMetrics.y; break; case HB_Combining_Below: p.y += offset; + // fall through case HB_Combining_BelowAttached: p.x += attachmentRect.x - markMetrics.x; p.y += (attachmentRect.y + attachmentRect.height) - markMetrics.y; @@ -170,28 +172,33 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast) break; case HB_Combining_BelowRight: p.y += offset; + // fall through case HB_Combining_BelowRightAttached: p.x += attachmentRect.x + attachmentRect.width - markMetrics.width - markMetrics.x; p.y += attachmentRect.y + attachmentRect.height - markMetrics.y; break; case HB_Combining_Left: p.x -= offset; + // fall through case HB_Combining_LeftAttached: break; case HB_Combining_Right: p.x += offset; + // fall through case HB_Combining_RightAttached: break; case HB_Combining_DoubleAbove: // ### wrong in RTL context! case HB_Combining_AboveLeft: p.y -= offset; + // fall through case HB_Combining_AboveLeftAttached: p.x += attachmentRect.x - markMetrics.x; p.y += attachmentRect.y - markMetrics.y - markMetrics.height; break; case HB_Combining_Above: p.y -= offset; + // fall through case HB_Combining_AboveAttached: p.x += attachmentRect.x - markMetrics.x; p.y += attachmentRect.y - markMetrics.y - markMetrics.height; @@ -200,6 +207,7 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast) break; case HB_Combining_AboveRight: p.y -= offset; + // fall through case HB_Combining_AboveRightAttached: p.x += attachmentRect.x + attachmentRect.width - markMetrics.x - markMetrics.width; p.y += attachmentRect.y - markMetrics.y - markMetrics.height; From 00304a3d57b9ba33b6a253b8736cf7e15aeac5c3 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 12 Oct 2016 09:50:42 +0200 Subject: [PATCH 16/24] Blacklist tst_MacNativeEvents::testMouseEnter It is already blacklisted for 10.8 and 10.9, and is now failing on 10.11 blocking integration. Change-Id: I71b8119ab32ec64096bfc53d5e521714ad4ae11b Reviewed-by: Lars Knoll --- tests/auto/other/macnativeevents/BLACKLIST | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/other/macnativeevents/BLACKLIST b/tests/auto/other/macnativeevents/BLACKLIST index 4129868022c..3e68ba0cf01 100644 --- a/tests/auto/other/macnativeevents/BLACKLIST +++ b/tests/auto/other/macnativeevents/BLACKLIST @@ -2,8 +2,7 @@ [testDragWindow] osx [testMouseEnter] -osx-10.9 -osx-10.8 +osx [testChildDialogInFrontOfModalParent] osx [testChildWindowInFrontOfStaysOnTopParentWindow] From de48fd192b7973c4849ec79bce4cd491b5e8550f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Oct 2016 21:02:16 +0200 Subject: [PATCH 17/24] QToolBarAreaLayoutInfo: add missing break statements in switch in distance() A fall-through here is logically non-sensical, because of symmetry (or lack thereof). Thus, a break must have been intended. Add it. While we're at it, also replace the default case label with the non-functional enum value QInternal::DockCount, so that -Wswitch can warn us if ever there should be a new DockPosition. Found independently by both GCC 7 and Coverity. Coverity-Id: 11145 Coverity-Id: 11146 Coverity-Id: 11147 Change-Id: I6bb31c1517e40f0cb06ceaee5aeb6fa78b84a523 Reviewed-by: Edward Welbourne --- src/widgets/widgets/qtoolbararealayout.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 16b1115dd63..f42c1f0ed93 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -598,16 +598,21 @@ int QToolBarAreaLayoutInfo::distance(const QPoint &pos) const case QInternal::LeftDock: if (pos.y() < rect.bottom()) return pos.x() - rect.right(); + break; case QInternal::RightDock: if (pos.y() < rect.bottom()) return rect.left() - pos.x(); + break; case QInternal::TopDock: if (pos.x() < rect.right()) return pos.y() - rect.bottom(); + break; case QInternal::BottomDock: if (pos.x() < rect.right()) return rect.top() - pos.y(); - default: + break; + + case QInternal::DockCount: break; } return -1; From f4fff02cbb1f9399f407c15a27741c6cd1a17133 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 10 Oct 2016 16:09:32 +0200 Subject: [PATCH 18/24] QXcbShmImage: don't use shmget()'s return unless it succeeds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When shmget() failed, we didn't set m_shm_info.shmid (not even to the -1 failure id) but did pass it (i.e. uninitialized noise) to shmat(), among other related functions. Guard against this; handle failure gracefully. Task-number: QTBUG-56419 Change-Id: Ie823c36c2ede03af6cb5d94ce7b4b5cd543c1008 Reviewed-by: Timur Pocheptsov Reviewed-by: Błażej Szczygieł Reviewed-by: Shawn Rutledge Reviewed-by: Joni Poikelin Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 3b04c59e28b..0b76830d8ea 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -150,12 +150,13 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI return; int id = shmget(IPC_PRIVATE, segmentSize, IPC_CREAT | 0600); - if (id == -1) + if (id == -1) { qWarning("QXcbShmImage: shmget() failed (%d: %s) for size %d (%dx%d)", errno, strerror(errno), segmentSize, size.width(), size.height()); - else - m_shm_info.shmid = id; - m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0); + } else { + m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat(id, 0, 0); + } + m_shm_info.shmid = id; m_shm_info.shmseg = xcb_generate_id(xcb_connection()); const xcb_query_extension_reply_t *shm_reply = xcb_get_extension_data(xcb_connection(), &xcb_shm_id); @@ -166,9 +167,10 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI if (!shm_present || error || id == -1) { free(error); - shmdt(m_shm_info.shmaddr); - shmctl(m_shm_info.shmid, IPC_RMID, 0); - + if (id != -1) { + shmdt(m_shm_info.shmaddr); + shmctl(m_shm_info.shmid, IPC_RMID, 0); + } m_shm_info.shmaddr = 0; m_xcb_image->data = (uint8_t *)malloc(segmentSize); From f12006e64405de72ac09f364ef25ee9701c9b755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 6 Oct 2016 17:49:52 +0200 Subject: [PATCH 19/24] Don't resize windows that aren't attached to a platform window QWindows that aren't created, and therefore don't have a platform window attached, should not be treated as "normal" windows. The expectation, in our code, is that these windows won't get their geometry updated by the platform plugin, and that the geometry is only changed by the owner. In QQuickWidget's case this was causing the scene to be rendered incorrectly. Task-number: QTBUG-50973 Change-Id: Iea62dfb7fa90cbe450a662c5792c7c4f49c991fd Reviewed-by: Laszlo Agocs --- src/gui/kernel/qplatformscreen.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 8e9767d69e3..3ec7a4cf3ff 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -335,6 +335,10 @@ void QPlatformScreen::resizeMaximizedWindows() for (int i = 0; i < windows.size(); ++i) { QWindow *w = windows.at(i); + // Skip non-platform windows, e.g., offscreen windows. + if (!w->handle()) + continue; + if (platformScreenForWindow(w) != this) continue; From dde86ebb9b020811a731a180c4f4d98f3b60728b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 6 Oct 2016 18:34:10 +0200 Subject: [PATCH 20/24] Android: Don't update offscreen windows Offscreen windows should not be handle by the platform plugin. Task-number: QTBUG-50973 Change-Id: I719a24b9bbcaad460d78fdc4095e86d615357cd2 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/android/androidjnimain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index fe2401f561a..69c590940fa 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -621,7 +621,12 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/) if (QGuiApplication::instance() != nullptr) { foreach (QWindow *w, QGuiApplication::topLevelWindows()) { - QRect availableGeometry = w->screen()->availableGeometry(); + + // Skip non-platform windows, e.g., offscreen windows. + if (!w->handle()) + continue; + + QRect availableGeometry = w->screen()->availableGeometry(); if (w->geometry().width() > 0 && w->geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) QWindowSystemInterface::handleExposeEvent(w, QRegion(QRect(QPoint(), w->geometry().size()))); } From cc62c3002231d74cbee8cb0105adf6372d37e7d9 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Wed, 12 Oct 2016 14:13:36 +0300 Subject: [PATCH 21/24] Android: Ministro updates - bump minimum required Qt version - use market://details instead which opens Ministro's page directly Change-Id: I3d879503625fe29e7b23149402217337fee6a863 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../src/org/qtproject/qt5/android/bindings/QtActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java index 9fc903af8e6..faa57657095 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java @@ -101,7 +101,7 @@ public class QtActivity extends Activity private final static int MINISTRO_INSTALL_REQUEST_CODE = 0xf3ee; // request code used to know when Ministro instalation is finished private static final int MINISTRO_API_LEVEL = 5; // Ministro api level (check IMinistro.aidl file) private static final int NECESSITAS_API_LEVEL = 2; // Necessitas api level used by platform plugin - private static final int QT_VERSION = 0x050100; // This app requires at least Qt version 5.1.0 + private static final int QT_VERSION = 0x050600; // This app requires at least Qt version 5.6.0 private static final String ERROR_CODE_KEY = "error.code"; private static final String ERROR_MESSAGE_KEY = "error.message"; @@ -333,7 +333,7 @@ public class QtActivity extends Activity @Override public void onClick(DialogInterface dialogInterface, int i) { try { - Uri uri = Uri.parse("market://search?q=pname:org.kde.necessitas.ministro"); + Uri uri = Uri.parse("market://details?id=org.kde.necessitas.ministro"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivityForResult(intent, MINISTRO_INSTALL_REQUEST_CODE); } catch (Exception e) { From e732e432ab3b6741917cafa93117b8a9a04d6387 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 10 Oct 2016 01:13:23 +0300 Subject: [PATCH 22/24] Remove unused static member QIconLoaderEngineEntry::count It was introduced in Qt 4 by the commit 13a31fe82845f8b1f4d86919080d3b2a87c4d061 and was unused even there. Change-Id: I5f3861918ea1f443f7e13439fafa067f2b28a91a Reviewed-by: Marc Mutz --- src/gui/image/qiconloader_p.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h index ccf0a9d4382..4d31a5d898d 100644 --- a/src/gui/image/qiconloader_p.h +++ b/src/gui/image/qiconloader_p.h @@ -89,7 +89,6 @@ public: QIcon::State state) = 0; QString filename; QIconDirInfo dir; - static int count; }; struct ScalableEntry : public QIconLoaderEngineEntry From f3ce959de6c682bdb7e71f7b82742f28a5be1e9c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 5 Oct 2016 15:45:55 +0200 Subject: [PATCH 23/24] Fix illegal memory access on simple image rotates Clip the transformed and rounded sourceClip to the source rectangle, so we don't try to rotate pixels outside the source. Task-number: QTBUG-56252 Change-Id: Ib9cb80f9856724118867aea37ead0b02a6c71495 Reviewed-by: Shawn Rutledge Reviewed-by: Gunnar Sletta --- src/gui/painting/qpaintengine_raster.cpp | 2 ++ .../gui/painting/qpainter/tst_qpainter.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index f87b052df24..83370be33fd 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2273,6 +2273,8 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe = QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(), clippedTargetRect.width(), clippedTargetRect.height()).toRect(); + clippedSourceRect = clippedSourceRect.intersected(img.rect()); + uint dbpl = d->rasterBuffer->bytesPerLine(); uint sbpl = img.bytesPerLine(); diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 8c725321222..2c0012497df 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -307,6 +307,8 @@ private slots: void QTBUG50153_drawImage_assert(); + void QTBUG56252(); + private: void fillData(); void setPenColor(QPainter& p); @@ -5078,6 +5080,23 @@ void tst_QPainter::QTBUG50153_drawImage_assert() } } +void tst_QPainter::QTBUG56252() +{ + QImage sourceImage(1770, 1477, QImage::Format_RGB32); + QImage rotatedImage(1478, 1771, QImage::Format_RGB32); + QTransform transformCenter; + transformCenter.translate(739.0, 885.5); + transformCenter.rotate(270.0); + transformCenter.translate(-885.0, -738.5); + QPainter painter; + painter.begin(&rotatedImage); + painter.setTransform(transformCenter); + painter.drawImage(QPoint(0, 0),sourceImage); + painter.end(); + + // If no crash or illegal memory read, all is fine +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" From ef416e0faaa83cd122038db397dd24d949c9cafe Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 12 Oct 2016 17:18:18 +0300 Subject: [PATCH 24/24] QIconLoaderEngine: add missing Q_DECL_OVERRIDEs Change-Id: I7671b05f2e3c218870dca04f3ed52c231dbe4a9d Reviewed-by: Marc Mutz --- src/gui/image/qiconloader_p.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h index 4d31a5d898d..57ab60b7a59 100644 --- a/src/gui/image/qiconloader_p.h +++ b/src/gui/image/qiconloader_p.h @@ -117,18 +117,18 @@ public: QIconLoaderEngine(const QString& iconName = QString()); ~QIconLoaderEngine(); - void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state); - QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state); - QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state); - QIconEngine *clone() const; - bool read(QDataStream &in); - bool write(QDataStream &out) const; + void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE; + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE; + QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE; + QIconEngine *clone() const Q_DECL_OVERRIDE; + bool read(QDataStream &in) Q_DECL_OVERRIDE; + bool write(QDataStream &out) const Q_DECL_OVERRIDE; private: - QString key() const; + QString key() const Q_DECL_OVERRIDE; bool hasIcon() const; void ensureLoaded(); - void virtual_hook(int id, void *data); + void virtual_hook(int id, void *data) Q_DECL_OVERRIDE; QIconLoaderEngineEntry *entryForSize(const QSize &size); QIconLoaderEngine(const QIconLoaderEngine &other); QThemeIconInfo m_info;