From 9ccc3070dd284947fc68e9f7964b6bd3ed8123ed Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 22 Mar 2017 09:49:29 +0100 Subject: Build fix for -no-feature-textedit After change e54356151c, qwidgettextcontrol_p.h does not always include qtextedit_p.h Change-Id: If7b54384d644fda4985eb1966d6773ee393ba107 Reviewed-by: Lars Knoll --- src/widgets/widgets/qlineedit.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 0a35bae200..27dd186f04 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -64,6 +64,8 @@ #include "qdebug.h" #include "qtextedit.h" #include +#include + #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif -- cgit v1.2.3 From 0ec871dac839ea2b2661f1333dad39534e83f19d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 23 Mar 2017 17:13:10 +0100 Subject: Introduce QInputControl::isCommonTextEditShortcut For handling ShortcutOverride events in text-edit-like controls one must know if a key event matches a common text edit short cut. The code that was formerly in QWidgetTextControl is now moved into QInputControl::isCommonTextEditShortcut to remove duplicated code in QtQuick and to avoid adding adding a third duplicate in QtWebEngine. Task-number: QTBUG-59053 Change-Id: I18723bb0224acd33c8ea4a8d0a601bb5e274a7a9 Reviewed-by: Simon Hausmann Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qinputcontrol.cpp | 51 ++++++++++++++++++++++++++++++ src/gui/text/qinputcontrol_p.h | 1 + src/widgets/widgets/qwidgettextcontrol.cpp | 46 +-------------------------- 3 files changed, 53 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/gui/text/qinputcontrol.cpp b/src/gui/text/qinputcontrol.cpp index 2f7dcfcd2b..3381fdb673 100644 --- a/src/gui/text/qinputcontrol.cpp +++ b/src/gui/text/qinputcontrol.cpp @@ -85,4 +85,55 @@ bool QInputControl::isAcceptableInput(const QKeyEvent *event) const return false; } +bool QInputControl::isCommonTextEditShortcut(const QKeyEvent *ke) +{ + if (ke->modifiers() == Qt::NoModifier + || ke->modifiers() == Qt::ShiftModifier + || ke->modifiers() == Qt::KeypadModifier) { + if (ke->key() < Qt::Key_Escape) { + return true; + } else { + switch (ke->key()) { + case Qt::Key_Return: + case Qt::Key_Enter: + case Qt::Key_Delete: + case Qt::Key_Home: + case Qt::Key_End: + case Qt::Key_Backspace: + case Qt::Key_Left: + case Qt::Key_Right: + case Qt::Key_Up: + case Qt::Key_Down: + case Qt::Key_Tab: + return true; + default: + break; + } + } +#if QT_CONFIG(shortcut) + } else if (ke->matches(QKeySequence::Copy) + || ke->matches(QKeySequence::Paste) + || ke->matches(QKeySequence::Cut) + || ke->matches(QKeySequence::Redo) + || ke->matches(QKeySequence::Undo) + || ke->matches(QKeySequence::MoveToNextWord) + || ke->matches(QKeySequence::MoveToPreviousWord) + || ke->matches(QKeySequence::MoveToStartOfDocument) + || ke->matches(QKeySequence::MoveToEndOfDocument) + || ke->matches(QKeySequence::SelectNextWord) + || ke->matches(QKeySequence::SelectPreviousWord) + || ke->matches(QKeySequence::SelectStartOfLine) + || ke->matches(QKeySequence::SelectEndOfLine) + || ke->matches(QKeySequence::SelectStartOfBlock) + || ke->matches(QKeySequence::SelectEndOfBlock) + || ke->matches(QKeySequence::SelectStartOfDocument) + || ke->matches(QKeySequence::SelectEndOfDocument) + || ke->matches(QKeySequence::SelectAll) + ) { + return true; +#endif + } + return false; +} + QT_END_NAMESPACE diff --git a/src/gui/text/qinputcontrol_p.h b/src/gui/text/qinputcontrol_p.h index e5709b5e54..b4c1ca8f8f 100644 --- a/src/gui/text/qinputcontrol_p.h +++ b/src/gui/text/qinputcontrol_p.h @@ -69,6 +69,7 @@ public: explicit QInputControl(Type type, QObject *parent = nullptr); bool isAcceptableInput(const QKeyEvent *event) const; + static bool isCommonTextEditShortcut(const QKeyEvent *ke); protected: explicit QInputControl(Type type, QObjectPrivate &dd, QObject *parent = nullptr); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index dacb4806ce..714f8bfda8 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1141,52 +1141,8 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget case QEvent::ShortcutOverride: if (d->interactionFlags & Qt::TextEditable) { QKeyEvent* ke = static_cast(e); - if (ke->modifiers() == Qt::NoModifier - || ke->modifiers() == Qt::ShiftModifier - || ke->modifiers() == Qt::KeypadModifier) { - if (ke->key() < Qt::Key_Escape) { - ke->accept(); - } else { - switch (ke->key()) { - case Qt::Key_Return: - case Qt::Key_Enter: - case Qt::Key_Delete: - case Qt::Key_Home: - case Qt::Key_End: - case Qt::Key_Backspace: - case Qt::Key_Left: - case Qt::Key_Right: - case Qt::Key_Up: - case Qt::Key_Down: - case Qt::Key_Tab: - ke->accept(); - default: - break; - } - } -#ifndef QT_NO_SHORTCUT - } else if (ke == QKeySequence::Copy - || ke == QKeySequence::Paste - || ke == QKeySequence::Cut - || ke == QKeySequence::Redo - || ke == QKeySequence::Undo - || ke == QKeySequence::MoveToNextWord - || ke == QKeySequence::MoveToPreviousWord - || ke == QKeySequence::MoveToStartOfDocument - || ke == QKeySequence::MoveToEndOfDocument - || ke == QKeySequence::SelectNextWord - || ke == QKeySequence::SelectPreviousWord - || ke == QKeySequence::SelectStartOfLine - || ke == QKeySequence::SelectEndOfLine - || ke == QKeySequence::SelectStartOfBlock - || ke == QKeySequence::SelectEndOfBlock - || ke == QKeySequence::SelectStartOfDocument - || ke == QKeySequence::SelectEndOfDocument - || ke == QKeySequence::SelectAll - ) { + if (isCommonTextEditShortcut(ke)) ke->accept(); -#endif - } } break; default: -- cgit v1.2.3 From 41750492db58ca30a70a685cd6a4ee180c0b4959 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Thu, 16 Mar 2017 14:48:49 +0300 Subject: 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(-) (limited to 'src') 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()) { -- cgit v1.2.3 From 1ab60b0430f2b57418ee4954fcfa43e1e14766fc Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 13 Dec 2016 10:02:15 +0200 Subject: Make sure we quit qt when the service is destroyed Task-number: QTBUG-58471 Change-Id: I37f162717f57323136811a8f80d53e3c3b7d6f22 Reviewed-by: Christian Stromme --- src/android/jar/src/org/qtproject/qt5/android/QtNative.java | 1 + .../jar/src/org/qtproject/qt5/android/QtServiceDelegate.java | 2 +- src/plugins/platforms/android/androidjnimain.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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}, -- cgit v1.2.3 From d3fd3171ce22f0974d571e91f2df6e2a98368081 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 23 Mar 2017 10:31:55 +0100 Subject: 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(-) (limited to 'src') 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()) { -- cgit v1.2.3 From 52767b8ee754f97abe42e9cdc3bcf69365a401fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 27 Mar 2017 17:34:48 +0200 Subject: macOS: Disassociate NSView from contentView when switching NSWindows When a NSView is the contentView of a NSWindow, it still has a superview, in this case an NSThemeFrame, and the theme frame is the view that retains the view, not the contentView property of the window. Unfortunately, when a view is removed from the NSThemeFrame by means of [NSView removeFromSuperview], or indirectly via [NSView addSubview:], AppKit does not update the contentView property of the corresponding NSWindow. The result is that the NSView might be deallocated while the NSWindow still is around, with a stale contentView property. To work around this we explicitly disassociate the view from the NSWindow when we know that we are going to release the NSWindow. This will take care of both resetting the property to nil, and remove the view from the NSThemeFrame superview. Task-number: QTBUG-59734 Change-Id: I1111d492f52fe5bdf86bbae071421f6a8a7a38b8 Reviewed-by: Timur Pocheptsov Reviewed-by: Jake Petroules --- src/plugins/platforms/cocoa/qcocoawindow.mm | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index cfe829905c..f6606745f1 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1613,6 +1613,13 @@ void QCocoaWindow::recreateWindowIfNeeded() [m_nsWindow closeAndRelease]; if (isChildNSWindow()) [m_view.window.parentWindow removeChildWindow:m_view.window]; + if (isContentView()) { + // We explicitly disassociate m_view from the window's contentView, + // as AppKit does not automatically do this in response to removing + // the view from the NSThemeFrame subview list, so we might end up + // with a NSWindow contentView pointing to a deallocated NSView. + m_view.window.contentView = nil; + } m_nsWindow = 0; } -- cgit v1.2.3 From e0e717d06a9da75474c6550e163d0d2ca18c258a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 24 Mar 2017 13:01:41 +0100 Subject: Fix crash when QUrl::from{NS/CF}URL() was passed a nullptr Change-Id: Ib193447c4a91dd3d08746e97727f7d4764f33d80 Reviewed-by: Jake Petroules Reviewed-by: Timur Pocheptsov Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcore_foundation.mm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm index 0e69f69a85..56eabc4b8c 100644 --- a/src/corelib/kernel/qcore_foundation.mm +++ b/src/corelib/kernel/qcore_foundation.mm @@ -328,6 +328,8 @@ NSUUID *QUuid::toNSUUID() const */ QUrl QUrl::fromCFURL(CFURLRef url) { + if (!url) + return QUrl(); return QUrl(QString::fromCFString(CFURLGetString(url))); } @@ -355,6 +357,8 @@ CFURLRef QUrl::toCFURL() const */ QUrl QUrl::fromNSURL(const NSURL *url) { + if (!url) + return QUrl(); return QUrl(QString::fromNSString([url absoluteString])); } -- cgit v1.2.3 From ed96363d56b912dc828537549a8028c8ad4ea3bb Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 27 Mar 2017 22:51:46 +0300 Subject: QMimeGlobPattern: init all members only once ... by initializer list. Change-Id: I39d2f933dac171273f500963eb47ffa9165978de Reviewed-by: Thiago Macieira --- src/corelib/mimetypes/qmimeglobpattern_p.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index c8b70464fd..21332e71bc 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -83,11 +83,9 @@ public: static const unsigned MinWeight = 1; explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType, unsigned theWeight = DefaultWeight, Qt::CaseSensitivity s = Qt::CaseInsensitive) : - m_pattern(thePattern), m_mimeType(theMimeType), m_weight(theWeight), m_caseSensitivity(s) + m_pattern(s == Qt::CaseInsensitive ? thePattern.toLower() : thePattern), + m_mimeType(theMimeType), m_weight(theWeight), m_caseSensitivity(s) { - if (s == Qt::CaseInsensitive) { - m_pattern = m_pattern.toLower(); - } } void swap(QMimeGlobPattern &other) Q_DECL_NOTHROW -- cgit v1.2.3 From a6bbaa08bfb37a77afa9ee8077cd51f74dd9ee9c Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 23 Mar 2017 09:34:48 +0100 Subject: ANGLE: remove dead MinGW code from common.pri Change-Id: I09a9d0553f00a3b04d084300cb6e2b9f5211913e Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen --- src/angle/src/common/common.pri | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'src') diff --git a/src/angle/src/common/common.pri b/src/angle/src/common/common.pri index 3da59c61e2..7305362d86 100644 --- a/src/angle/src/common/common.pri +++ b/src/angle/src/common/common.pri @@ -30,29 +30,11 @@ winrt|msvc { error("Cannot determine DirectX SDK location. Please set DXSDK_DIR environment variable.") } - DXINC_DIR = $${DX_DIR}Include - contains(QT_ARCH, x86_64) { - DXLIB_DIR = $${DX_DIR}Lib\\x64 - } else { - DXLIB_DIR = $${DX_DIR}Lib\\x86 - } - equals(QMAKE_TARGET.arch, x86_64) { FXC = \"$${DX_DIR}Utilities\\bin\\x64\\fxc.exe\" } else { FXC = \"$${DX_DIR}Utilities\\bin\\x86\\fxc.exe\" } - - msvc { - # Unfortunately MinGW cannot use the DirectX headers from the DX SDK because d3d11shader.h uses - # buffer annotation macros (eg: __out, __in) which are not defined in the MinGW copy of - # specstrings_strict.h - INCLUDEPATH += $$DXINC_DIR - - # Similarly we want the MinGW linker to use the import libraries shipped with the compiler - # instead of those from the SDK which cause a crash on startup. - LIBS_PRIVATE += -L$$DXLIB_DIR - } } static: DEFINES *= LIBGLESV2_EXPORT_H_ ANGLE_EXPORT= -- cgit v1.2.3 From 781b5a6198aef300bb8f1fdc6681d4756001d3b4 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Fri, 24 Mar 2017 13:51:36 +0100 Subject: 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(-) (limited to 'src') 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); -- cgit v1.2.3 From 18d6c82299d51aacca55465dd1a2066a93440618 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 27 Mar 2017 22:44:22 +0300 Subject: Prefer rvalue versions of toLower() and toUpper() ... to re-use existing buffers. Change-Id: Ib2bc938f1cf0451c1dbc012b3db022b878e987cb Reviewed-by: Thiago Macieira --- src/corelib/io/qsettings_mac.cpp | 2 +- src/corelib/tools/qlocale.cpp | 6 +++--- src/gui/kernel/qkeysequence.cpp | 2 +- src/gui/text/qcssparser.cpp | 4 ++-- src/gui/text/qtextdocument.cpp | 2 +- src/gui/text/qtexthtmlparser.cpp | 8 ++++---- src/plugins/platforms/windows/qwindowstheme.cpp | 4 ++-- src/plugins/sqldrivers/psql/qsql_psql.cpp | 8 ++++---- src/widgets/util/qcompleter.cpp | 8 ++++---- src/widgets/widgets/qsplitter.cpp | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index e4631bad12..39777e6c90 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -419,7 +419,7 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString & curPos = nextDot + 1; } javaPackageName.prepend(domainName.midRef(curPos)); - javaPackageName = javaPackageName.toLower(); + javaPackageName = std::move(javaPackageName).toLower(); if (curPos == 0) javaPackageName.prepend(QLatin1String("com.")); suiteId = javaPackageName; diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 59952bd107..bde4bf553e 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2891,7 +2891,7 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q num_str.prepend(QLatin1Char(' ')); if (flags & QLocaleData::CapitalEorX) - num_str = num_str.toUpper(); + num_str = std::move(num_str).toUpper(); return num_str; } @@ -2973,7 +2973,7 @@ QString QLocaleData::longLongToString(const QChar zero, const QChar group, } if (flags & CapitalEorX) - num_str = num_str.toUpper(); + num_str = std::move(num_str).toUpper(); if (base == 16 && (flags & ShowBase)) num_str.prepend(QLatin1String(flags & UppercaseBase ? "0X" : "0x")); @@ -3052,7 +3052,7 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group, } if (flags & CapitalEorX) - num_str = num_str.toUpper(); + num_str = std::move(num_str).toUpper(); if (base == 16 && flags & ShowBase) num_str.prepend(QLatin1String(flags & UppercaseBase ? "0X" : "0x")); diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index a6bc7d4d9c..20eac2ed15 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1183,7 +1183,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence QString keyName(tran == 0 ? QCoreApplication::translate("QShortcut", keyname[i].name) : QString::fromLatin1(keyname[i].name)); - if (accelRef == keyName.toLower()) { + if (accelRef == std::move(keyName).toLower()) { ret |= keyname[i].key; found = true; break; diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index a0438bd458..9670f24b1e 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1822,7 +1822,7 @@ void StyleSheet::buildIndexes(Qt::CaseSensitivity nameCaseSensitivity) nr.order = i; QString name = sel.elementName; if (nameCaseSensitivity == Qt::CaseInsensitive) - name=name.toLower(); + name = std::move(name).toLower(); nameIndex.insert(name, nr); } else { universalsSelectors += selector; @@ -2027,7 +2027,7 @@ QVector StyleSelector::styleRulesForNode(NodePtr node) for (int i = 0; i < names.count(); i++) { QString name = names.at(i); if (nameCaseSensitivity == Qt::CaseInsensitive) - name = name.toLower(); + name = std::move(name).toLower(); QMultiHash::const_iterator it = styleSheet.nameIndex.constFind(name); while (it != styleSheet.nameIndex.constEnd() && it.key() == name) { matchRule(node, it.value(), styleSheet.origin, styleSheet.depth, &weightedRules); diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 6074917087..f8215f92e9 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -133,7 +133,7 @@ bool Qt::mightBeRichText(const QString& text) return false; // that's not a tag } #ifndef QT_NO_TEXTHTMLPARSER - return QTextHtmlParser::lookupElement(tag.toLower()) != -1; + return QTextHtmlParser::lookupElement(std::move(tag).toLower()) != -1; #else return false; #endif // QT_NO_TEXTHTMLPARSER diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 269e505a56..8471c55e5f 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1525,7 +1525,7 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) } else if (value == QLatin1String("I")) { node->listStyle = QTextListFormat::ListUpperRoman; } else { - value = value.toLower(); + value = std::move(value).toLower(); if (value == QLatin1String("square")) node->listStyle = QTextListFormat::ListSquare; else if (value == QLatin1String("disc")) @@ -1636,7 +1636,7 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) node->parseStyleAttribute(value, resourceProvider); #endif } else if (key == QLatin1String("align")) { - value = value.toLower(); + value = std::move(value).toLower(); bool alignmentSet = true; if (value == QLatin1String("left")) @@ -1664,7 +1664,7 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) } } } else if (key == QLatin1String("valign")) { - value = value.toLower(); + value = std::move(value).toLower(); if (value == QLatin1String("top")) node->charFormat.setVerticalAlignment(QTextCharFormat::AlignTop); else if (value == QLatin1String("middle")) @@ -1672,7 +1672,7 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes) else if (value == QLatin1String("bottom")) node->charFormat.setVerticalAlignment(QTextCharFormat::AlignBottom); } else if (key == QLatin1String("dir")) { - value = value.toLower(); + value = std::move(value).toLower(); if (value == QLatin1String("ltr")) node->blockFormat.setLayoutDirection(Qt::LeftToRight); else if (value == QLatin1String("rtl")) diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 4ae1a751e9..3e2cb5e9e9 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -815,14 +815,14 @@ QString QWindowsFileIconEngine::cacheKey() const // Return "" for .exe, .lnk and .ico extensions. // It is faster to just look at the file extensions; // avoiding slow QFileInfo::isExecutable() (QTBUG-13182) - const QString &suffix = fileInfo().suffix(); + QString suffix = fileInfo().suffix(); if (!suffix.compare(QLatin1String("exe"), Qt::CaseInsensitive) || !suffix.compare(QLatin1String("lnk"), Qt::CaseInsensitive) || !suffix.compare(QLatin1String("ico"), Qt::CaseInsensitive)) { return QString(); } return QLatin1String("qt_.") - + (suffix.isEmpty() ? fileInfo().fileName() : suffix.toUpper()); // handle "Makefile" ;) + + (suffix.isEmpty() ? fileInfo().fileName() : std::move(suffix).toUpper()); // handle "Makefile" ;) } QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon::State) diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 19de9a8003..a54ceefb6f 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1073,12 +1073,12 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const if (isIdentifierEscaped(tbl, QSqlDriver::TableName)) tbl = stripDelimiters(tbl, QSqlDriver::TableName); else - tbl = tbl.toLower(); + tbl = std::move(tbl).toLower(); if (isIdentifierEscaped(schema, QSqlDriver::TableName)) schema = stripDelimiters(schema, QSqlDriver::TableName); else - schema = schema.toLower(); + schema = std::move(schema).toLower(); switch(d->pro) { case QPSQLDriver::Version6: @@ -1153,12 +1153,12 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const if (isIdentifierEscaped(tbl, QSqlDriver::TableName)) tbl = stripDelimiters(tbl, QSqlDriver::TableName); else - tbl = tbl.toLower(); + tbl = std::move(tbl).toLower(); if (isIdentifierEscaped(schema, QSqlDriver::TableName)) schema = stripDelimiters(schema, QSqlDriver::TableName); else - schema = schema.toLower(); + schema = std::move(schema).toLower(); QString stmt; switch(d->pro) { diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index e8f23f08bc..5a31eb4e52 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -493,7 +493,7 @@ QMatchData QCompletionEngine::filterHistory() bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatchData *hint) { if (c->cs == Qt::CaseInsensitive) - part = part.toLower(); + part = std::move(part).toLower(); const CacheItem& map = cache[parent]; @@ -512,7 +512,7 @@ bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatc bool QCompletionEngine::lookupCache(QString part, const QModelIndex& parent, QMatchData *m) { if (c->cs == Qt::CaseInsensitive) - part = part.toLower(); + part = std::move(part).toLower(); const CacheItem& map = cache[parent]; if (!map.contains(part)) return false; @@ -548,7 +548,7 @@ void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, con } if (c->cs == Qt::CaseInsensitive) - part = part.toLower(); + part = std::move(part).toLower(); cache[parent][part] = m; } @@ -558,7 +558,7 @@ QIndexMapper QSortedModelEngine::indexHint(QString part, const QModelIndex& pare const QAbstractItemModel *model = c->proxy->sourceModel(); if (c->cs == Qt::CaseInsensitive) - part = part.toLower(); + part = std::move(part).toLower(); const CacheItem& map = cache[parent]; diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index e6332293e4..c55b943b5a 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1798,7 +1798,7 @@ QTextStream& operator>>(QTextStream& ts, QSplitter& splitter) QString line = ts.readLine(); line = line.simplified(); line.replace(QLatin1Char(' '), QString()); - line = line.toUpper(); + line = std::move(line).toUpper(); splitter.restoreState(line.toLatin1()); return ts; -- cgit v1.2.3 From 81b5aa792f84747962cb05e0cf11708e4466bf30 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 28 Mar 2017 11:18:13 +0200 Subject: QCocoaWindow - fix a compilation error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clang does not like Q_FALLTHROUGH in 'default' label, the diagnostics is: 'fallthrough annotation does not directly precede switch label'. Accodring to their docs: "The fallthrough (or clang::fallthrough) attribute is used to annotate intentional fall-through between switch labels. It can only be applied to a null statement placed at a point of execution between any statement and the next switch label." - obviously, there is no 'next switch label' in our case. Change-Id: Ia7dba4cb965a85d229d44b04b69633a8f07d4a0c Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.mm | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f6606745f1..989adcc5b0 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1867,8 +1867,7 @@ void QCocoaWindow::applyWindowState(Qt::WindowState newState) // the new state. return; } - default: - Q_FALLTHROUGH(); + default:; } // Then we apply the new state if needed @@ -1886,12 +1885,8 @@ void QCocoaWindow::applyWindowState(Qt::WindowState newState) [m_nsWindow miniaturize:sender]; break; case Qt::WindowNoState: - switch (windowState()) { - case Qt::WindowMaximized: + if (windowState() == Qt::WindowMaximized) toggleMaximized(); - default: - Q_FALLTHROUGH(); - } break; default: Q_UNREACHABLE(); -- cgit v1.2.3 From bae0c4c11a6dda52e5d1e9d6d7d0de3ebd47642b Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Sun, 19 Mar 2017 14:19:22 +0300 Subject: Avoid expensive QHash::values() calls qcocoawindow.mm: we can replace QHash::values() with std::vector since CoW is needless here and std::vector is more cache-friendly. Also replace foreach with range-based for. qitemeditorfactory.cpp: QHash::values() is used as auxiliary container to create QSet. Replace it with std::vector since CoW is needless here and apply sort-unique idiom to remove duplicates. Also avoid needless allocations. Change-Id: If34c7016977ceb7fab68e9298bf2e1944af79139 Reviewed-by: Marc Mutz --- src/plugins/platforms/cocoa/qcocoawindow.mm | 6 ++++-- src/widgets/itemviews/qitemeditorfactory.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 989adcc5b0..d531003abe 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -58,6 +58,8 @@ #include +#include + enum { defaultWindowWidth = 160, defaultWindowHeight = 160 @@ -2068,10 +2070,10 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window) } // Find consecutive registered border areas, starting from the top. - QList ranges = m_contentBorderAreas.values(); + std::vector ranges(m_contentBorderAreas.cbegin(), m_contentBorderAreas.cend()); std::sort(ranges.begin(), ranges.end()); int effectiveTopContentBorderThickness = m_topContentBorderThickness; - foreach (BorderRange range, ranges) { + for (BorderRange range : ranges) { // Skip disiabled ranges (typically hidden tool bars) if (!m_enabledContentBorderAreas.value(range.identifier, false)) continue; diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index c044d37575..c535cf5f9e 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -55,6 +55,7 @@ #include #include +#include #include QT_BEGIN_NAMESPACE @@ -191,9 +192,11 @@ QByteArray QItemEditorFactory::valuePropertyName(int userType) const QItemEditorFactory::~QItemEditorFactory() { //we make sure we delete all the QItemEditorCreatorBase - //this has to be done only once, hence the QSet - QSet set = creatorMap.values().toSet(); - qDeleteAll(set); + //this has to be done only once, hence the sort-unique idiom + std::vector creators(creatorMap.cbegin(), creatorMap.cend()); + std::sort(creators.begin(), creators.end()); + const auto it = std::unique(creators.begin(), creators.end()); + qDeleteAll(creators.begin(), it); } /*! -- cgit v1.2.3 From dd385741605df2dd0cd977ebd8cd49cbf5d90271 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 17 Mar 2017 15:23:37 +0100 Subject: Switch to RGB(A|X)8888[_Premultiplied] for QOpenGLFBO readbacks on GLES Instead of the never-ending blacklisting of "broken" drivers, simply switch to always choosing a byte ordered QImage format with OpenGL ES, and keep on using the (one and only) spec-mandated GL_RGBA/GL_UNSIGNED_BYTE combo. There is nothing broken with not supporting BGRA for glReadPixels even when GL_EXT_read_format_bgra (an out of date, pre-2.0 extension that got folded into the spec to begin with) is present. We do not have a good way to tell if BGRA_EXT is supported for glReadPixels or not, so just skip the whole problem altogether. Task-number: QTBUG-59283 Task-number: QTBUG-59303 Change-Id: I9f0605380923bd3b3ffdeb80f5c172d3e4cc7927 Reviewed-by: Allan Sandfeld Jensen --- src/gui/opengl/qopenglframebufferobject.cpp | 43 ++++++----------------------- 1 file changed, 9 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 98ff49ea31..b56bcd0866 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1282,35 +1282,11 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ return img; } -#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN - // Without GL_UNSIGNED_INT_8_8_8_8_REV, GL_BGRA only makes sense on little endian. - const bool has_bgra_ext = context->isOpenGLES() - ? context->hasExtension(QByteArrayLiteral("GL_EXT_read_format_bgra")) - : context->hasExtension(QByteArrayLiteral("GL_EXT_bgra")); - -#ifndef Q_OS_IOS - const char *renderer = reinterpret_cast(funcs->glGetString(GL_RENDERER)); - const char *ver = reinterpret_cast(funcs->glGetString(GL_VERSION)); - - // Blacklist GPU chipsets that have problems with their BGRA support. - const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0 - && ::strstr(ver, "1.3") != 0) || - (qstrcmp(renderer, "Mali-T760") == 0 - && ::strstr(ver, "3.1") != 0) || - (qstrcmp(renderer, "Mali-T720") == 0 - && ::strstr(ver, "3.1") != 0) || - qstrcmp(renderer, "PowerVR SGX 554") == 0; -#else - const bool blackListed = true; -#endif - const bool supports_bgra = has_bgra_ext && !blackListed; + // For OpenGL ES stick with the byte ordered format / RGBA readback format + // since that is the only spec mandated way. (also, skip the + // GL_IMPLEMENTATION_COLOR_READ_FORMAT mess since there is nothing saying a + // BGRA capable impl would return BGRA from there) - if (supports_bgra) { - QImage img(size, include_alpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); - funcs->glReadPixels(0, 0, w, h, GL_BGRA, GL_UNSIGNED_BYTE, img.bits()); - return img; - } -#endif QImage rgbaImage(size, include_alpha ? QImage::Format_RGBA8888_Premultiplied : QImage::Format_RGBX8888); funcs->glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, rgbaImage.bits()); return rgbaImage; @@ -1362,8 +1338,11 @@ Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, If used together with QOpenGLPaintDevice, \a flipped should be the opposite of the value of QOpenGLPaintDevice::paintFlipped(). - The returned image has a format of premultiplied ARGB32 or RGB32. The latter is used - only when internalTextureFormat() is set to \c GL_RGB. + The returned image has a format of premultiplied ARGB32 or RGB32. The latter + is used only when internalTextureFormat() is set to \c GL_RGB. Since Qt 5.2 + the function will fall back to premultiplied RGBA8888 or RGBx8888 when + reading to (A)RGB32 is not supported, and this includes OpenGL ES. Since Qt + 5.4 an A2BGR30 image is returned if the internal format is RGB10_A2. If the rendering in the framebuffer was not done with premultiplied alpha in mind, create a wrapper QImage with a non-premultiplied format. This is necessary before @@ -1376,10 +1355,6 @@ Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, QImage image(fboImage.constBits(), fboImage.width(), fboImage.height(), QImage::Format_ARGB32); \endcode - Since Qt 5.2 the function will fall back to premultiplied RGBA8888 or RGBx8888 when - reading to (A)RGB32 is not supported. Since 5.4 an A2BGR30 image is returned if the - internal format is RGB10_A2. - For multisampled framebuffer objects the samples are resolved using the \c{GL_EXT_framebuffer_blit} extension. If the extension is not available, the contents of the returned image is undefined. -- cgit v1.2.3 From 22a414ab3d988b8819f5738e740caa775ad34697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 27 Mar 2017 18:41:39 +0200 Subject: macOS: Remove workaround for default-sized NSViews The workaround introduced in 38a55c7 to explicitly call viewDidChangeFrame() was not ideal for a multitude of reasons. Instead we can just initialize the NSView with a NSZeroRect frame, which will ensure that whatever geometry we set from the Qt side will result in geometry change and expose events. The only case where we will not receive an expose event is if the QWindow is requested to be 0x0 sized, but that wouldn't warrant an expose event anyways. Also, it's not possible to initialize a QWindow to 0x0 from the Qt side, as that will trigger QPlatformWindow::initialGeometry() to pick the default size (160x160 in the case of macOS). Task-number: QTBUG-58963 Change-Id: Ia84de7edcfdf26b90e4e93186fabe8b5c7382caa Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 7 ------- src/plugins/platforms/cocoa/qnsview.h | 1 - src/plugins/platforms/cocoa/qnsview.mm | 8 +------- 3 files changed, 1 insertion(+), 15 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index d531003abe..e9bcaa8f41 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1645,13 +1645,6 @@ void QCocoaWindow::recreateWindowIfNeeded() [m_nsWindow setContentView:m_view]; [m_view release]; [m_view setPostsFrameChangedNotifications:YES]; - // QTBUG-58963 - // viewDidChangeFrame() should be called for each window automatically at this point because it is - // registered with Q_NOTIFICATION_HANDLER(NSViewFrameDidChangeNotification); - // The corner case when it's not called and we need to make a manual geometry update is when window's - // size is not specified explicitly but minimumSize is set and matches to the size NSView was created with. - if (QSizeF::fromCGSize(m_view.frame.size) == [QNSView defaultViewSize]) - viewDidChangeFrame(); } } diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index a05bd66890..75a508370f 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -88,7 +88,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); QSet m_acceptedKeyDowns; } -+ (QSizeF)defaultViewSize; - (id)init; - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow; #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 967271be9c..296b6a28cc 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -140,8 +140,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (id) init { - self = [super initWithFrame : NSMakeRect(0, 0, [[self class] defaultViewSize].width(), [[self class] defaultViewSize].height())]; - if (self) { + if (self = [super initWithFrame:NSZeroRect]) { m_backingStore = 0; m_maskImage = 0; m_shouldInvalidateWindowShadow = false; @@ -189,11 +188,6 @@ static bool _q_dontOverrideCtrlLMB = false; [super dealloc]; } -+ (QSizeF)defaultViewSize -{ - return QSizeF(300.0, 300.0); -} - - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow { self = [self init]; -- cgit v1.2.3 From 3c66df6400e364ead47f13a1fbdd5d4c49adbb46 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 21 Feb 2017 10:17:53 +0100 Subject: Core: Replace LGPL21 with LGPL license header Also use canonical contact url. Change-Id: I43f8c6a2c4949ee0e054045bccc17d82575b072c Reviewed-by: Thiago Macieira Reviewed-by: Jani Heikkinen --- src/corelib/global/qglobal_p.h | 32 ++++++++++++++++++------------ src/corelib/kernel/qdeadlinetimer.cpp | 32 ++++++++++++++++++------------ src/corelib/kernel/qdeadlinetimer.h | 32 ++++++++++++++++++------------ src/corelib/statemachine/qfinalstate_p.h | 34 +++++++++++++++++++------------- 4 files changed, 77 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h index b8f9e5fbf7..b1d2836783 100644 --- a/src/corelib/global/qglobal_p.h +++ b/src/corelib/global/qglobal_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** ** Copyright (C) 2015 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index ad549dcd7b..a2ec813f11 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** ** Copyright (C) 2016 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h index aa0f735fcc..ddab0191ad 100644 --- a/src/corelib/kernel/qdeadlinetimer.h +++ b/src/corelib/kernel/qdeadlinetimer.h @@ -1,31 +1,37 @@ /**************************************************************************** ** ** Copyright (C) 2016 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/src/corelib/statemachine/qfinalstate_p.h b/src/corelib/statemachine/qfinalstate_p.h index 57de703fe9..65598f6c19 100644 --- a/src/corelib/statemachine/qfinalstate_p.h +++ b/src/corelib/statemachine/qfinalstate_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** -- cgit v1.2.3 From cea75a2a6557947d44135c1ca05027c4e0202795 Mon Sep 17 00:00:00 2001 From: Kimmo Ollila Date: Sun, 26 Mar 2017 20:54:46 +0300 Subject: Add GHS internal id TOOLS-26637 to bug workaround comments Change-Id: I653e0b16e08e6167891603f47298554a87352765 Reviewed-by: Marc Mutz Reviewed-by: Lars Knoll --- src/widgets/widgets/qlineedit_p.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 68be82c71d..7c5ba79cb6 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -536,7 +536,8 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE // If there is a 'before' action, it takes preference // There's a bug in GHS compiler that causes internal error on the following code. - // The affected GHS compiler versions are 2016.5.4 and 2017.1 + // The affected GHS compiler versions are 2016.5.4 and 2017.1. GHS internal reference + // to track the progress of this issue is TOOLS-26637. // This temporary workaround allows to compile with GHS toolchain and should be // removed when GHS provides a patch to fix the compiler issue. -- cgit v1.2.3 From ff259bffe6b1d09dfec2f56f6c9a4a326ff8e98a Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 28 Mar 2017 07:28:58 +0300 Subject: Use case-insensitive compare more ... to avoid allocations. Change-Id: I5993633d1509495ff6ce3a11274a53504aac7c5e Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/io/qloggingregistry.cpp | 2 +- src/gui/text/qcssparser.cpp | 2 +- src/network/access/qftp.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 4f7bc95330..ff865dc9a1 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -215,7 +215,7 @@ void QLoggingSettingsParser::setContent(QTextStream &stream) continue; } - if (_section.toLower() == QLatin1String("rules")) { + if (_section.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0) { int equalPos = line.indexOf(QLatin1Char('=')); if (equalPos != -1) { if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 9670f24b1e..64adeaa260 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -2748,7 +2748,7 @@ bool Parser::testAndParseUri(QString *uri) index = rewind; return false; } - if (name.toLower() != QLatin1String("url")) { + if (name.compare(QLatin1String("url"), Qt::CaseInsensitive) != 0) { index = rewind; return false; } diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index e9cb3aa498..47579ba654 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -574,7 +574,7 @@ static void _q_parseDosDir(const QStringList &tokens, const QString &userName, Q QString name = tokens.at(3); info->setName(name); - info->setSymLink(name.toLower().endsWith(QLatin1String(".lnk"))); + info->setSymLink(name.endsWith(QLatin1String(".lnk"), Qt::CaseInsensitive)); if (tokens.at(2) == QLatin1String("")) { info->setFile(false); -- cgit v1.2.3 From 78f761318a20f320e04a8439101d429136fe3d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Tue, 28 Mar 2017 17:12:44 +0200 Subject: Set the mode for the GTK3 file chooser also in selectFile If the mode is not GTK_FILE_CHOOSER_ACTION_SAVE or GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER , a GTK warning will be generated which makes Qt WebEngine's Glib error handler assert. Doing so only when showing the dialog is too late. This patch moves the actual file selection to a private method that can be called from both selectFile and applyOptions in order to prevent overwriting the file chooser action potentially multiple times. Task-number: QTBUG-59692 Change-Id: Ied939248cdc3a0b4c9e8239ab61ba617a46b8496 Reviewed-by: J-P Nurmi --- .../platformthemes/gtk3/qgtk3dialoghelpers.cpp | 19 ++++++++++++++++--- src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index 8b6ec31400..b1821ebbd2 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -315,6 +315,12 @@ QUrl QGtk3FileDialogHelper::directory() const } void QGtk3FileDialogHelper::selectFile(const QUrl &filename) +{ + setFileChooserAction(); + selectFileInternal(filename); +} + +void QGtk3FileDialogHelper::selectFileInternal(const QUrl &filename) { GtkDialog *gtkDialog = d->gtkDialog(); if (options()->acceptMode() == QFileDialogOptions::AcceptSave) { @@ -409,6 +415,14 @@ static GtkFileChooserAction gtkFileChooserAction(const QSharedPointergtkDialog(); + + const GtkFileChooserAction action = gtkFileChooserAction(options()); + gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action); +} + void QGtk3FileDialogHelper::applyOptions() { GtkDialog *gtkDialog = d->gtkDialog(); @@ -417,8 +431,7 @@ void QGtk3FileDialogHelper::applyOptions() gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8()); gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(gtkDialog), true); - const GtkFileChooserAction action = gtkFileChooserAction(opts); - gtk_file_chooser_set_action(GTK_FILE_CHOOSER(gtkDialog), action); + setFileChooserAction(); const bool selectMultiple = opts->fileMode() == QFileDialogOptions::ExistingFiles; gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(gtkDialog), selectMultiple); @@ -437,7 +450,7 @@ void QGtk3FileDialogHelper::applyOptions() setDirectory(opts->initialDirectory()); foreach (const QUrl &filename, opts->initiallySelectedFiles()) - selectFile(filename); + selectFileInternal(filename); const QString initialNameFilter = opts->initiallySelectedNameFilter(); if (!initialNameFilter.isEmpty()) diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h index 99add3bda3..ba43046e04 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.h @@ -110,6 +110,8 @@ private: static void onFilterChanged(QGtk3FileDialogHelper *helper); void applyOptions(); void setNameFilters(const QStringList &filters); + void selectFileInternal(const QUrl &filename); + void setFileChooserAction(); QUrl _dir; QList _selection; -- cgit v1.2.3 From 886ce572d628e7cd98cc39edcc930ffae951e95e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 22 Feb 2017 17:06:23 +0100 Subject: Windows QPA: don't resize fixed sized windows when changing screen This seems to give pretty good result when EnableHighDPIScaling is NOT set. But this seems to be worse when it's set. Task-number: QTBUG-58959 Change-Id: I8de5a6c3c8b6146b1cb8f89676463206af404083 Reviewed-by: Friedemann Kleint Reviewed-by: Anton Kudryavtsev --- src/plugins/platforms/windows/qwindowscontext.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index b7a866679f..ff4ab1accb 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1104,6 +1104,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif } break; case QtWindows::DpiChangedEvent: { + if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_DLGFRAME) + return false; // Fixed-size window should not be resized + platformWindow->setFlag(QWindowsWindow::WithinDpiChanged); const RECT *prcNewWindow = reinterpret_cast(lParam); SetWindowPos(hwnd, NULL, prcNewWindow->left, prcNewWindow->top, -- cgit v1.2.3 From baf71807768d81bf0d436063561b7589686c8a2c Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 20 Feb 2017 12:57:02 +0100 Subject: Use HTTP2WasUsedAttribute for HTTP2 Previously we were always setting SpdyWasUsedAttribute for SPDY/HTTP/2/HTTP/1.1 (true/false) which is confusing. Now if HTTP2AllowedAttribute was set to true on a request, we set HTTP2WasUsedAttribute. Otherwise, as we did before, we're setting SpdyWasUsedAttribute. Change-Id: I0c44cfb5469fef0c12719baa951197ee2accee4a Reviewed-by: Markus Goetz (Woboq GmbH) Reviewed-by: Timur Pocheptsov --- src/network/access/qhttp2protocolhandler.cpp | 2 ++ src/network/access/qnetworkreplyhttpimpl.cpp | 9 ++++++++- src/network/access/qnetworkrequest.cpp | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 60313422da..555f1ba0ef 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -1387,6 +1387,8 @@ void QHttp2ProtocolHandler::initReplyFromPushPromise(const HttpMessagePair &mess { Q_ASSERT(promisedData.contains(cacheKey)); auto promise = promisedData.take(cacheKey); + Q_ASSERT(message.second); + message.second->setSpdyWasUsed(true); qCDebug(QT_HTTP2) << "found cached/promised response on stream" << promise.reservedID; diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 5cd0747e34..bdb23ede1d 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1234,7 +1234,14 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QListsetAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, pu); - q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, spdyWasUsed); + const QVariant http2Allowed = request.attribute(QNetworkRequest::HTTP2AllowedAttribute); + if (http2Allowed.isValid() && http2Allowed.toBool()) { + q->setAttribute(QNetworkRequest::HTTP2WasUsedAttribute, spdyWasUsed); + q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, false); + } else { + q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, spdyWasUsed); + q->setAttribute(QNetworkRequest::HTTP2WasUsedAttribute, false); + } // reconstruct the HTTP header QList > headerMap = hm; diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index e95187de30..60701d45be 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -266,7 +266,10 @@ QT_BEGIN_NAMESPACE allowed to use HTTP/2 with this request. This applies to SSL requests or 'cleartext' HTTP/2. - \omitvalue HTTP2WasUsedAttribute + \value HTTP2WasUsedAttribute + Replies only, type: QMetaType::Bool (default: false) + Indicates whether HTTP/2 was used for receiving this reply. + (This value was introduced in 5.9.) \value EmitAllUploadProgressSignalsAttribute Requests only, type: QMetaType::Bool (default: false) -- cgit v1.2.3 From d9fe00e8e2a3e5610d5dce934d82daad8c7f3cab Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 23 Mar 2017 22:12:57 +0200 Subject: Fix warnings for -no-feature-cssparser Change-Id: Ib0eae1858880e3fe2b6c6abd94c7ea0bbc2649a2 Reviewed-by: Stephan Binner Reviewed-by: Paul Olav Tvete --- src/gui/text/qtextdocumentlayout.cpp | 2 ++ src/gui/text/qtexthtmlparser.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 8ad2d85e7c..e9194e73ff 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -834,6 +834,8 @@ void QTextDocumentLayoutPrivate::drawBorder(QPainter *painter, const QRectF &rec #ifndef QT_NO_CSSPARSER QCss::BorderStyle cssStyle = static_cast(style + 1); +#else + Q_UNUSED(style); #endif //QT_NO_CSSPARSER bool turn_off_antialiasing = !(painter->renderHints() & QPainter::Antialiasing); diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 8471c55e5f..da4e21728f 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -706,8 +706,8 @@ void QTextHtmlParser::parseTag() node = resolveParent(); resolveNode(); - const int nodeIndex = nodes.count() - 1; // this new node is always the last #ifndef QT_NO_CSSPARSER + const int nodeIndex = nodes.count() - 1; // this new node is always the last node->applyCssDeclarations(declarationsForNode(nodeIndex), resourceProvider); #endif applyAttributes(node->attributes); -- cgit v1.2.3 From b7febc35da1321f8e08476bd9850ac783be54760 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 23 Mar 2017 22:19:11 +0200 Subject: Fix warnings for -no-feature-combobox Change-Id: I352c011b21624ae9fb9db5a608e8c2b2491a05cd Reviewed-by: Stephan Binner Reviewed-by: Paul Olav Tvete --- src/widgets/styles/qpixmapstyle.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index 3aec3cf991..19f4cc3617 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -732,6 +732,8 @@ void QPixmapStyle::drawLineEdit(const QStyleOption *option, #if QT_CONFIG(combobox) if (widget && qobject_cast(widget->parentWidget())) return; +#else + Q_UNUSED(widget); #endif const bool enabled = option->state & State_Enabled; const bool focused = option->state & State_HasFocus; -- cgit v1.2.3 From c20cd4d98ea43275bd8859581e273d69a90c3413 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 23 Mar 2017 22:20:31 +0200 Subject: Fix warnings for -no-feature-dockwidget Change-Id: Id1f04f9ff6da9bec07068d4ebed15f8bd29105af Reviewed-by: Stephan Binner Reviewed-by: Paul Olav Tvete Reviewed-by: Ulf Hermann --- src/widgets/widgets/qmainwindowlayout.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 640154063e..d15af3505b 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2432,6 +2432,9 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) } #endif +#if !QT_CONFIG(dockwidget) && !QT_CONFIG(tabbar) + Q_UNUSED(group); +#endif layoutState.unplug(path ,&savedState); savedState.fitLayout(); -- cgit v1.2.3 From d8426aa18eb4f80dc9a5d64f7b73697d4773b4d2 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 23 Mar 2017 22:17:21 +0200 Subject: Fix warnings for -no-feature-itemviews Change-Id: Ia384c2b48a6eaccb424cdde00240ebcfa6fd24c6 Reviewed-by: Stephan Binner Reviewed-by: Paul Olav Tvete --- src/widgets/styles/qcommonstyle.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 604422dc4f..cdb80d7581 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4882,6 +4882,8 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz.rheight() += 2; // Prevent icons from overlapping. } break; +#else + Q_UNUSED(d); #endif // QT_NO_ITEMVIEWS #ifndef QT_NO_SPINBOX case CT_SpinBox: -- cgit v1.2.3 From cc4f610c2137e58ecdbb852b799a7535b81793a1 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 23 Mar 2017 22:14:45 +0200 Subject: Fix warnings for -no-feature-mimetype Change-Id: I6b1239941f8fd13eec72b0874d15d821d717ddf3 Reviewed-by: Stephan Binner Reviewed-by: Paul Olav Tvete --- src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 4eefcace0f..e9116223bd 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -555,6 +555,7 @@ QIcon QKdeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions #if QT_CONFIG(mimetype) return xdgFileIcon(fileInfo); #else + Q_UNUSED(fileInfo); return QIcon(); #endif } @@ -720,6 +721,7 @@ QIcon QGnomeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptio #if QT_CONFIG(mimetype) return xdgFileIcon(fileInfo); #else + Q_UNUSED(fileInfo); return QIcon(); #endif } -- cgit v1.2.3 From f901afaf4963341cd8e16d54fe630f06df031182 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Sun, 19 Mar 2017 21:01:59 +0300 Subject: Use QStringBuilder more Change-Id: If5283e364e921d99ffa7a8fa1abb07356a4a2682 Reviewed-by: Edward Welbourne --- src/corelib/io/qsettings_mac.cpp | 3 +-- src/sql/models/qsqltablemodel.cpp | 4 ++-- src/tools/uic/cpp/cppwriteinitialization.cpp | 17 +++++++---------- 3 files changed, 10 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index 39777e6c90..cf3a480623 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -425,8 +425,7 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString & suiteId = javaPackageName; if (!application.isEmpty()) { - javaPackageName += QLatin1Char('.'); - javaPackageName += application; + javaPackageName += QLatin1Char('.') + application; applicationId = javaPackageName; } diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 8166613e53..c0706ac22d 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -986,8 +986,8 @@ QString QSqlTableModel::orderByClause() const //we can safely escape the field because it would have been obtained from the database //and have the correct case - QString field = d->db.driver()->escapeIdentifier(f.name(), QSqlDriver::FieldName); - field.prepend(QLatin1Char('.')).prepend(d->tableName); + QString field = d->tableName + QLatin1Char('.') + + d->db.driver()->escapeIdentifier(f.name(), QSqlDriver::FieldName); field = d->sortOrder == Qt::AscendingOrder ? Sql::asc(field) : Sql::desc(field); return Sql::orderBy(field); } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 301d6fdabb..bbef010a9c 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -48,10 +48,11 @@ namespace { // Fixup an enumeration name from class Qt. // They are currently stored as "BottomToolBarArea" instead of "Qt::BottomToolBarArea". // due to MO issues. This might be fixed in the future. - void fixQtEnumerationName(QString& name) { + QLatin1String qtEnumerationPrefix(const QString &name) { static const QLatin1String prefix("Qt::"); if (name.indexOf(prefix) != 0) - name.prepend(prefix); + return prefix; + return QLatin1String(); } // figure out the toolbar area of a DOM attrib list. // By legacy, it is stored as an integer. As of 4.3.0, it is the enumeration value. @@ -62,16 +63,12 @@ namespace { switch (pstyle->kind()) { case DomProperty::Number: { - QString area = QLatin1String("static_cast("); - area += QString::number(pstyle->elementNumber()); - area += QLatin1String("), "); - return area; + return QLatin1String("static_cast(") + + QString::number(pstyle->elementNumber()) + QLatin1String("), "); } case DomProperty::Enum: { - QString area = pstyle->elementEnum(); - fixQtEnumerationName(area); - area += QLatin1String(", "); - return area; + const QString area = pstyle->elementEnum(); + return qtEnumerationPrefix(area) + area + QLatin1String(", "); } default: break; -- cgit v1.2.3 From 805a850f04aa42706bbe8d4d8e8161a09fa65645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Br=C3=BCning?= Date: Wed, 29 Mar 2017 14:11:01 +0200 Subject: Convert QStrings with qUtf8Printable for GTK API calls The fix for dangling pointers in 524f39 caused some problems when the QByteArray was implicitly converted to const gchar*. This is fixed by wrapping the QString in question in qUtf8Printable where possible and removing the former convenience method. Task-number: QTBUG-59692 Change-Id: I5abcf42e1c23b12c7a5c4c195d801f377fe9d138 Reviewed-by: J-P Nurmi --- .../platformthemes/gtk3/qgtk3dialoghelpers.cpp | 45 ++++++++++------------ 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index b1821ebbd2..c64a02fa0c 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -57,11 +57,6 @@ QT_BEGIN_NAMESPACE -static QByteArray standardButtonText(int button) -{ - return QGtk3Theme::defaultStandardButtonText(button).toUtf8(); -} - class QGtk3Dialog : public QWindow { Q_OBJECT @@ -236,7 +231,7 @@ void QGtk3ColorDialogHelper::onColorChanged(QGtk3ColorDialogHelper *dialog) void QGtk3ColorDialogHelper::applyOptions() { GtkDialog *gtkDialog = d->gtkDialog(); - gtk_window_set_title(GTK_WINDOW(gtkDialog), options()->windowTitle().toUtf8()); + gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(options()->windowTitle())); gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(gtkDialog), options()->testOption(QColorDialogOptions::ShowAlphaChannel)); } @@ -245,8 +240,8 @@ QGtk3FileDialogHelper::QGtk3FileDialogHelper() { d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", 0, GTK_FILE_CHOOSER_ACTION_OPEN, - standardButtonText(QPlatformDialogHelper::Cancel), GTK_RESPONSE_CANCEL, - standardButtonText(QPlatformDialogHelper::Ok), GTK_RESPONSE_OK, + qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Cancel)), GTK_RESPONSE_CANCEL, + qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Ok)), GTK_RESPONSE_OK, NULL))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); @@ -294,7 +289,7 @@ bool QGtk3FileDialogHelper::defaultNameFilterDisables() const void QGtk3FileDialogHelper::setDirectory(const QUrl &directory) { GtkDialog *gtkDialog = d->gtkDialog(); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), directory.toLocalFile().toUtf8()); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(directory.toLocalFile())); } QUrl QGtk3FileDialogHelper::directory() const @@ -325,10 +320,10 @@ void QGtk3FileDialogHelper::selectFileInternal(const QUrl &filename) GtkDialog *gtkDialog = d->gtkDialog(); if (options()->acceptMode() == QFileDialogOptions::AcceptSave) { QFileInfo fi(filename.toLocalFile()); - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), fi.path().toUtf8()); - gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(gtkDialog), fi.fileName().toUtf8()); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(fi.path())); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(fi.fileName())); } else { - gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), filename.toLocalFile().toUtf8()); + gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(gtkDialog), qUtf8Printable(filename.toLocalFile())); } } @@ -428,7 +423,7 @@ void QGtk3FileDialogHelper::applyOptions() GtkDialog *gtkDialog = d->gtkDialog(); const QSharedPointer &opts = options(); - gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8()); + gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(opts->windowTitle())); gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(gtkDialog), true); setFileChooserAction(); @@ -459,19 +454,19 @@ void QGtk3FileDialogHelper::applyOptions() GtkWidget *acceptButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_OK); if (acceptButton) { if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept)) - gtk_button_set_label(GTK_BUTTON(acceptButton), opts->labelText(QFileDialogOptions::Accept).toUtf8()); + gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(opts->labelText(QFileDialogOptions::Accept))); else if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) - gtk_button_set_label(GTK_BUTTON(acceptButton), standardButtonText(QPlatformDialogHelper::Open)); + gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Open))); else - gtk_button_set_label(GTK_BUTTON(acceptButton), standardButtonText(QPlatformDialogHelper::Save)); + gtk_button_set_label(GTK_BUTTON(acceptButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Save))); } GtkWidget *rejectButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_CANCEL); if (rejectButton) { if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject)) - gtk_button_set_label(GTK_BUTTON(rejectButton), opts->labelText(QFileDialogOptions::Reject).toUtf8()); + gtk_button_set_label(GTK_BUTTON(rejectButton), qUtf8Printable(opts->labelText(QFileDialogOptions::Reject))); else - gtk_button_set_label(GTK_BUTTON(rejectButton), standardButtonText(QPlatformDialogHelper::Cancel)); + gtk_button_set_label(GTK_BUTTON(rejectButton), qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Cancel))); } } @@ -486,12 +481,12 @@ void QGtk3FileDialogHelper::setNameFilters(const QStringList &filters) foreach (const QString &filter, filters) { GtkFileFilter *gtkFilter = gtk_file_filter_new(); - const QStringRef name = filter.leftRef(filter.indexOf(QLatin1Char('('))); + const QString name = filter.left(filter.indexOf(QLatin1Char('('))); const QStringList extensions = cleanFilterList(filter); - gtk_file_filter_set_name(gtkFilter, name.isEmpty() ? extensions.join(QLatin1String(", ")).toUtf8() : name.toUtf8()); + gtk_file_filter_set_name(gtkFilter, qUtf8Printable(name.isEmpty() ? extensions.join(QLatin1String(", ")) : name)); foreach (const QString &ext, extensions) - gtk_file_filter_add_pattern(gtkFilter, ext.toUtf8()); + gtk_file_filter_add_pattern(gtkFilter, qUtf8Printable(ext)); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(gtkDialog), gtkFilter); @@ -533,7 +528,7 @@ static QString qt_fontToString(const QFont &font) { PangoFontDescription *desc = pango_font_description_new(); pango_font_description_set_size(desc, (font.pointSizeF() > 0.0 ? font.pointSizeF() : QFontInfo(font).pointSizeF()) * PANGO_SCALE); - pango_font_description_set_family(desc, QFontInfo(font).family().toUtf8()); + pango_font_description_set_family(desc, qUtf8Printable(QFontInfo(font).family())); int weight = font.weight(); if (weight >= QFont::Black) @@ -573,7 +568,7 @@ static QString qt_fontToString(const QFont &font) static QFont qt_fontFromString(const QString &name) { QFont font; - PangoFontDescription *desc = pango_font_description_from_string(name.toUtf8()); + PangoFontDescription *desc = pango_font_description_from_string(qUtf8Printable(name)); font.setPointSizeF(static_cast(pango_font_description_get_size(desc)) / PANGO_SCALE); QString family = QString::fromUtf8(pango_font_description_get_family(desc)); @@ -598,7 +593,7 @@ static QFont qt_fontFromString(const QString &name) void QGtk3FontDialogHelper::setCurrentFont(const QFont &font) { GtkFontChooser *gtkDialog = GTK_FONT_CHOOSER(d->gtkDialog()); - gtk_font_chooser_set_font(gtkDialog, qt_fontToString(font).toUtf8()); + gtk_font_chooser_set_font(gtkDialog, qUtf8Printable(qt_fontToString(font))); } QFont QGtk3FontDialogHelper::currentFont() const @@ -625,7 +620,7 @@ void QGtk3FontDialogHelper::applyOptions() GtkDialog *gtkDialog = d->gtkDialog(); const QSharedPointer &opts = options(); - gtk_window_set_title(GTK_WINDOW(gtkDialog), opts->windowTitle().toUtf8()); + gtk_window_set_title(GTK_WINDOW(gtkDialog), qUtf8Printable(opts->windowTitle())); } QT_END_NAMESPACE -- cgit v1.2.3 From ce124d511917f95bd9193ec71f747f490ec982da Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 29 Mar 2017 07:20:42 +0300 Subject: Prefer rvalue version of toLocal8Bit() ... to re-use existing buffers. Change-Id: I5907a2e29d7f7dac04df5bf50769b47131e175d8 Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/plugins/platforms/xcb/qxcbintegration.cpp | 2 +- src/plugins/sqldrivers/psql/qsql_psql.cpp | 2 +- src/printsupport/kernel/qprintengine_win.cpp | 2 +- src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 40858b39e0..b414bee204 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -466,7 +466,7 @@ QByteArray QXcbIntegration::wmClass() const } if (!name.isEmpty() && !className.isEmpty()) - m_wmClass = name.toLocal8Bit() + '\0' + className.toLocal8Bit() + '\0'; + m_wmClass = std::move(name).toLocal8Bit() + '\0' + std::move(className).toLocal8Bit() + '\0'; } return m_wmClass; } diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index a54ceefb6f..acadc830b2 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -911,7 +911,7 @@ bool QPSQLDriver::open(const QString & db, connectString.append(QLatin1Char(' ')).append(opt); } - d->connection = PQconnectdb(connectString.toLocal8Bit().constData()); + d->connection = PQconnectdb(std::move(connectString).toLocal8Bit().constData()); if (PQstatus(d->connection) == CONNECTION_BAD) { setLastError(qMakeError(tr("Unable to connect"), QSqlError::ConnectionError, d)); setOpenError(true); diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index f1ccbaa90a..37f2290d94 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -106,7 +106,7 @@ static QByteArray msgBeginFailed(const char *function, const DOCINFO &d) str << ", document \"" << QString::fromWCharArray(d.lpszDocName) << '"'; if (d.lpszOutput && d.lpszOutput[0]) str << ", file \"" << QString::fromWCharArray(d.lpszOutput) << '"'; - return result.toLocal8Bit(); + return std::move(result).toLocal8Bit(); } bool QWin32PrintEngine::begin(QPaintDevice *pdev) diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index efce778acf..7ddd0fcf5d 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -447,7 +447,7 @@ int main(int argc, char **argv) output.write("\n"); for (const ClassDef &cdef : qAsConst(classes)) { QString xml = qDBusGenerateClassDefXml(&cdef); - output.write(xml.toLocal8Bit()); + output.write(std::move(xml).toLocal8Bit()); } output.write("\n"); -- cgit v1.2.3 From 5ec57560c0b497f9f48671dd200bb23d1f6eac35 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 29 Mar 2017 07:10:46 +0300 Subject: Prefer rvalue versions of toLatin() and toUtf8() ... to re-use existing buffers. Change-Id: I7c42529b8cd4400520a59e658ab76f4f8e965cd4 Reviewed-by: Thiago Macieira --- src/corelib/io/qsettings_mac.cpp | 2 +- src/corelib/io/qurl.cpp | 6 ++---- src/corelib/tools/qlocale_win.cpp | 13 +++++-------- src/corelib/tools/qregularexpression.cpp | 2 +- src/corelib/tools/qtimezoneprivate_icu.cpp | 2 +- src/corelib/tools/qtimezoneprivate_win.cpp | 2 +- src/network/access/qhttpnetworkconnection.cpp | 2 +- src/network/access/qhttpthreaddelegate.cpp | 2 +- src/plugins/platforms/windows/qwindowsmime.cpp | 2 +- src/plugins/platforms/xcb/qxcbmime.cpp | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 4 ++-- src/testlib/qplaintestlogger.cpp | 2 +- src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp | 4 ++-- src/widgets/widgets/qsplitter.cpp | 2 +- src/xml/dom/qdom.cpp | 2 +- src/xml/sax/qxml.cpp | 2 +- 16 files changed, 23 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index cf3a480623..2a08ee2e64 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -211,7 +211,7 @@ static QCFType macValue(const QVariant &value) default: QString string = QSettingsPrivate::variantToString(value); if (string.contains(QChar::Null)) - result = string.toUtf8().toCFData(); + result = std::move(string).toUtf8().toCFData(); else result = string.toCFString(); } diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index b5772b5ce2..9663235a67 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3418,8 +3418,7 @@ QUrl QUrl::adjusted(QUrl::FormattingOptions options) const QByteArray QUrl::toEncoded(FormattingOptions options) const { options &= ~(FullyDecoded | FullyEncoded); - QString stringForm = toString(options | FullyEncoded); - return stringForm.toLatin1(); + return toString(options | FullyEncoded).toLatin1(); } /*! @@ -3536,8 +3535,7 @@ QString QUrl::fromAce(const QByteArray &domain) */ QByteArray QUrl::toAce(const QString &domain) { - QString result = qt_ACE_do(domain, ToAceOnly, ForbidLeadingDot /*FIXME: make configurable*/); - return result.toLatin1(); + return qt_ACE_do(domain, ToAceOnly, ForbidLeadingDot /*FIXME: make configurable*/).toLatin1(); } /*! diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index d1abb8b565..2475859abd 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -1037,7 +1037,7 @@ static QString winIso639LangName(LPWSTR id) if (!lang_code.isEmpty()) { const char *endptr; bool ok; - QByteArray latin1_lang_code = lang_code.toLatin1(); + QByteArray latin1_lang_code = std::move(lang_code).toLatin1(); int i = qstrtoull(latin1_lang_code, &endptr, 16, &ok); if (ok && *endptr == '\0') { switch (i) { @@ -1120,15 +1120,12 @@ static QByteArray getWinLocaleName(LPWSTR id) id = lcName; } #endif // Q_OS_WINRT - QString resultuage = winIso639LangName(id); + QString resultusage = winIso639LangName(id); QString country = winIso3116CtryName(id); - result = resultuage.toLatin1(); - if (!country.isEmpty()) { - result += '_'; - result += country.toLatin1(); - } + if (!country.isEmpty()) + resultusage += QLatin1Char('_') + country; - return result; + return std::move(resultusage).toLatin1(); } Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id) diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 8366e01ee8..f1fac093b0 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -1674,7 +1674,7 @@ QString QRegularExpression::errorString() const } while (errorStringLength < 0); errorString.resize(errorStringLength); - return QCoreApplication::translate("QRegularExpression", errorString.toLatin1().constData()); + return QCoreApplication::translate("QRegularExpression", std::move(errorString).toLatin1().constData()); } return QCoreApplication::translate("QRegularExpression", "no error"); } diff --git a/src/corelib/tools/qtimezoneprivate_icu.cpp b/src/corelib/tools/qtimezoneprivate_icu.cpp index 887486f567..a7226f2720 100644 --- a/src/corelib/tools/qtimezoneprivate_icu.cpp +++ b/src/corelib/tools/qtimezoneprivate_icu.cpp @@ -98,7 +98,7 @@ static QByteArray ucalDefaultTimeZoneId() // If successful on first or second go, resize and return if (U_SUCCESS(status)) { result.resize(size); - return result.toUtf8(); + return std::move(result).toUtf8(); } return QByteArray(); diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp index 16dfaefb74..f963e10333 100644 --- a/src/corelib/tools/qtimezoneprivate_win.cpp +++ b/src/corelib/tools/qtimezoneprivate_win.cpp @@ -299,7 +299,7 @@ static QByteArray windowsSystemZoneId() id = readRegistryString(key, L"TimeZoneKeyName"); RegCloseKey(key); if (!id.isEmpty()) - return id.toUtf8(); + return std::move(id).toUtf8(); } // On XP we have to iterate over the zones until we find a match on diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 72feffda8c..da055de2da 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -327,7 +327,7 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) acceptLanguage = systemLocale + QLatin1String(",*"); else acceptLanguage = systemLocale + QLatin1String(",en,*"); - request.setHeaderField("Accept-Language", acceptLanguage.toLatin1()); + request.setHeaderField("Accept-Language", std::move(acceptLanguage).toLatin1()); } // set the User Agent diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 6e5e29d7bf..9d874b4d94 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -169,7 +169,7 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy) Q_UNUSED(proxy) #endif - return "http-connection:" + result.toLatin1(); + return "http-connection:" + std::move(result).toLatin1(); } class QNetworkAccessCachedHttpConnection: public QHttpNetworkConnection, diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 71fd12d71b..bd4822c664 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -717,7 +717,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData if (preferredType == QVariant::String) ret = str; else - ret = str.toUtf8(); + ret = std::move(str).toUtf8(); } qCDebug(lcQpaMime) << __FUNCTION__ << ret; return ret; diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 7592eb2887..186f31e08a 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -305,7 +305,7 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString QString formatWithCharset = format; formatWithCharset.append(QLatin1String(";charset=utf-8")); - xcb_atom_t a = connection->internAtom(formatWithCharset.toLatin1()); + xcb_atom_t a = connection->internAtom(std::move(formatWithCharset).toLatin1()); if (a && atoms.contains(a)) { *requestedEncoding = "utf-8"; return a; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index f6fa903ec2..77291cc4f5 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1512,8 +1512,8 @@ void QXcbWindow::setParent(const QPlatformWindow *parent) void QXcbWindow::setWindowTitle(const QString &title) { - const QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH - const QByteArray ba = fullTitle.toUtf8(); + QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH + const QByteArray ba = std::move(fullTitle).toUtf8(); Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index dc20d922e5..77959341cf 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -199,8 +199,8 @@ namespace QTest { int formatResult(char * buffer, int bufferSize, T number, int significantDigits) { QString result = formatResult(number, significantDigits); - qstrncpy(buffer, result.toLatin1().constData(), bufferSize); int size = result.count(); + qstrncpy(buffer, std::move(result).toLatin1().constData(), bufferSize); return size; } } diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index cdf3ad3310..9ccf8be73a 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -217,7 +217,7 @@ static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection: annotationName += QString::fromLatin1(".%1%2").arg(QLatin1String(direction)).arg(paramId); QString qttype = annotations.value(annotationName); if (!qttype.isEmpty()) - return qttype.toLatin1(); + return std::move(qttype).toLatin1(); QString oldAnnotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName"); if (paramId >= 0) @@ -242,7 +242,7 @@ static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection: "suggest updating to '%s'\n", PROGRAMNAME, qPrintable(oldAnnotationName), qPrintable(inputFile), qPrintable(annotationName)); - return qttype.toLatin1(); + return std::move(qttype).toLatin1(); } return QVariant::typeToName(QVariant::Type(type)); diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index c55b943b5a..e92347c65c 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1800,7 +1800,7 @@ QTextStream& operator>>(QTextStream& ts, QSplitter& splitter) line.replace(QLatin1Char(' '), QString()); line = std::move(line).toUpper(); - splitter.restoreState(line.toLatin1()); + splitter.restoreState(std::move(line).toLatin1()); return ts; } diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index dd9bb4f875..9affd697a0 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -6442,7 +6442,7 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod if (enc.isEmpty()) enc = encoding.cap(5); if (!enc.isEmpty()) - codec = QTextCodec::codecForName(enc.toLatin1().data()); + codec = QTextCodec::codecForName(std::move(enc).toLatin1()); } if (!codec) codec = QTextCodec::codecForName("UTF-8"); diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 1724076b84..bc7d00483a 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -1407,7 +1407,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) QString encoding = extractEncodingDecl(d->encodingDeclChars, &needMoreText); if (!encoding.isEmpty()) { - if (QTextCodec *codec = QTextCodec::codecForName(encoding.toLatin1())) { + if (QTextCodec *codec = QTextCodec::codecForName(std::move(encoding).toLatin1())) { /* If the encoding is the same, we don't have to do toUnicode() all over again. */ if(codec->mibEnum() != mib) { delete d->encMapper; -- cgit v1.2.3 From df43ef7b6dde35c13d2d06ad69c2d63f66b237fb Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 30 Mar 2017 19:19:45 +0200 Subject: QStringBuilder: simplify QConcatenable ... by delegating to QConcatenable. The only thing that varied was the nested type alias 'type', which therefore got retained. Change-Id: I202f899034e1ddd23c6d1978a31be5eb7c195697 Reviewed-by: Thiago Macieira --- src/corelib/tools/qstringbuilder.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index b2832b5fbe..9a40abcfed 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -277,9 +277,9 @@ template <> struct QConcatenable : private QAbstractConcatenable } }; -template struct QConcatenable : private QAbstractConcatenable +template struct QConcatenable : private QAbstractConcatenable { - typedef char type[N]; + typedef const char type[N]; typedef QByteArray ConvertTo; enum { ExactSize = false }; static int size(const char[N]) { return N - 1; } @@ -296,23 +296,9 @@ template struct QConcatenable : private QAbstractConcatenable } }; -template struct QConcatenable : private QAbstractConcatenable +template struct QConcatenable : QConcatenable { - typedef const char type[N]; - typedef QByteArray ConvertTo; - enum { ExactSize = false }; - static int size(const char[N]) { return N - 1; } -#ifndef QT_NO_CAST_FROM_ASCII - static inline void QT_ASCII_CAST_WARN appendTo(const char a[N], QChar *&out) - { - QAbstractConcatenable::convertFromAscii(a, N - 1, out); - } -#endif - static inline void appendTo(const char a[N], char *&out) - { - while (*a) - *out++ = *a++; - } + typedef char type[N]; }; template <> struct QConcatenable : private QAbstractConcatenable -- cgit v1.2.3 From 995719cebd7cb2e875b2d64b54b9314363eab984 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 30 Mar 2017 10:45:21 +0200 Subject: winrt: Fix dnd with non mouse input device When using anything but the mouse, there is no release event sent. Instead one needs to subscribe to the ICorePointerRedirector. Task-number: QTBUG-58781 Change-Id: I664ba24bd89ea9f513f8f11b385e2f06ece42fd0 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 23 +++++++++++++++++++++++ src/plugins/platforms/winrt/qwinrtscreen.h | 2 ++ 2 files changed, 25 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 150fc8a25e..edfcf038d7 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -91,6 +91,7 @@ typedef ITypedEventHandler PointerHandler; typedef ITypedEventHandler SizeChangedHandler; typedef ITypedEventHandler VisibilityChangedHandler; typedef ITypedEventHandler DisplayInformationHandler; +typedef ITypedEventHandler RedirectHandler; #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) typedef ITypedEventHandler VisibleBoundsChangedHandler; #endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) @@ -454,6 +455,8 @@ typedef HRESULT (__stdcall ICoreWindow::*CoreWindowCallbackRemover)(EventRegistr uint qHash(CoreWindowCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } typedef HRESULT (__stdcall IDisplayInformation::*DisplayCallbackRemover)(EventRegistrationToken); uint qHash(DisplayCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } +typedef HRESULT (__stdcall ICorePointerRedirector::*RedirectorCallbackRemover)(EventRegistrationToken); +uint qHash(RedirectorCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) typedef HRESULT (__stdcall IApplicationView2::*ApplicationView2CallbackRemover)(EventRegistrationToken); uint qHash(ApplicationView2CallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } @@ -464,6 +467,7 @@ class QWinRTScreenPrivate public: QTouchDevice *touchDevice; ComPtr coreWindow; + ComPtr redirect; ComPtr canvas; ComPtr view; ComPtr displayInformation; @@ -482,6 +486,7 @@ public: QHash activeKeys; QHash windowTokens; QHash displayTokens; + QHash redirectTokens; #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) QHash view2Tokens; ComPtr view2; @@ -513,6 +518,10 @@ QWinRTScreen::QWinRTScreen() hr = window->get_CoreWindow(&d->coreWindow); Q_ASSERT_SUCCEEDED(hr); + + hr = d->coreWindow.As(&d->redirect); + Q_ASSERT_SUCCEEDED(hr); + hr = d->coreWindow->Activate(); Q_ASSERT_SUCCEEDED(hr); @@ -595,6 +604,10 @@ QWinRTScreen::~QWinRTScreen() hr = (d->displayInformation.Get()->*i.key())(i.value()); Q_ASSERT_SUCCEEDED(hr); } + for (QHash::const_iterator i = d->redirectTokens.begin(); i != d->redirectTokens.end(); ++i) { + hr = (d->redirect.Get()->*i.key())(i.value()); + Q_ASSERT_SUCCEEDED(hr); + } #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) for (QHash::const_iterator i = d->view2Tokens.begin(); i != d->view2Tokens.end(); ++i) { hr = (d->view2.Get()->*i.key())(i.value()); @@ -754,6 +767,9 @@ void QWinRTScreen::initialize() Q_ASSERT_SUCCEEDED(hr); onOrientationChanged(Q_NULLPTR, Q_NULLPTR); onVisibilityChanged(nullptr, nullptr); + + hr = d->redirect->add_PointerRoutedReleased(Callback(this, &QWinRTScreen::onRedirectReleased).Get(), &d->redirectTokens[&ICorePointerRedirector::remove_PointerRoutedReleased]); + Q_ASSERT_SUCCEEDED(hr); } void QWinRTScreen::setCursorRect(const QRectF &cursorRect) @@ -1378,6 +1394,13 @@ HRESULT QWinRTScreen::onDpiChanged(IDisplayInformation *, IInspectable *) return S_OK; } +HRESULT QWinRTScreen::onRedirectReleased(ICorePointerRedirector *, IPointerEventArgs *args) +{ + // When dragging ends with a non-mouse input device then onRedirectRelease is invoked. + // QTBUG-58781 + return onPointerUpdated(nullptr, args); +} + #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) HRESULT QWinRTScreen::onWindowSizeChanged(IApplicationView *, IInspectable *) #else diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index 7dcdb98ead..fd6499c2b9 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -52,6 +52,7 @@ namespace ABI { namespace Core { struct IAutomationProviderRequestedEventArgs; struct ICharacterReceivedEventArgs; + struct ICorePointerRedirector; struct ICoreWindow; struct ICoreWindowEventArgs; struct IKeyEventArgs; @@ -149,6 +150,7 @@ private: #else HRESULT onWindowSizeChanged(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *); #endif + HRESULT onRedirectReleased(ABI::Windows::UI::Core::ICorePointerRedirector *, ABI::Windows::UI::Core::IPointerEventArgs *); QScopedPointer d_ptr; QRectF mCursorRect; -- cgit v1.2.3 From 5090fd501880e5580fa56812c9820f7688b53330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 24 Mar 2017 11:05:09 +0100 Subject: Rewrite FreeType-ifdef'ed function call in QCoreTextFontDatabase Makes the code slightly less awkward to deal with. Change-Id: Ie98a04d812beecfbf0d19e77b8e784db783a19d6 Reviewed-by: Konstantin Ritt Reviewed-by: Simon Hausmann --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 10 +++------- .../fontdatabases/mac/qcoretextfontdatabase_p.h | 1 + 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 2b9e928266..3588948133 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -615,7 +615,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo return fallbackLists[styleLookupKey.arg(styleHint)]; } -static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName = QString()) +CFArrayRef QCoreTextFontDatabase::createDescriptorArrayForFont(CTFontRef font, const QString &fileName) { CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); QCFType descriptor = CTFontCopyFontDescriptor(font); @@ -625,7 +625,7 @@ static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fi // The physical font source URL (usually a local file or Qt resource) is only required for // FreeType, when using non-system fonts, and needs some hackery to attach in a format // agreeable to OSX. - if (!fileName.isEmpty()) { + if (m_useFreeType && !fileName.isEmpty()) { QCFType fontURL; if (fileName.startsWith(QLatin1String(":/"))) { @@ -662,11 +662,7 @@ QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData if (cgFont) { if (CTFontManagerRegisterGraphicsFont(cgFont, &error)) { QCFType font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL); - fonts = createDescriptorArrayForFont(font -#ifndef QT_NO_FREETYPE - , m_useFreeType ? fileName : QString() -#endif - ); + fonts = createDescriptorArrayForFont(font, fileName); m_applicationFonts.append(QVariant::fromValue(QCFType::constructFromGet(cgFont))); } } diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 3b1be2e6a1..c093d903af 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -93,6 +93,7 @@ public: private: void populateFromDescriptor(CTFontDescriptorRef font, const QString &familyName = QString()); + CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName); #ifndef QT_NO_FREETYPE bool m_useFreeType; -- cgit v1.2.3 From 8675e1c5ee7d1209784a2320f1ae3f486b1eaae4 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Thu, 30 Mar 2017 22:46:02 +0300 Subject: Fix warnings for -no-feature-dockwidget This amends commit c20cd4d98ea43275bd8859581e273d69a90c3413 Change-Id: I2fa903209694cd05e0dcf31e6f92d96ed934c91d Reviewed-by: Stephan Binner Reviewed-by: Ulf Hermann --- src/widgets/widgets/qmainwindowlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index d15af3505b..d31fa3ddfa 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2432,7 +2432,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) } #endif -#if !QT_CONFIG(dockwidget) && !QT_CONFIG(tabbar) +#if !QT_CONFIG(dockwidget) || !QT_CONFIG(tabbar) Q_UNUSED(group); #endif -- cgit v1.2.3