From 41750492db58ca30a70a685cd6a4ee180c0b4959 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Thu, 16 Mar 2017 14:48:49 +0300 Subject: [PATCH 1/4] Make sure QDBusMenuBar is restored when the window is hidden and shown Task-number: QTBUG-58723 Change-Id: Ib4c3dac8a8cce717f4d47ab619c05b9e1719f311 Reviewed-by: Shawn Rutledge --- .../themes/genericunix/dbusmenu/qdbusmenubar.cpp | 2 +- src/widgets/widgets/qmenubar.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp index fb0705c8c7..b13c875854 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenubar.cpp @@ -120,7 +120,7 @@ void QDBusMenuBar::syncMenu(QPlatformMenu *menu) void QDBusMenuBar::handleReparent(QWindow *newParentWindow) { - if (newParentWindow && newParentWindow->winId() != m_windowId) { + if (newParentWindow) { unregisterMenuBar(); m_windowId = newParentWindow->winId(); registerMenuBar(); diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 2588f41468..b2ec8f2c08 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1474,6 +1474,17 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event) } } + if (isNativeMenuBar() && event->type() == QEvent::ShowToParent) { + // On some desktops like Unity, the D-Bus menu bar is unregistered + // when the window is hidden. So when the window is shown, we need + // to forcefully re-register it. The only way to force re-registering + // with D-Bus menu is the handleReparent method. + QWidget *widget = qobject_cast(object); + QWindow *handle = widget ? widget->windowHandle() : nullptr; + if (handle != nullptr) + d->platformMenuBar->handleReparent(handle); + } + if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) { if (d->altPressed) { switch (event->type()) { From 1ab60b0430f2b57418ee4954fcfa43e1e14766fc Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 13 Dec 2016 10:02:15 +0200 Subject: [PATCH 2/4] Make sure we quit qt when the service is destroyed Task-number: QTBUG-58471 Change-Id: I37f162717f57323136811a8f80d53e3c3b7d6f22 Reviewed-by: Christian Stromme --- .../jar/src/org/qtproject/qt5/android/QtNative.java | 1 + .../src/org/qtproject/qt5/android/QtServiceDelegate.java | 2 +- src/plugins/platforms/android/androidjnimain.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index b7d1217e98..710648e25a 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -348,6 +348,7 @@ public class QtNative // application methods public static native void startQtApplication(String params, String env); public static native boolean startQtAndroidPlugin(); + public static native void quitQtCoreApplication(); public static native void quitQtAndroidPlugin(); public static native void terminateQt(); // application methods diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java index 5ac406c710..035a65a84c 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java @@ -185,6 +185,6 @@ public class QtServiceDelegate public void onDestroy() { - QtNative.setService(null, null); + QtNative.quitQtCoreApplication(); } } diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 0fabb25233..17c197ea38 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -533,6 +533,12 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para return pthread_create(&m_qtAppThread, nullptr, startMainMethod, nullptr) == 0; } +static void quitQtCoreApplication(JNIEnv *env, jclass /*clazz*/) +{ + Q_UNUSED(env); + QCoreApplication::quit(); +} + static void quitQtAndroidPlugin(JNIEnv *env, jclass /*clazz*/) { Q_UNUSED(env); @@ -733,6 +739,7 @@ static JNINativeMethod methods[] = { {"startQtAndroidPlugin", "()Z", (void *)startQtAndroidPlugin}, {"startQtApplication", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)startQtApplication}, {"quitQtAndroidPlugin", "()V", (void *)quitQtAndroidPlugin}, + {"quitQtCoreApplication", "()V", (void *)quitQtCoreApplication}, {"terminateQt", "()V", (void *)terminateQt}, {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, From d3fd3171ce22f0974d571e91f2df6e2a98368081 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 23 Mar 2017 10:31:55 +0100 Subject: [PATCH 3/4] Annotate more implicit fallthroughs Reduces our number of gcc 7 warnings Change-Id: I792d658cbc11cad15cf45da3a36fc93fcdcc67ea Reviewed-by: Marc Mutz --- src/gui/painting/qdrawhelper.cpp | 16 ++++++------- src/gui/painting/qdrawhelper_sse2.cpp | 24 ++++++++++---------- src/printsupport/kernel/qcups.cpp | 1 + src/widgets/accessible/itemviews.cpp | 1 + src/widgets/graphicsview/qgraphicswidget.cpp | 1 + src/widgets/itemviews/qabstractitemview.cpp | 1 + src/widgets/itemviews/qheaderview.cpp | 1 + src/widgets/itemviews/qlistview.cpp | 2 ++ 8 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 7b3e1b991d..23da42c8cf 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5980,13 +5980,13 @@ inline void qt_memfill_template(T *dest, T color, int count) int n = (count + 7) / 8; switch (count & 0x07) { - case 0: do { *dest++ = color; - case 7: *dest++ = color; - case 6: *dest++ = color; - case 5: *dest++ = color; - case 4: *dest++ = color; - case 3: *dest++ = color; - case 2: *dest++ = color; + case 0: do { *dest++ = color; Q_FALLTHROUGH(); + case 7: *dest++ = color; Q_FALLTHROUGH(); + case 6: *dest++ = color; Q_FALLTHROUGH(); + case 5: *dest++ = color; Q_FALLTHROUGH(); + case 4: *dest++ = color; Q_FALLTHROUGH(); + case 3: *dest++ = color; Q_FALLTHROUGH(); + case 2: *dest++ = color; Q_FALLTHROUGH(); case 1: *dest++ = color; } while (--n > 0); } @@ -5997,7 +5997,7 @@ inline void qt_memfill_template(quint16 *dest, quint16 value, int count) { if (count < 3) { switch (count) { - case 2: *dest++ = value; + case 2: *dest++ = value; Q_FALLTHROUGH(); case 1: *dest = value; } return; diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index edce70d2d0..3013d2cf3e 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -237,11 +237,11 @@ void qt_memfill32(quint32 *dest, quint32 value, int count) { if (count < 7) { switch (count) { - case 6: *dest++ = value; - case 5: *dest++ = value; - case 4: *dest++ = value; - case 3: *dest++ = value; - case 2: *dest++ = value; + case 6: *dest++ = value; Q_FALLTHROUGH(); + case 5: *dest++ = value; Q_FALLTHROUGH(); + case 4: *dest++ = value; Q_FALLTHROUGH(); + case 3: *dest++ = value; Q_FALLTHROUGH(); + case 2: *dest++ = value; Q_FALLTHROUGH(); case 1: *dest = value; } return; @@ -249,16 +249,16 @@ void qt_memfill32(quint32 *dest, quint32 value, int count) const int align = (quintptr)(dest) & 0xf; switch (align) { - case 4: *dest++ = value; --count; - case 8: *dest++ = value; --count; + case 4: *dest++ = value; --count; Q_FALLTHROUGH(); + case 8: *dest++ = value; --count; Q_FALLTHROUGH(); case 12: *dest++ = value; --count; } const int rest = count & 0x3; if (rest) { switch (rest) { - case 3: dest[count - 3] = value; - case 2: dest[count - 2] = value; + case 3: dest[count - 3] = value; Q_FALLTHROUGH(); + case 2: dest[count - 2] = value; Q_FALLTHROUGH(); case 1: dest[count - 1] = value; } } @@ -277,8 +277,8 @@ void qt_memfill32(quint32 *dest, quint32 value, int count) } switch (count128 & 0x3) { - case 3: _mm_stream_si128(dst128++, value128); - case 2: _mm_stream_si128(dst128++, value128); + case 3: _mm_stream_si128(dst128++, value128); Q_FALLTHROUGH(); + case 2: _mm_stream_si128(dst128++, value128); Q_FALLTHROUGH(); case 1: _mm_stream_si128(dst128++, value128); } } @@ -318,7 +318,7 @@ void qt_memfill16(quint16 *dest, quint16 value, int count) { if (count < 3) { switch (count) { - case 2: *dest++ = value; + case 2: *dest++ = value; Q_FALLTHROUGH(); case 1: *dest = value; } return; diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 3c6a6caffa..d655dd09ba 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -101,6 +101,7 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, return localDateTime.toUTC().time().toString(QStringLiteral("HH:mm")); } // else fall through: + Q_FALLTHROUGH(); case QCUPSSupport::NoHold: return QString(); } diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index db5af4fd7c..eec9a0021c 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -310,6 +310,7 @@ bool QAccessibleTable::selectColumn(int column) case QAbstractItemView::SingleSelection: if (view()->selectionBehavior() != QAbstractItemView::SelectColumns && rowCount() > 1) return false; + Q_FALLTHROUGH(); case QAbstractItemView::ContiguousSelection: if ((!column || !view()->selectionModel()->isColumnSelected(column - 1, view()->rootIndex())) && !view()->selectionModel()->isColumnSelected(column + 1, view()->rootIndex())) diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 2adc58e4a4..1ff01b875c 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -1500,6 +1500,7 @@ void QGraphicsWidget::changeEvent(QEvent *event) unsetWindowFrameMargins(); if (d->layout) d->layout->invalidate(); + Q_FALLTHROUGH(); case QEvent::FontChange: update(); updateGeometry(); diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 319cc86c18..e234f56799 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -4035,6 +4035,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC switch (static_cast(event)->key()) { case Qt::Key_Backtab: modifiers = modifiers & ~Qt::ShiftModifier; // special case for backtab + Q_FALLTHROUGH(); case Qt::Key_Down: case Qt::Key_Up: case Qt::Key_Left: diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 1310a060ea..e15fc558bf 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2558,6 +2558,7 @@ void QHeaderView::mouseReleaseEvent(QMouseEvent *e) d->updateSectionIndicator(d->section, pos); break; } // not moving + Q_FALLTHROUGH(); case QHeaderViewPrivate::SelectSections: if (!d->clickableSections) { int section = logicalIndexAt(pos); diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 65421bfb67..0f5e83b83b 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1157,6 +1157,7 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie rect.moveTop(rect.top() - d->viewport->height() + 2 * rect.height()); if (rect.top() < rect.height()) rect.moveTop(rect.height()); + Q_FALLTHROUGH(); case MovePrevious: case MoveUp: while (intersectVector.isEmpty()) { @@ -1185,6 +1186,7 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie rect.moveTop(rect.top() + d->viewport->height() - 2 * rect.height()); if (rect.bottom() > contents.height() - rect.height()) rect.moveBottom(contents.height() - rect.height()); + Q_FALLTHROUGH(); case MoveNext: case MoveDown: while (intersectVector.isEmpty()) { From 781b5a6198aef300bb8f1fdc6681d4756001d3b4 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Fri, 24 Mar 2017 13:51:36 +0100 Subject: [PATCH 4/4] Fix generation of gradient shader function in PDF Add the missing endobj tag for the shader function object. Change-Id: Ieb3cfa5a5d0e27d04164a80b028d41371507fb94 Reviewed-by: Lars Knoll --- src/gui/painting/qpdf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 84e18a64dd..7b53966f81 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -2073,7 +2073,8 @@ int QPdfEnginePrivate::createShadingFunction(const QGradient *gradient, int from for (int i = 0; i < gradientBounds.size(); ++i) s << gradientBounds.at(i).function << "0 R "; s << "]\n" - ">>\n"; + ">>\n" + "endobj\n"; write(data); } else { function = functions.at(0);