From 7a127fb4b605da6a6f9cc781fe67de7aa00048aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 13 Feb 2019 14:29:32 +0100 Subject: [PATCH 1/7] Document that dialog parent relationship does not imply stacking order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS, and most probably some X11 window managers, the parent/child relationship of the dialog is not possible to propagate to the platform, and the only determining factor of whether or not the windows stack on top of each other is the modal state of the window. Task-number: QTBUG-34767 Change-Id: I8b4b4910e3f905c44e577544fc347dbded373848 Reviewed-by: Volker Hilsheimer Reviewed-by: Topi Reiniö --- src/widgets/dialogs/qdialog.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index c9093095a77..1c10e3e7868 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -246,6 +246,13 @@ void QDialogPrivate::deletePlatformHelper() window-system properties for the widget (in particular it will reset the Qt::Dialog flag). + \note The parent relationship of the dialog does \e{not} imply + that the dialog will always be stacked on top of the parent + window. To ensure that the dialog is always on top, make the + dialog modal. This also applies for child windows of the dialog + itself. To ensure that child windows of the dialog stay on top + of the dialog, make the child windows modal as well. + \section1 Modal Dialogs A \b{modal} dialog is a dialog that blocks input to other From 7831b276e610368514087a81396d1ca2425b2e42 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 5 Mar 2019 11:06:55 +0100 Subject: [PATCH 2/7] Handle error from MS-Win API in QCollator::compare() CompreString(Ex|) can fail, e.g. if it doesn't like the flags given. Report such failure and treat compared values as equal rather than whichever is first being less. Fixes: QTBUG-74209 Change-Id: If8fa962f9e14ee43cc423a09a67bc58259a24794 Reviewed-by: Thiago Macieira Reviewed-by: Aleix Pol Gonzalez --- src/corelib/tools/qcollator_win.cpp | 34 ++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp index 35142bb8b86..10cfdaa264f 100644 --- a/src/corelib/tools/qcollator_win.cpp +++ b/src/corelib/tools/qcollator_win.cpp @@ -72,6 +72,8 @@ void QCollatorPrivate::init() if (caseSensitivity == Qt::CaseInsensitive) collator |= NORM_IGNORECASE; + // WINE does not support SORT_DIGITSASNUMBERS :-( + // (and its std::sort() crashes on bad comparisons, QTBUG-74209) if (numericMode) collator |= SORT_DIGITSASNUMBERS; @@ -98,16 +100,36 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con // Returns one of the following values if successful. To maintain the C runtime convention of // comparing strings, the value 2 can be subtracted from a nonzero return value. Then, the // meaning of <0, ==0, and >0 is consistent with the C runtime. + // [...] The function returns 0 if it does not succeed. + // https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-comparestringex#return-value #ifndef USE_COMPARESTRINGEX - return CompareString(d->localeID, d->collator, - reinterpret_cast(s1), len1, - reinterpret_cast(s2), len2) - 2; + const int ret = CompareString(d->localeID, d->collator, + reinterpret_cast(s1), len1, + reinterpret_cast(s2), len2); #else - return CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator, - reinterpret_cast(s1), len1, - reinterpret_cast(s2), len2, NULL, NULL, 0) - 2; + const int ret = CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator, + reinterpret_cast(s1), len1, + reinterpret_cast(s2), len2, + nullptr, nullptr, 0); #endif + if (Q_LIKELY(ret)) + return ret - 2; + + switch (DWORD error = GetLastError()) { + case ERROR_INVALID_FLAGS: + qWarning("Unsupported flags (%d) used in QCollator", int(d->collator)); + break; + case ERROR_INVALID_PARAMETER: + qWarning("Invalid parameter for QCollator::compare()"); + break; + default: + qWarning("Failed (%ld) comparison in QCollator::compare()", long(error)); + break; + } + // We have no idea what to return, so pretend we think they're equal. + // At least that way we'll be consistent if we get the same values swapped ... + return 0; } int QCollator::compare(const QString &str1, const QString &str2) const From e431a3ac027915dbfc0588f42f3b56e07639811e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 4 Mar 2019 12:24:10 +0100 Subject: [PATCH 3/7] Don't retry a ssl connection if encryption was never finished As explained in the inline comment we don't actually have a protocol handler until we're done encrypting when we use SSL, but we would still retry the connection if an error occurred between "connected" and "encrypted". This would then lead us to fail an assert that checked if a protocol handler had been set Fixes: QTBUG-47822 Change-Id: If7f4ef4f70e72b764f492e7ced5a9349b3a421d2 Reviewed-by: Timur Pocheptsov --- src/network/access/qhttpnetworkconnectionchannel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 5726925cb03..d5f63af745d 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -966,7 +966,10 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket } else if (state != QHttpNetworkConnectionChannel::IdleState && state != QHttpNetworkConnectionChannel::ReadingState) { // Try to reconnect/resend before sending an error. // While "Reading" the _q_disconnected() will handle this. - if (reconnectAttempts-- > 0) { + // If we're using ssl then the protocolHandler is not initialized until + // "encrypted" has been emitted, since retrying requires the protocolHandler (asserted) + // we will not try if encryption is not done. + if (!pendingEncrypt && reconnectAttempts-- > 0) { resendCurrentRequest(); return; } else { From 464d261aa8269c4dd59b88b6fa187a1973e32fbe Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Mar 2019 12:50:26 +0100 Subject: [PATCH 4/7] Fix some warnings in manual tests Fix: gestures.cpp:46:16: warning: this statement may fall through [-Wimplicit-fallthrough=] gestures.cpp:47:5: note: here gestures.cpp:48:9: warning: this statement may fall through [-Wimplicit-fallthrough=] gestures.cpp:52:5: note: here main.cpp: In function 'QByteArray windowsVersionToString(QSysInfo::WinVersion)': main.cpp:40:12: warning: enumeration value 'WV_CE' not handled in switch [-Wswitch] ... main.cpp: In function 'QByteArray macVersionToString(QSysInfo::MacVersion)': main.cpp:68:12: warning: enumeration value 'MV_10_12' not handled in switch [-Wswitch] ... widget.cpp: In member function 'CustomItem* Widget::checkedItem() const': widget.cpp:238:12: warning: 'item' may be used uninitialized in this function [-Wmaybe-uninitialized] Change-Id: I434784e86d127e56b92663cb45eba7d60d8f8eaf Reviewed-by: Edward Welbourne --- .../manual/gestures/graphicsview/gestures.cpp | 2 ++ tests/manual/qgraphicsitemgroup/widget.cpp | 2 +- tests/manual/qsysinfo/main.cpp | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/manual/gestures/graphicsview/gestures.cpp b/tests/manual/gestures/graphicsview/gestures.cpp index cc0ff3e1aa9..6e5b07bf186 100644 --- a/tests/manual/gestures/graphicsview/gestures.cpp +++ b/tests/manual/gestures/graphicsview/gestures.cpp @@ -44,11 +44,13 @@ QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::recognize(QGesture switch (event->type()) { case QEvent::TouchBegin: result = QGestureRecognizer::MayBeGesture; + break; case QEvent::TouchEnd: if (d->gestureFired) result = QGestureRecognizer::FinishGesture; else result = QGestureRecognizer::CancelGesture; + break; case QEvent::TouchUpdate: if (d->state() != Qt::NoGesture) { QTouchEvent *ev = static_cast(event); diff --git a/tests/manual/qgraphicsitemgroup/widget.cpp b/tests/manual/qgraphicsitemgroup/widget.cpp index b0e7a47cf8c..ba9ed815fa2 100644 --- a/tests/manual/qgraphicsitemgroup/widget.cpp +++ b/tests/manual/qgraphicsitemgroup/widget.cpp @@ -224,7 +224,7 @@ void Widget::updateUngroupButton() CustomItem * Widget::checkedItem() const { - CustomItem *item; + CustomItem *item = nullptr; if (ui->blue->isChecked()) item = rectBlue; diff --git a/tests/manual/qsysinfo/main.cpp b/tests/manual/qsysinfo/main.cpp index 62d0c514167..1d39514236e 100644 --- a/tests/manual/qsysinfo/main.cpp +++ b/tests/manual/qsysinfo/main.cpp @@ -57,6 +57,11 @@ QByteArray windowsVersionToString(QSysInfo::WinVersion v) CASE_VERSION(WV_WINDOWS8_1); CASE_VERSION(WV_WINDOWS10); case QSysInfo::WV_NT_based: // shouldn't happen + case QSysInfo::WV_CE: + case QSysInfo::WV_CENET: + case QSysInfo::WV_CE_5: + case QSysInfo::WV_CE_6: + case QSysInfo::WV_CE_based: break; } @@ -82,6 +87,7 @@ QByteArray macVersionToString(QSysInfo::MacVersion v) CASE_VERSION(MV_10_9); CASE_VERSION(MV_10_10); CASE_VERSION(MV_10_11); + CASE_VERSION(MV_10_12); CASE_VERSION(MV_IOS_4_3); CASE_VERSION(MV_IOS_5_0); @@ -96,8 +102,24 @@ QByteArray macVersionToString(QSysInfo::MacVersion v) CASE_VERSION(MV_IOS_8_3); CASE_VERSION(MV_IOS_8_4); CASE_VERSION(MV_IOS_9_0); + CASE_VERSION(MV_IOS_9_1); + CASE_VERSION(MV_IOS_9_2); + CASE_VERSION(MV_IOS_9_3); + CASE_VERSION(MV_IOS_10_0); case QSysInfo::MV_IOS: // shouldn't happen: + case QSysInfo::MV_TVOS: + case QSysInfo::MV_WATCHOS: break; + + CASE_VERSION(MV_TVOS_9_0); + CASE_VERSION(MV_TVOS_9_1); + CASE_VERSION(MV_TVOS_9_2); + CASE_VERSION(MV_TVOS_10_0); + + CASE_VERSION(MV_WATCHOS_2_0); + CASE_VERSION(MV_WATCHOS_2_1); + CASE_VERSION(MV_WATCHOS_2_2); + CASE_VERSION(MV_WATCHOS_3_0); } if (v & QSysInfo::MV_IOS) { From 3702622dde060442534019bd99cbbf140391547b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Mar 2019 12:28:51 +0100 Subject: [PATCH 5/7] manual tests: Fix build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix QOverload::of(), causing ../../../../include/QtCore/../../src/corelib/global/qglobal.h: In instantiation of ‘struct QConstOverload’: Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr) and add a missing .pro-file. Change-Id: I19597adc33f2323a9f7dea9ee5ce94546f0e8f12 Reviewed-by: Edward Welbourne --- tests/manual/qtabletevent/regular_widgets/main.cpp | 2 +- tests/manual/widgets/widgets/widgets.pro | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/manual/widgets/widgets/widgets.pro diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp index c0366dea63d..4816e2f3b94 100644 --- a/tests/manual/qtabletevent/regular_widgets/main.cpp +++ b/tests/manual/qtabletevent/regular_widgets/main.cpp @@ -284,7 +284,7 @@ int main(int argc, char *argv[]) mainWindow.setWindowTitle(QString::fromLatin1("Tablet Test %1").arg(QT_VERSION_STR)); EventReportWidget *widget = new EventReportWidget; QObject::connect(proximityEventFilter, &ProximityEventFilter::proximityChanged, - widget, QOverload::of(&QWidget::update)); + widget, QOverload<>::of(&QWidget::update)); widget->setMinimumSize(640, 480); QMenu *fileMenu = mainWindow.menuBar()->addMenu("File"); fileMenu->addAction("Clear", widget, &EventReportWidget::clearPoints); diff --git a/tests/manual/widgets/widgets/widgets.pro b/tests/manual/widgets/widgets/widgets.pro new file mode 100644 index 00000000000..1fccb09d791 --- /dev/null +++ b/tests/manual/widgets/widgets/widgets.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs +SUBDIRS = bigmenucreator \ + defaultUpMenuBar \ + multiscreen-menus \ + qtoolbutton/menuOnMultiScreens From 8b3463fdeb3d03fd0c87873089a6f84321eecc49 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 17 Feb 2019 21:02:11 +0100 Subject: [PATCH 6/7] QAbstractItemView: make v-aligned items texts more user-friendly Commit 25133a1b77c059e32760f3d288c985183d86da4a fixed the item view text layouting correctly in a technical way. For a vertically aligned text which does not fit into the given rect it is not user-friendly to show some parts of the text. It is better to display the start of it and show an elide marker in the last visible line. Fixes: QTBUG-73721 Change-Id: Ia7453133ea0a229b24196467168c8371585c4d8f Reviewed-by: Eirik Aavitsland Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qcommonstyle.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 79e338a6e78..c739ddc6e27 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -843,11 +843,14 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut } #endif // QT_CONFIG(toolbutton) -static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth) +static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight = -1, int *lastVisibleLine = nullptr) { + if (lastVisibleLine) + *lastVisibleLine = -1; qreal height = 0; qreal widthUsed = 0; textLayout.beginLayout(); + int i = 0; while (true) { QTextLine line = textLayout.createLine(); if (!line.isValid()) @@ -856,6 +859,13 @@ static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth) line.setPosition(QPointF(0, height)); height += line.height(); widthUsed = qMax(widthUsed, line.naturalTextWidth()); + // we assume that the height of the next line is the same as the current one + if (maxHeight > 0 && lastVisibleLine && height + line.height() > maxHeight) { + const QTextLine nextLine = textLayout.createLine(); + *lastVisibleLine = nextLine.isValid() ? i : -1; + break; + } + ++i; } textLayout.endLayout(); return QSizeF(widthUsed, height); @@ -869,7 +879,13 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex QTextLayout textLayout(text, font); textLayout.setTextOption(textOption); - viewItemTextLayout(textLayout, textRect.width()); + // In AlignVCenter mode when more than one line is displayed and the height only allows + // some of the lines it makes no sense to display those. From a users perspective it makes + // more sense to see the start of the text instead something inbetween. + const bool vAlignmentOptimization = paintStartPosition && valign.testFlag(Qt::AlignVCenter); + + int lastVisibleLine = -1; + viewItemTextLayout(textLayout, textRect.width(), vAlignmentOptimization ? textRect.height() : -1, &lastVisibleLine); const QRectF boundingRect = textLayout.boundingRect(); // don't care about LTR/RTL here, only need the height @@ -896,7 +912,7 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex const int start = line.textStart(); const int length = line.textLength(); const bool drawElided = line.naturalTextWidth() > textRect.width(); - bool elideLastVisibleLine = false; + bool elideLastVisibleLine = lastVisibleLine == i; if (!drawElided && i + 1 < lineCount && lastVisibleLineShouldBeElided) { const QTextLine nextLine = textLayout.lineAt(i + 1); const int nextHeight = height + nextLine.height() / 2; @@ -927,7 +943,8 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex } // below visible text, can stop - if (height + layoutRect.top() >= textRect.bottom()) + if ((height + layoutRect.top() >= textRect.bottom()) || + (lastVisibleLine >= 0 && lastVisibleLine == i)) break; } return ret; From e4749e798585ffe43159fc32a10bf33843c6c5ed Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 6 Mar 2019 11:27:17 +0100 Subject: [PATCH 7/7] Do not mix QByteArray with QString in arithmetic QLatin1String + QByteArray + QLatin1String + QString should not be supported. That the compiler let us get away with this is distressing. Exposed by Anton Kudryavtsev's workon extending QString's operator+ support. Change-Id: I0adfaa87e48335928acb680da49e9173639af614 Reviewed-by: Anton Kudryavtsev Reviewed-by: Friedemann Kleint --- tests/baselineserver/shared/baselineprotocol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp index 80e269ee2ab..c9f9cd9bd29 100644 --- a/tests/baselineserver/shared/baselineprotocol.cpp +++ b/tests/baselineserver/shared/baselineprotocol.cpp @@ -366,7 +366,7 @@ bool BaselineProtocol::connect(const QString &testCase, bool *dryrun, const Plat if (!socket.waitForConnected(Timeout)) { sysSleep(3000); // Wait a bit and try again, the server might just be restarting if (!socket.waitForConnected(Timeout)) { - errMsg += QLS("TCP connectToHost failed. Host:") + serverName + QLS(" port:") + QString::number(ServerPort); + errMsg += QLS("TCP connectToHost failed. Host:") + QLS(serverName) + QLS(" port:") + QString::number(ServerPort); return false; } }