From 0e69230d02813f0b7a050645fb7e443bd504ab6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Martsum?= Date: Mon, 13 Jan 2014 14:29:16 +0100 Subject: [PATCH 01/15] Revert "QAIV - Fix scollbars with ScrollPerPixel to scroll 1 pixel." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 934f06220391eb0e0ebf66a2eb037f48adb4c43c. The patch needs to be modified a bit. Many users considers not having the old feature as a big regression. The feature needs to be improved with a variable that is only set when the user uses setSingleStep. Task-number: QTBUG-33906 Change-Id: I35e5d3e9d3d7a3ebd01807b03a0e7a424185d483 Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qlistview.cpp | 8 ++++---- src/widgets/itemviews/qtableview.cpp | 4 ++-- src/widgets/itemviews/qtreeview.cpp | 4 ++-- .../auto/widgets/itemviews/qtableview/tst_qtableview.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 0cca52daa2a..7f7c60b10ee 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1837,18 +1837,18 @@ void QCommonListViewBase::paintDragDrop(QPainter *painter) } #endif -void QCommonListViewBase::updateHorizontalScrollBar(const QSize & /*step*/) +void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) { + horizontalScrollBar()->setSingleStep(step.width() + spacing()); horizontalScrollBar()->setPageStep(viewport()->width()); horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width()); - // we do not want to overwrite (a possible user set) single step } -void QCommonListViewBase::updateVerticalScrollBar(const QSize & /*step*/) +void QCommonListViewBase::updateVerticalScrollBar(const QSize &step) { + verticalScrollBar()->setSingleStep(step.height() + spacing()); verticalScrollBar()->setPageStep(viewport()->height()); verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height()); - // we do not want to overwrite (a possible user set) single step } void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/) diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 08600b3ef78..a252428a81b 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -2170,7 +2170,7 @@ void QTableView::updateGeometries() } else { // ScrollPerPixel horizontalScrollBar()->setPageStep(vsize.width()); horizontalScrollBar()->setRange(0, horizontalLength - vsize.width()); - // here we do not want to overwrite (a possible user set) single step + horizontalScrollBar()->setSingleStep(qMax(vsize.width() / (columnsInViewport + 1), 2)); } // vertical scroll bar @@ -2198,7 +2198,7 @@ void QTableView::updateGeometries() } else { // ScrollPerPixel verticalScrollBar()->setPageStep(vsize.height()); verticalScrollBar()->setRange(0, verticalLength - vsize.height()); - // here we do not want to overwrite (a possible user set) single step + verticalScrollBar()->setSingleStep(qMax(vsize.height() / (rowsInViewport + 1), 2)); } d->geometryRecursionBlock = false; diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 4d0eb5c3ad3..5d0e835b0e8 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3685,7 +3685,7 @@ void QTreeViewPrivate::updateScrollBars() } vbar->setRange(0, contentsHeight - viewportSize.height()); vbar->setPageStep(viewportSize.height()); - // here we do not want to overwrite (a possible user set) single step + vbar->setSingleStep(qMax(viewportSize.height() / (itemsInViewport + 1), 2)); } const int columnCount = header->count(); @@ -3711,7 +3711,7 @@ void QTreeViewPrivate::updateScrollBars() viewportSize = maxSize; hbar->setPageStep(viewportSize.width()); hbar->setRange(0, qMax(horizontalLength - viewportSize.width(), 0)); - // here we do not want to overwrite (a possible user set) single step + hbar->setSingleStep(qMax(viewportSize.width() / (columnsInViewport + 1), 2)); } } diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 76ac6bcf199..dfb780c8fa9 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -3702,7 +3702,7 @@ void tst_QTableView::mouseWheel_data() << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); QTest::newRow("scroll down per pixel") << int(QAbstractItemView::ScrollPerPixel) << -120 - << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); + << 10 + qApp->wheelScrollLines() * 89 << 10 + qApp->wheelScrollLines() * 28; } void tst_QTableView::mouseWheel() From a813fcf4709811a947f9f39c87bd2145af37c73e Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 15 Jan 2014 14:13:53 +0100 Subject: [PATCH 02/15] Stabilize tst_QAbstractItemView::task200665_itemEntered() It seems that sometimes QCursor::setPos() will not get the opportunity to run the event loop before scrolling the list view unless we do it explicitly. Task-number: QTBUG-35060 Change-Id: Ic635bd8d1a4e3dbcadf9605e88197df6a0f69fc7 Reviewed-by: Frederik Gladhorn --- .../itemviews/qabstractitemview/tst_qabstractitemview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 97ea7d7d32a..d4aad98ae9a 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -1286,6 +1286,7 @@ void tst_QAbstractItemView::task200665_itemEntered() QVERIFY(QTest::qWaitForWindowExposed(&view)); QRect rect = view.visualRect(model.index(0,0)); QCursor::setPos( view.viewport()->mapToGlobal(rect.center()) ); + QCoreApplication::processEvents(); QSignalSpy spy(&view, SIGNAL(entered(QModelIndex))); view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum()); From 6eeab0b0e19818815dffb1ff603bc84aac3ffcb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:15:38 +0100 Subject: [PATCH 03/15] Remove Mac unified toolbar workarounds. QMainWindow::unifiedTitleAndToolBarOnMac() will again return true, but the new implementation is much more similar to the cross platform one so these workarounds are not needed. Task-number: QTBUG-34411 Change-Id: I8f63067f929c94aab252fc2e88f98fb94c870c44 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qtoolbararealayout.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 04ef6a80be1..5ec76569aad 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -655,9 +655,7 @@ QRect QToolBarAreaLayout::fitLayout() docks[QInternal::BottomDock].rect = QRect(rect.left(), center.bottom() + 1, rect.width(), bottom_hint.height()); - if (!mainWindow->unifiedTitleAndToolBarOnMac()) { - docks[QInternal::TopDock].fitLayout(); - } + docks[QInternal::TopDock].fitLayout(); docks[QInternal::LeftDock].fitLayout(); docks[QInternal::RightDock].fitLayout(); docks[QInternal::BottomDock].fitLayout(); @@ -1307,8 +1305,6 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList toolBars = _toolBars; int lines; stream >> lines; - if (!testing) - testing = mainWindow->unifiedTitleAndToolBarOnMac(); for (int j = 0; j < lines; ++j) { int pos; @@ -1319,7 +1315,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList> cnt; QToolBarAreaLayoutInfo &dock = docks[pos]; - const bool applyingLayout = !testing && !(pos == QInternal::TopDock && mainWindow->unifiedTitleAndToolBarOnMac()); + const bool applyingLayout = !testing; QToolBarAreaLayoutLine line(dock.o); for (int k = 0; k < cnt; ++k) { From 7edb5f22bf78cf2691145ab4160998c7b7f9416a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 16 Dec 2013 23:21:43 +0100 Subject: [PATCH 04/15] Implement QMainWindow::setUnifiedTitleAndToolBarOnMac Fix a feature regression from Qt 4. Unlike the Qt 4 implementation this does not move the tool bars out of the QMainWindow while pretending they are still there. Instead, use setContentBorderThickness from the Cocoa platform plugin to draw a background gradient that unifies the title and toolbar area. QToolBar can then draw itself with a transparent background and let the gradient shine throughout. This is a style-only change, toolbar behavior is kept as-is. [ChangeLog][Platform Specific Changes][OS X] Implemented QMainWindow::setUnifiedTitleAndToolBarOnMac. Task-number: QTBUG-34411 Change-Id: Idcaab6399f249b11edb1147856d9aece9923ab36 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmainwindow.cpp | 43 ++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 0638981a9ce..07db78c06cb 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -60,6 +60,9 @@ #include #include "qtoolbar_p.h" #include "qwidgetanimator_p.h" +#ifdef Q_OS_OSX +#include +#endif #ifdef Q_WS_MAC #include #include @@ -76,6 +79,9 @@ class QMainWindowPrivate : public QWidgetPrivate public: inline QMainWindowPrivate() : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) +#ifdef Q_OS_OSX + , useUnifiedToolBar(false) +#endif #ifdef Q_WS_MAC , useHIToolBar(false) , activateUnifiedToolbarAfterFullScreen(false) @@ -88,6 +94,9 @@ public: QSize iconSize; bool explicitIconSize; Qt::ToolButtonStyle toolButtonStyle; +#ifdef Q_OS_OSX + bool useUnifiedToolBar; +#endif #ifdef Q_WS_MAC bool useHIToolBar; bool activateUnifiedToolbarAfterFullScreen; @@ -1492,16 +1501,29 @@ bool QMainWindow::event(QEvent *event) /*! \property QMainWindow::unifiedTitleAndToolBarOnMac \brief whether the window uses the unified title and toolbar look on Mac OS X - \since 4.3 - \obsolete - - This property is not implemented in Qt 5. Setting it has no effect. - - A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras at - http://qt.gitorious.org/qtplayground/qtmacextras + \since 5.2 */ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) { +#ifdef Q_OS_OSX + Q_D(QMainWindow); + if (isWindow()) { + QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); + QPlatformNativeInterface::NativeResourceForIntegrationFunction function = + nativeInterface->nativeResourceFunctionForIntegration("setContentBorderThickness"); + if (!function) + return; // Not Cocoa platform plugin. + + createWinId(); + + d->useUnifiedToolBar = set; + + const int toolBarHeight = 50; + typedef void (*SetContentBorderThicknessFunction)(QWindow *window, int topThickness, int bottomThickness); + (reinterpret_cast(function))(window()->windowHandle(), toolBarHeight, 0); + } +#endif + #ifdef Q_WS_MAC Q_D(QMainWindow); if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3) @@ -1534,6 +1556,9 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) bool QMainWindow::unifiedTitleAndToolBarOnMac() const { +#ifdef Q_OS_OSX + return d_func()->useUnifiedToolBar; +#endif #ifdef Q_WS_MAC return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint); #endif @@ -1655,9 +1680,7 @@ QMenu *QMainWindow::createPopupMenu() for (int i = 0; i < toolbars.size(); ++i) { QToolBar *toolBar = toolbars.at(i); if (toolBar->parentWidget() == this - && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty() - || (unifiedTitleAndToolBarOnMac() - && toolBarArea(toolBar) == Qt::TopToolBarArea))) { + && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty())) { menu->addAction(toolbars.at(i)->toggleViewAction()); } } From 4162ea3f5086782984c6ca34924b9559fcad72f9 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Thu, 2 Jan 2014 13:33:46 +0100 Subject: [PATCH 05/15] Doc: Update links in INSTALL file Documentation URLs no longer use module names in path. Also, the pages discussing installation from source have been renamed. Change-Id: I135dc527ec9170eab62b0ffd1f4a80cdd834e186 Reviewed-by: Jerome Pasion --- INSTALL | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/INSTALL b/INSTALL index 400f6fab14c..2021c501a25 100644 --- a/INSTALL +++ b/INSTALL @@ -1,10 +1,10 @@ INSTALLING Qt Source Package Version %VERSION%. -For full installation instructions for each supported platform, please -see http://qt-project.org/doc/qt-%SHORTVERSION%/qtdoc/installation.html, +For instructions on building and installing Qt for each supported platform, +please see http://qt-project.org/doc/qt-%SHORTVERSION%/build-sources.html, or follow one of these links: -Mac OS X: http://qt-project.org/doc/qt-%SHORTVERSION%/qtdoc/install-mac.html -Windows: http://qt-project.org/doc/qt-%SHORTVERSION%/qtdoc/install-win.html -Windows CE: http://qt-project.org/doc/qt-%SHORTVERSION%/qtdoc/install-wince.html -X11 Platforms: http://qt-project.org/doc/qt-%SHORTVERSION%/qtdoc/install-x11.html +Mac OS X: http://qt-project.org/doc/qt-%SHORTVERSION%/macosx-building.html +Windows: http://qt-project.org/doc/qt-%SHORTVERSION%/windows-building.html +X11 Platforms: http://qt-project.org/doc/qt-%SHORTVERSION%/linux-building.html +Windows CE: http://qt-project.org/doc/qt-%SHORTVERSION%/install-wince.html From 6cbbd1f93d369059e16c62f4b8ba60ad3407d886 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 14 Jan 2014 13:10:09 +0100 Subject: [PATCH 06/15] Cocoa: Popups should not become key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... at least not like that. We still need to find a way for the popup to receive and process key events on its own, instead of depending on other layers inside Qt. This would make Qt Quick control's PopupWindow implementation much simpler, for example. Revert "Cocoa: Allow popups to grab mouse and keyboard" This reverts commit a25e6528d3806d3b5fd87c5a1cacd6c748215db1. Task-number: QTBUG-35820 Task-number: QTBUG-35904 Change-Id: Ica10529308ab25938397c16b9c1e1ce6cbd8f247 Reviewed-by: Gabriel de Dietrich Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 - src/plugins/platforms/cocoa/qcocoawindow.mm | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 66c3241b3de..452be901084 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -211,7 +211,6 @@ public: // for QNSView QRect m_exposedGeometry; int m_registerTouchCount; bool m_resizableTransientParent; - bool m_overrideBecomeKey; static const int NoAlertRequest; NSInteger m_alertRequest; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 8e977236fa4..56665719e89 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -160,9 +160,7 @@ static bool isMouseEvent(NSEvent *ev) // Only tool or dialog windows should become key: if (m_cocoaPlatformWindow - && (m_cocoaPlatformWindow->m_overrideBecomeKey || - m_cocoaPlatformWindow->window()->type() == Qt::Tool || - m_cocoaPlatformWindow->window()->type() == Qt::Dialog)) + && (m_cocoaPlatformWindow->window()->type() == Qt::Tool || m_cocoaPlatformWindow->window()->type() == Qt::Dialog)) return YES; return NO; } @@ -217,7 +215,6 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_isExposed(false) , m_registerTouchCount(0) , m_resizableTransientParent(false) - , m_overrideBecomeKey(false) , m_alertRequest(NoAlertRequest) , monitor(nil) , m_drawContentBorderGradient(false) @@ -705,8 +702,6 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) if (!m_nsWindow) return false; - m_overrideBecomeKey = grab; - if (grab && ![m_nsWindow isKeyWindow]) [m_nsWindow makeKeyWindow]; else if (!grab && [m_nsWindow isKeyWindow]) @@ -719,8 +714,6 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab) if (!m_nsWindow) return false; - m_overrideBecomeKey = grab; - if (grab && ![m_nsWindow isKeyWindow]) [m_nsWindow makeKeyWindow]; else if (!grab && [m_nsWindow isKeyWindow]) From 2565ef220b9f261fc2d62869b8d38625e41bc6fd Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 14 Jan 2014 09:34:47 +0100 Subject: [PATCH 07/15] Revert "Cocoa: fix single punctuation input via CJK input method" This change makes a regression. This reverts commit a79f8a3a6774875fc16fd63461e04c2791a8d03d. Task-number: QTBUG-36033 Change-Id: Ibcb19cd8631f85c81433c9625bbbf280404db1c4 Reviewed-by: Jens Bache-Wiig --- src/plugins/platforms/cocoa/qnsview.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f7b129aea11..ecb6c127aa7 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1346,6 +1346,11 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) { Q_UNUSED(replacementRange) + if (m_sendKeyEvent && m_composingText.isEmpty()) { + // don't send input method events for simple text input (let handleKeyEvent send key events instead) + return; + } + QString commitString; if ([aString length]) { if ([aString isKindOfClass:[NSAttributedString class]]) { From 84be1bd4d3ed8d2d9e65301649bc841ea4197fe2 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 14 Jan 2014 18:27:33 +0200 Subject: [PATCH 08/15] Fix crash due to a stale pointer dereferencing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The HB face caching mechanism introduced in 227e9a40cfeb7e00658cd3 wasn't complete due that fact that HB-NG doesn't parse the entire font table at once but rather references a table on-demand. This incompleteness caused a crash in case the engine doesn't get cached or when it removed from the cache and then re-used. Task-number: QTBUG-36099 Change-Id: I7816836107655ce7cf6eb9683bb5dc7f892f9cd1 Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Michael Krasnyk Reviewed-by: Lars Knoll Reviewed-by: Allan Sandfeld Jensen --- src/gui/text/qfontengine.cpp | 13 ++++++++++++- src/gui/text/qfontengine_ft.cpp | 29 +++++++++++++++++++---------- src/gui/text/qfontengine_p.h | 5 +++++ src/gui/text/qharfbuzzng.cpp | 22 +++++++++++++++------- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 303c85ce75b..9eea2e786f8 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -171,7 +171,8 @@ static const HB_FontClass hb_fontClass = { static HB_Error hb_getSFntTable(void *font, HB_Tag tableTag, HB_Byte *buffer, HB_UInt *length) { QFontEngine *fe = (QFontEngine *)font; - if (!fe->getSfntTableData(tableTag, buffer, length)) + Q_ASSERT(fe->faceData.get_font_table); + if (!fe->faceData.get_font_table(fe->faceData.user_data, tableTag, buffer, length)) return HB_Err_Invalid_Argument; return HB_Err_Ok; } @@ -182,6 +183,13 @@ static void hb_freeFace(void *face) } +static bool qt_get_font_table_default(void *user_data, uint tag, uchar *buffer, uint *length) +{ + QFontEngine *fe = (QFontEngine *)user_data; + return fe->getSfntTableData(tag, buffer, length); +} + + #ifdef QT_BUILD_INTERNAL // for testing purpose only, not thread-safe! static QList *enginesCollector = 0; @@ -210,6 +218,9 @@ QFontEngine::QFontEngine() font_(0), font_destroy_func(0), face_(0), face_destroy_func(0) { + faceData.user_data = this; + faceData.get_font_table = qt_get_font_table_default; + cache_cost = 0; fsType = 0; symbol = false; diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 42cf15ee3b0..05bd014bd75 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -116,6 +116,21 @@ QT_BEGIN_NAMESPACE #define TRUNC(x) ((x) >> 6) #define ROUND(x) (((x)+32) & -64) +static bool ft_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length) +{ + FT_Face face = (FT_Face)user_data; + + bool result = false; + if (FT_IS_SFNT(face)) { + FT_ULong len = *length; + result = FT_Load_Sfnt_Table(face, tag, 0, buffer, &len) == FT_Err_Ok; + *length = len; + } + + return result; +} + + // -------------------------- Freetype support ------------------------------ class QtFreetypeData @@ -408,15 +423,7 @@ QFontEngine::Properties QFreetypeFace::properties() const bool QFreetypeFace::getSfntTable(uint tag, uchar *buffer, uint *length) const { - bool result = false; -#if (FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) > 20103 - if (FT_IS_SFNT(face)) { - FT_ULong len = *length; - result = FT_Load_Sfnt_Table(face, tag, 0, buffer, &len) == FT_Err_Ok; - *length = len; - } -#endif - return result; + return ft_getSfntTable(face, tag, buffer, length); } /* Some fonts (such as MingLiu rely on hinting to scale different @@ -761,6 +768,8 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, fontDef.styleName = QString::fromUtf8(face->style_name); if (!freetype->hbFace) { + faceData.user_data = face; + faceData.get_font_table = ft_getSfntTable; freetype->hbFace = harfbuzzFace(); freetype->hbFace_destroy_func = face_destroy_func; } else { @@ -1179,7 +1188,7 @@ QFixed QFontEngineFT::emSquareSize() const bool QFontEngineFT::getSfntTableData(uint tag, uchar *buffer, uint *length) const { - return freetype->getSfntTable(tag, buffer, length); + return ft_getSfntTable(freetype->face, tag, buffer, length); } int QFontEngineFT::synthesized() const diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index c181d61d738..a04f4bd0ac6 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -85,6 +85,7 @@ enum HB_Compat_Error { }; typedef void (*qt_destroy_func_t) (void *user_data); +typedef bool (*qt_get_font_table_func_t) (void *user_data, uint tag, uchar *buffer, uint *length); class Q_GUI_EXPORT QFontEngine { @@ -280,6 +281,10 @@ public: mutable qt_destroy_func_t font_destroy_func; mutable void *face_; mutable qt_destroy_func_t face_destroy_func; + struct FaceData { + void *user_data; + qt_get_font_table_func_t get_font_table; + } faceData; uint cache_cost; // amount of mem used in kb by the font uint fsType : 16; diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index b4ab5856df2..d2e7df9c10a 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -623,19 +623,22 @@ hb_font_funcs_t *hb_qt_get_font_funcs() static hb_blob_t * -_hb_qt_get_font_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) +_hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) { - QFontEngine *fe = (QFontEngine *)user_data; - Q_ASSERT(fe); + QFontEngine::FaceData *data = (QFontEngine::FaceData *)user_data; + Q_ASSERT(data); + + qt_get_font_table_func_t get_font_table = data->get_font_table; + Q_ASSERT(get_font_table); uint length = 0; - if (Q_UNLIKELY(!fe->getSfntTableData(tag, 0, &length) || length == 0)) + if (Q_UNLIKELY(!get_font_table(data->user_data, tag, 0, &length) || length == 0)) return hb_blob_get_empty(); char *buffer = (char *)malloc(length); Q_CHECK_PTR(buffer); - if (Q_UNLIKELY(!fe->getSfntTableData(tag, reinterpret_cast(buffer), &length))) + if (Q_UNLIKELY(!get_font_table(data->user_data, tag, reinterpret_cast(buffer), &length))) length = 0; return hb_blob_create(const_cast(buffer), length, @@ -646,9 +649,14 @@ _hb_qt_get_font_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) static inline hb_face_t * _hb_qt_face_create(QFontEngine *fe) { - hb_face_t *face; + Q_ASSERT(fe); - face = hb_face_create_for_tables(_hb_qt_get_font_table, (void *)fe, NULL); + QFontEngine::FaceData *data = (QFontEngine::FaceData *)malloc(sizeof(QFontEngine::FaceData)); + Q_CHECK_PTR(data); + data->user_data = fe->faceData.user_data; + data->get_font_table = fe->faceData.get_font_table; + + hb_face_t *face = hb_face_create_for_tables(_hb_qt_reference_table, (void *)data, free); if (Q_UNLIKELY(hb_face_is_immutable(face))) { hb_face_destroy(face); return NULL; From 5dee237022e84a378468c3839e4e7af13cb1246d Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Wed, 15 Jan 2014 13:53:00 +0100 Subject: [PATCH 09/15] [QNX] Set Window usage Set Window usage prior to use the framebuffer. For OpenGL windows set OpenGL usage and for normal painting set it to native usage. Some QNX libscreen implementations don't set usage automatically, so we must set this explicitly. Task-number: QTBUG-35912 Change-Id: I5154c0bcf9c65ef6d47af6a1cf8f17765ccf51dd Reviewed-by: Fabian Bumberger Reviewed-by: Vladimir Minenko Reviewed-by: Giuseppe D'Angelo Reviewed-by: Rafael Roquetto --- src/plugins/platforms/qnx/qqnxeglwindow.cpp | 7 +++++++ src/plugins/platforms/qnx/qqnxrasterwindow.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/platforms/qnx/qqnxeglwindow.cpp b/src/plugins/platforms/qnx/qqnxeglwindow.cpp index b57227a60ba..984de67d7d6 100644 --- a/src/plugins/platforms/qnx/qqnxeglwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxeglwindow.cpp @@ -63,6 +63,13 @@ QQnxEglWindow::QQnxEglWindow(QWindow *window, screen_context_t context, bool nee m_eglSurface(EGL_NO_SURFACE) { initWindow(); + + // Set window usage + const int val = SCREEN_USAGE_OPENGL_ES2; + const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &val); + if (result != 0) + qFatal("QQnxEglWindow: failed to set window alpha usage, errno=%d", errno); + m_requestedBufferSize = screen()->rootWindow() == this ? screen()->geometry().size() : window->geometry().size(); } diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp index 1f974b268d3..0d8daac0eea 100644 --- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp @@ -60,6 +60,12 @@ QQnxRasterWindow::QQnxRasterWindow(QWindow *window, screen_context_t context, bo m_previousBufferIndex(-1) { initWindow(); + + // Set window usage + const int val = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE; + const int result = screen_set_window_property_iv(nativeHandle(), SCREEN_PROPERTY_USAGE, &val); + if (result != 0) + qFatal("QQnxEglWindow: failed to set window alpha usage, errno=%d", errno); } void QQnxRasterWindow::post(const QRegion &dirty) From 0c09d2ccb9b46138a908950d65a49aa58dd55062 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 13 Jan 2014 11:12:34 +0100 Subject: [PATCH 10/15] Windows: Do not try to update keymap on WM_IME_CHAR messages Task-number: QTBUG-35806 Change-Id: Ie1082353155aa7ee61f49f2fbcbfdb01d57e797c Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 1baea6faff0..334df170266 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -743,10 +743,10 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd, return true; } - // WM_CHAR messages already contain the character in question so there is + // WM_(IME_)CHAR messages already contain the character in question so there is // no need to fiddle with our key map. In any other case add this key to the // keymap if it is not present yet. - if (msg.message != WM_CHAR) + if (msg.message != WM_CHAR && msg.message != WM_IME_CHAR) updateKeyMap(msg); MSG peekedMsg; From a19817082caa49309ba425e42f22637628f985d1 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 13 Jan 2014 11:53:43 +0100 Subject: [PATCH 11/15] Use non-threaded render loop on Samsung Galaxy Tab 3 We get EGL_BAD_ACCESS from eglMakeCurrent() on this device, and only on this device, so we simply work around it by disabling the threaded render loop. [ChangeLog][Android] Add workarounds for OpenGL bugs on Samsung Galaxy Tab 3. Task-number: QTBUG-34984 Change-Id: I309881f8317473ff87aea2f92d0f6f1b898342d3 Reviewed-by: Gunnar Sletta --- .../platforms/android/src/androidjnimain.cpp | 10 +++++++++- .../platforms/android/src/androidjnimain.h | 1 + .../src/qandroidplatformintegration.cpp | 18 ++++++++++++++++++ .../android/src/qandroidplatformintegration.h | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp index 3064e5d4e2a..6461fa47331 100644 --- a/src/plugins/platforms/android/src/androidjnimain.cpp +++ b/src/plugins/platforms/android/src/androidjnimain.cpp @@ -418,7 +418,15 @@ namespace QtAndroid { return m_qtTag; } -} + + QString deviceName() + { + QString manufacturer = QJNIObjectPrivate::getStaticObjectField("android/os/Build", "MANUFACTURER", "Ljava/lang/String;").toString(); + QString model = QJNIObjectPrivate::getStaticObjectField("android/os/Build", "MODEL", "Ljava/lang/String;").toString(); + + return manufacturer + QStringLiteral(" ") + model; + } +} // namespace QtAndroid static jboolean startQtAndroidPlugin(JNIEnv* /*env*/, jobject /*object*//*, jobject applicationAssetManager*/) { diff --git a/src/plugins/platforms/android/src/androidjnimain.h b/src/plugins/platforms/android/src/androidjnimain.h index 11d35734043..a7b7072ba39 100644 --- a/src/plugins/platforms/android/src/androidjnimain.h +++ b/src/plugins/platforms/android/src/androidjnimain.h @@ -120,5 +120,6 @@ namespace QtAndroid const char *methodErrorMsgFmt(); const char *qtTagText(); + QString deviceName(); } #endif // ANDROID_APP_H diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index ae3e257d3c7..e09cc40e015 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -89,6 +89,10 @@ void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteA return &m_palettes; if (resource == "AndroidStyleFonts") return &m_fonts; + if (resource == "AndroidDeviceName") { + static QString deviceName = QtAndroid::deviceName(); + return &deviceName; + } return 0; } @@ -119,12 +123,26 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidSystemLocale = new QAndroidSystemLocale; } +bool QAndroidPlatformIntegration::needsBasicRenderloopWorkaround() +{ + static bool needsWorkaround = + QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 + || QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T210"), Qt::CaseInsensitive) == 0 + || QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0; + return needsWorkaround; +} + bool QAndroidPlatformIntegration::hasCapability(Capability cap) const { switch (cap) { case ThreadedPixmaps: return true; case ApplicationState: return true; case NativeWidgets: return false; + + case ThreadedOpenGL: + if (needsBasicRenderloopWorkaround()) + return false; + // fall through default: #ifndef ANDROID_PLUGIN_OPENGL return QPlatformIntegration::hasCapability(cap); diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h index bd08ad694c0..15a8ad33dd8 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h @@ -146,6 +146,7 @@ public: #endif private: + static bool needsBasicRenderloopWorkaround(); friend class QEglFSAndroidHooks; From 09f54e99f2e956908f9104181e7d61fa2f6a027d Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 20 Jan 2014 09:56:24 +0100 Subject: [PATCH 12/15] Cocoa: avoid a crash for cursor in QCocoaWindow It need to be copied. Task-number: QTBUG-35887 Change-Id: Ia165e6a8f9dc23733e53e11f9e1e98bf54e7dd20 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoawindow.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 56665719e89..bf5e0cfbc40 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -264,6 +264,7 @@ QCocoaWindow::~QCocoaWindow() [m_contentView release]; [m_nsWindow release]; [m_nsWindowDelegate release]; + [m_windowCursor release]; } QSurfaceFormat QCocoaWindow::format() const @@ -1059,7 +1060,10 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor) [cursor set]; // or we can set the cursor on mouse enter/leave using tracking // areas. This is done in QNSView, save the cursor: - m_windowCursor = cursor; + if (m_windowCursor != cursor) { + [m_windowCursor release]; + m_windowCursor = [cursor retain]; + } } void QCocoaWindow::registerTouch(bool enable) From c2629632cf82be842a29493f87e6bdbd0b84a974 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 21 Jan 2014 10:23:38 +0100 Subject: [PATCH 13/15] Fix compilation of ANGLE with mingw-tdm64 gcc 4.8.1 Do not rely on sprintf_s being declared/defined. This also fixes deployment to Windows XP. See https://chromium-review.googlesource.com/#/c/182975/ for a similar commit proposed upstream. Task-number: QTBUG-36242 Change-Id: I520e2f61aeab34963e7a57baafd413c7db93f110 Reviewed-by: Friedemann Kleint --- src/3rdparty/angle/src/libEGL/Display.cpp | 2 +- ...-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/angle/patches/0001-Fix-compilation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch diff --git a/src/3rdparty/angle/src/libEGL/Display.cpp b/src/3rdparty/angle/src/libEGL/Display.cpp index a382c3b1eb7..82b48cedcfd 100644 --- a/src/3rdparty/angle/src/libEGL/Display.cpp +++ b/src/3rdparty/angle/src/libEGL/Display.cpp @@ -523,7 +523,7 @@ void Display::initVendorString() if (mRenderer && mRenderer->getLUID(&adapterLuid)) { char adapterLuidString[64]; - sprintf_s(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08x%08x)", adapterLuid.HighPart, adapterLuid.LowPart); + snprintf(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08l%08l)", adapterLuid.HighPart, adapterLuid.LowPart); mVendorString += adapterLuidString; } diff --git a/src/angle/patches/0001-Fix-compilation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch b/src/angle/patches/0001-Fix-compilation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch new file mode 100644 index 00000000000..498cce1b7c5 --- /dev/null +++ b/src/angle/patches/0001-Fix-compilation-of-ANGLE-with-mingw-tdm64-gcc-4.8.1.patch @@ -0,0 +1,33 @@ +From 58a797397378aff3aa039a8b2a2d7011fe788737 Mon Sep 17 00:00:00 2001 +From: Kai Koehne +Date: Tue, 21 Jan 2014 10:23:38 +0100 +Subject: [PATCH] Fix compilation of ANGLE with mingw-tdm64 gcc 4.8.1 + +Do not rely on sprintf_s being declared/defined. This also fixes +deployment to Windows XP. + +See https://chromium-review.googlesource.com/#/c/182975/ for a similar +commit proposed upstream. + +Task-number: QTBUG-36242 +Change-Id: I520e2f61aeab34963e7a57baafd413c7db93f110 +--- + src/3rdparty/angle/src/libEGL/Display.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/3rdparty/angle/src/libEGL/Display.cpp b/src/3rdparty/angle/src/libEGL/Display.cpp +index a382c3b..82b48ce 100644 +--- a/src/3rdparty/angle/src/libEGL/Display.cpp ++++ b/src/3rdparty/angle/src/libEGL/Display.cpp +@@ -523,7 +523,7 @@ void Display::initVendorString() + if (mRenderer && mRenderer->getLUID(&adapterLuid)) + { + char adapterLuidString[64]; +- sprintf_s(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08x%08x)", adapterLuid.HighPart, adapterLuid.LowPart); ++ snprintf(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08l%08l)", adapterLuid.HighPart, adapterLuid.LowPart); + + mVendorString += adapterLuidString; + } +-- +1.8.5.2.msysgit.0 + From 909dbb92eb8ae607142e4316c01058090faaf1c7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 20 Jan 2014 08:38:27 +0100 Subject: [PATCH 14/15] Work around FBO readback bug on Samsung Galaxy Tab 3 Symptom of the error is garbled text in Qt Quick 2, and the fix has been confirmed to be enabling the texture resize workaround. Task-number: QTBUG-34984 Change-Id: If6f621b43120c7913cbd33ab326c52ad6e2599bc Reviewed-by: Gunnar Sletta --- .../android/src/opengl/qandroidopenglcontext.cpp | 8 +++++--- .../platforms/android/src/qandroidplatformintegration.cpp | 4 ++-- .../platforms/android/src/qandroidplatformintegration.h | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp b/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp index 6431914812b..d94bb241f78 100644 --- a/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp +++ b/src/plugins/platforms/android/src/opengl/qandroidopenglcontext.cpp @@ -82,12 +82,14 @@ void QAndroidOpenGLContext::swapBuffers(QPlatformSurface *surface) bool QAndroidOpenGLContext::makeCurrent(QPlatformSurface *surface) { bool ret = QEglFSContext::makeCurrent(surface); + QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); const char *rendererString = reinterpret_cast(glGetString(GL_RENDERER)); - if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) { - QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); + if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) ctx_d->workaround_missingPrecisionQualifiers = true; - } + + if (!ctx_d->workaround_brokenFBOReadBack && QAndroidPlatformIntegration::needsWorkaround()) + ctx_d->workaround_brokenFBOReadBack = true; return ret; } diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index e09cc40e015..e4a2ad582de 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -123,7 +123,7 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_androidSystemLocale = new QAndroidSystemLocale; } -bool QAndroidPlatformIntegration::needsBasicRenderloopWorkaround() +bool QAndroidPlatformIntegration::needsWorkaround() { static bool needsWorkaround = QtAndroid::deviceName().compare(QStringLiteral("samsung SM-T211"), Qt::CaseInsensitive) == 0 @@ -140,7 +140,7 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const case NativeWidgets: return false; case ThreadedOpenGL: - if (needsBasicRenderloopWorkaround()) + if (needsWorkaround()) return false; // fall through default: diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h index 15a8ad33dd8..474c1e837e0 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h @@ -145,9 +145,9 @@ public: QEglFSScreen *createScreen() const; #endif -private: - static bool needsBasicRenderloopWorkaround(); + static bool needsWorkaround(); +private: friend class QEglFSAndroidHooks; QTouchDevice *m_touchDevice; From 9eba69d7f914e4823e94699c5653df5ad279eb46 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 21 Jan 2014 08:42:05 +0100 Subject: [PATCH 15/15] Fix a bug in some QString comparison operators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some comparison operators comparing to const char * where not implemented correctly. Task-number: QTBUG-34024 Change-Id: Idbdc64c8ed93e88d9f2b2f55213bc785b33cb543 Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qstring.h | 8 +-- .../corelib/tools/qstring/tst_qstring.cpp | 56 +++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 0a0a6097281..9778d42c1de 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -1029,13 +1029,13 @@ inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QString &s2) inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QString &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) != 0; } inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QString &s2) -{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; } -inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) > 0; } +inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2) +{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) < 0; } inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QString &s2) -{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; } -inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2) { return QString::compare_helper(s2.constData(), s2.size(), s1, -1) >= 0; } +inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2) +{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; } inline QT_ASCII_CAST_WARN bool operator==(const char *s1, QLatin1String s2) { return QString::fromUtf8(s1) == s2; } diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 48874781c02..12fe5259d92 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -4419,6 +4419,62 @@ void tst_QString::operator_smaller() // operator< is not locale-aware (or shouldn't be) QVERIFY( foo < QString("\xc3\xa9") ); QVERIFY( foo < "\xc3\xa9" ); + + QVERIFY(QString("a") < QString("b")); + QVERIFY(QString("a") <= QString("b")); + QVERIFY(QString("a") <= QString("a")); + QVERIFY(QString("a") == QString("a")); + QVERIFY(QString("a") >= QString("a")); + QVERIFY(QString("b") >= QString("a")); + QVERIFY(QString("b") > QString("a")); + + QVERIFY("a" < QString("b")); + QVERIFY("a" <= QString("b")); + QVERIFY("a" <= QString("a")); + QVERIFY("a" == QString("a")); + QVERIFY("a" >= QString("a")); + QVERIFY("b" >= QString("a")); + QVERIFY("b" > QString("a")); + + QVERIFY(QString("a") < "b"); + QVERIFY(QString("a") <= "b"); + QVERIFY(QString("a") <= "a"); + QVERIFY(QString("a") == "a"); + QVERIFY(QString("a") >= "a"); + QVERIFY(QString("b") >= "a"); + QVERIFY(QString("b") > "a"); + + QVERIFY(QLatin1String("a") < QString("b")); + QVERIFY(QLatin1String("a") <= QString("b")); + QVERIFY(QLatin1String("a") <= QString("a")); + QVERIFY(QLatin1String("a") == QString("a")); + QVERIFY(QLatin1String("a") >= QString("a")); + QVERIFY(QLatin1String("b") >= QString("a")); + QVERIFY(QLatin1String("b") > QString("a")); + + QVERIFY(QString("a") < QLatin1String("b")); + QVERIFY(QString("a") <= QLatin1String("b")); + QVERIFY(QString("a") <= QLatin1String("a")); + QVERIFY(QString("a") == QLatin1String("a")); + QVERIFY(QString("a") >= QLatin1String("a")); + QVERIFY(QString("b") >= QLatin1String("a")); + QVERIFY(QString("b") > QLatin1String("a")); + + QVERIFY("a" < QLatin1String("b")); + QVERIFY("a" <= QLatin1String("b")); + QVERIFY("a" <= QLatin1String("a")); + QVERIFY("a" == QLatin1String("a")); + QVERIFY("a" >= QLatin1String("a")); + QVERIFY("b" >= QLatin1String("a")); + QVERIFY("b" > QLatin1String("a")); + + QVERIFY(QLatin1String("a") < "b"); + QVERIFY(QLatin1String("a") <= "b"); + QVERIFY(QLatin1String("a") <= "a"); + QVERIFY(QLatin1String("a") == "a"); + QVERIFY(QLatin1String("a") >= "a"); + QVERIFY(QLatin1String("b") >= "a"); + QVERIFY(QLatin1String("b") > "a"); } void tst_QString::integer_conversion_data()