diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-03-09 01:00:19 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-03-09 01:00:20 +0100 |
commit | fbc9fb233dfb1959924632b428048d5f6a3401d9 (patch) | |
tree | b9c2acc3fa61789f84a78ad7144beda53ccc0570 /src | |
parent | caa74f16d41ebe65e1edbea219f799cf246d6067 (diff) | |
parent | e4749e798585ffe43159fc32a10bf33843c6c5ed (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Ica3f89ace33585ad7854417a328156f5a68e2a00
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qcollator_win.cpp | 34 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 5 | ||||
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 7 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 25 |
4 files changed, 60 insertions, 11 deletions
diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp index 35142bb8b8..10cfdaa264 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<const wchar_t*>(s1), len1, - reinterpret_cast<const wchar_t*>(s2), len2) - 2; + const int ret = CompareString(d->localeID, d->collator, + reinterpret_cast<const wchar_t*>(s1), len1, + reinterpret_cast<const wchar_t*>(s2), len2); #else - return CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator, - reinterpret_cast<LPCWSTR>(s1), len1, - reinterpret_cast<LPCWSTR>(s2), len2, NULL, NULL, 0) - 2; + const int ret = CompareStringEx(LPCWSTR(d->localeName.utf16()), d->collator, + reinterpret_cast<LPCWSTR>(s1), len1, + reinterpret_cast<LPCWSTR>(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 diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 9df3d73dd7..f79a4d1dc6 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -967,7 +967,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 { diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 609430fba6..caab6c16ba 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 diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index b064b2eff2..a3461d8848 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -846,11 +846,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()) @@ -859,6 +862,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); @@ -872,7 +882,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 @@ -899,7 +915,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; @@ -930,7 +946,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; |