From bff683416c73329eb91bdb0bc282f4022c9fec7e Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 8 Jul 2016 14:41:49 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 96a37197e9..98b0489dfc 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 { -- cgit v1.2.3 From 8356caea45cfd24bb11ab673f16f6761768e6811 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 10 Oct 2016 14:20:43 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 17d3c02e36..856ba64204 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, -- cgit v1.2.3 From 940ea856f0b5796b43d1053bc7549d50f9afd31c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index adaeb8c846..7ff89cd5dc 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; -- cgit v1.2.3 From 9ad4157530e86a1bac7ab8ca50ba3ee9f839f536 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 10 Oct 2016 11:30:51 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index d636eabe3f..1c6cd5db8a 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 278d7bb99e..f87b052df2 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; - -public: - typedef QPair ColorBufferPair; + typedef QMultiHash > QGradientColorTableHash; - 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; -- cgit v1.2.3 From dafa7cc7b5bc35f06f63a78b8f29a7d71fc93f5d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Oct 2016 20:34:54 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 3aa9052917..61f5f7b0d2 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(); } -- cgit v1.2.3 From eec2d5e68af7b65342e4e5a95e47481a483be67e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 8 Oct 2016 00:48:02 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 89cde851e5..3823b9c10f 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(); -- cgit v1.2.3 From 2ecd95bbe907cc9199773bb7930f781058735e1c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Oct 2016 20:47:40 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 3823b9c10f..7895dc04d9 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(); } ////////////////////////////////// -- cgit v1.2.3 From 1ab521e7f46ad4e3c925d4eececdf3a2ff8b493b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 11 Oct 2016 00:56:59 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index e9e1f349c5..dcc99496e3 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(); { -- cgit v1.2.3 From c34c8a564ef029144db6d2be256de7e46f91199a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Oct 2016 21:43:05 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 181671c493..450c27d573 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: -- cgit v1.2.3 From eade394e993bb190bb71152ea0bd805beade6f59 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index d63a317612..d12a7d127e 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); } -- cgit v1.2.3 From 0c8b5b9a0446fdd881bbceddbbe2afc9ec9f1a0b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 652a498930..071c8d63cb 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: -- cgit v1.2.3 From 77372e0b66393c1f9673e41418683c96a361dfe4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Oct 2016 18:58:23 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp index f7a4195308..c234f19918 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; -- cgit v1.2.3 From de48fd192b7973c4849ec79bce4cd491b5e8550f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 10 Oct 2016 21:02:16 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 16b1115dd6..f42c1f0ed9 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; -- cgit v1.2.3 From f4fff02cbb1f9399f407c15a27741c6cd1a17133 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 10 Oct 2016 16:09:32 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 3b04c59e28..0b76830d8e 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); -- cgit v1.2.3 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: 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(+) (limited to 'src') diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 8e9767d69e..3ec7a4cf3f 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; -- cgit v1.2.3 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: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index fe2401f561..69c590940f 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()))); } -- cgit v1.2.3 From cc62c3002231d74cbee8cb0105adf6372d37e7d9 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Wed, 12 Oct 2016 14:13:36 +0300 Subject: 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 --- .../java/src/org/qtproject/qt5/android/bindings/QtActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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 9fc903af8e..faa5765709 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) { -- cgit v1.2.3 From e732e432ab3b6741917cafa93117b8a9a04d6387 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 10 Oct 2016 01:13:23 +0300 Subject: 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(-) (limited to 'src') diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h index ccf0a9d438..4d31a5d898 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 -- cgit v1.2.3 From f3ce959de6c682bdb7e71f7b82742f28a5be1e9c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 5 Oct 2016 15:45:55 +0200 Subject: 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 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index f87b052df2..83370be33f 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(); -- cgit v1.2.3 From ef416e0faaa83cd122038db397dd24d949c9cafe Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 12 Oct 2016 17:18:18 +0300 Subject: 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(-) (limited to 'src') diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h index 4d31a5d898..57ab60b7a5 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; -- cgit v1.2.3