From 38a0909d4ed39b49e0463bd780d20a82ea672d35 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 20 Oct 2017 12:42:29 +0200 Subject: [PATCH 01/56] tst_qnetworkreply: Replace insignificant_test with blacklisting Neither the exit crash of QTBUG-21102 nor the Windows failure of QTBUG-24226 appear to be reproduceable. Add verbose error reporting to getErrors() and blacklist getErrors:ftp-host which has been found to fail with timeouts on Linux and ioHttpRedirectMultipartPost. Task-number: QTBUG-21102 Task-number: QTBUG-24226 Task-number: QTBUG-62860 Change-Id: I6b29f6184e83de8ffebf6ff0d80606512dca6419 Reviewed-by: Timur Pocheptsov --- .../network/access/qnetworkreply/BLACKLIST | 20 +++++++++++++++++++ .../access/qnetworkreply/test/test.pro | 3 --- .../qnetworkreply/tst_qnetworkreply.cpp | 13 +++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index 1d56c78bbcb..f2ccefb9d65 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -1,5 +1,7 @@ # See qtbase/src/testlib/qtestblacklist.cpp for format osx +[authenticationCacheAfterCancel] +windows [ioGetFromBuiltinHttp:http+limited] ubuntu-14.04 [ioGetFromBuiltinHttp:https+limited] @@ -8,3 +10,21 @@ ubuntu-14.04 * [backgroundRequestInterruption:ftp, bg, nobg] * +[getErrors:ftp-host] +linux +[getFromHttpIntoBuffer] +windows +[getFromHttpIntoBuffer2] +windows +[headFromHttp] +windows +[ioGetFromHttpWithSocksProxy] +windows +[ioPostToHttpFromSocket] +windows +[ioHttpRedirectMultipartPost] +linux +[putWithServerClosingConnectionImmediately] +windows +[qtbug28035browserDoesNotLoadQtProjectOrgCorrectly] +windows diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro index 0dcf5a250c6..1f45ac0c498 100644 --- a/tests/auto/network/access/qnetworkreply/test/test.pro +++ b/tests/auto/network/access/qnetworkreply/test/test.pro @@ -13,7 +13,4 @@ RESOURCES += ../qnetworkreply.qrc TESTDATA += ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg ../certs \ ../index.html ../smb-file.txt -qtConfig(xcb): CONFIG+=insignificant_test # unstable, QTBUG-21102 -win32:CONFIG += insignificant_test # QTBUG-24226 - !winrt: TEST_HELPER_INSTALLS = ../echo/echo diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 93afca3d489..099ea8ff39c 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1994,6 +1994,16 @@ void tst_QNetworkReply::getErrors_data() << int(QNetworkReply::AuthenticationRequiredError) << 401 << false; } +static QByteArray msgGetErrors(int waitResult, const QNetworkReplyPtr &reply) +{ + QByteArray result ="waitResult=" + QByteArray::number(waitResult); + if (reply->isFinished()) + result += ", finished"; + if (reply->error() != QNetworkReply::NoError) + result += ", error: " + QByteArray::number(int(reply->error())); + return result; +} + void tst_QNetworkReply::getErrors() { QFETCH(QString, url); @@ -2023,7 +2033,8 @@ void tst_QNetworkReply::getErrors() QCOMPARE(reply->error(), QNetworkReply::NoError); // now run the request: - QVERIFY(waitForFinish(reply) != Timeout); + const int waitResult = waitForFinish(reply); + QVERIFY2(waitResult != Timeout, msgGetErrors(waitResult, reply)); QFETCH(int, error); QEXPECT_FAIL("ftp-is-dir", "QFtp cannot provide enough detail", Abort); From 01c7b474f5ad2c9fcf4b90c71048624070811618 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 26 Oct 2017 11:01:11 +0200 Subject: [PATCH 02/56] tst_QMenuBar: Port to QWindow-based mouse test API Add some helpers to convert the coordinates and change the code to use the QWindow-based mouse test API. Remove mouse presses on the second and third menu from task256322_highlight() since moving the mouse is sufficient to switch menus. Remove blacklisting/skipping of macOS and offscreen. Task-number: QTBUG-63988 Change-Id: If3e94170d11df369aec199d13d54d39382a78723 Reviewed-by: Gatis Paeglis --- tests/auto/widgets/widgets/qmenubar/BLACKLIST | 2 - .../widgets/widgets/qmenubar/tst_qmenubar.cpp | 71 ++++++++++--------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST index ee08086e83c..e2194e69ca7 100644 --- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST +++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST @@ -1,5 +1,3 @@ [check_menuPosition] ubuntu-14.04 ubuntu-16.04 -[task256322_highlight] -osx diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index bc50e4f1d87..12afb772813 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -48,6 +48,18 @@ QT_FORWARD_DECLARE_CLASS(QMainWindow) #include +// Helper to calculate the action position in window coordinates +static inline QPoint widgetToWindowPos(const QWidget *w, const QPoint &pos) +{ + const QWindow *window = w->window()->windowHandle(); + Q_ASSERT(window); + return window->mapFromGlobal(w->mapToGlobal(pos)); +} + +static QPoint menuBarActionWindowPos(const QMenuBar *mb, QAction *a) +{ + return widgetToWindowPos(mb, mb->actionGeometry(a).center()); +} class Menu : public QMenu { @@ -1194,21 +1206,19 @@ void tst_QMenuBar::check_menuPosition() menu.close(); } -# ifndef QT_NO_CURSOR // QTBUG-28031: Click at bottom-right corner. { w.move(400, 200); LayoutDirectionSaver directionSaver(Qt::RightToLeft); QMenuBar *mb = w.menuBar(); - const QPoint localPos = mb->actionGeometry(menu.menuAction()).bottomRight() - QPoint(1, 1); - const QPoint globalPos = mb->mapToGlobal(localPos); - QCursor::setPos(globalPos); - QTest::mouseClick(mb, Qt::LeftButton, 0, localPos); + const QPoint bottomRight = mb->actionGeometry(menu.menuAction()).bottomRight() - QPoint(1, 1); + const QPoint localPos = widgetToWindowPos(mb, bottomRight); + const QPoint globalPos = w.mapToGlobal(localPos); + QTest::mouseClick(w.windowHandle(), Qt::LeftButton, 0, localPos); QTRY_VERIFY(menu.isActiveWindow()); QCOMPARE(menu.geometry().right() - 1, globalPos.x()); menu.close(); } -# endif // QT_NO_CURSOR } #endif @@ -1246,10 +1256,8 @@ void tst_QMenuBar::task223138_triggered() void tst_QMenuBar::task256322_highlight() { - if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive) - || !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) { - QSKIP("Highlighting does not work correctly for minimal/offscreen platforms"); - } + if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) + QSKIP("Highlighting does not work correctly for minimal platform"); QMainWindow win; win.menuBar()->setNativeMenuBar(false); //we can't check the geometry of native menubars @@ -1266,31 +1274,26 @@ void tst_QMenuBar::task256322_highlight() QApplication::setActiveWindow(&win); QVERIFY(QTest::qWaitForWindowActive(&win)); - QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); - QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file).center()); - QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center()); + const QPoint filePos = menuBarActionWindowPos(win.menuBar(), file); + QWindow *window = win.windowHandle(); + QTest::mousePress(window, Qt::LeftButton, 0, filePos); + QTest::mouseMove(window, filePos); + QTest::mouseRelease(window, Qt::LeftButton, 0, filePos); QTRY_VERIFY(menu.isVisible()); QVERIFY(!menu2.isVisible()); QCOMPARE(win.menuBar()->activeAction(), file); - QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center()); - QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file2).center()); + const QPoint file2Pos = menuBarActionWindowPos(win.menuBar(), file2); + QTest::mouseMove(window, file2Pos); QTRY_VERIFY(!menu.isVisible()); - QVERIFY(menu2.isVisible()); + QTRY_VERIFY(menu2.isVisible()); QCOMPARE(win.menuBar()->activeAction(), file2); - QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center()); - QPoint nothingCenter = win.menuBar()->actionGeometry(nothing).center(); - QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, nothingCenter); - QTest::mouseMove(win.menuBar(), nothingCenter); + QPoint nothingCenter = menuBarActionWindowPos(win.menuBar(), nothing); + QTest::mouseMove(window, nothingCenter); QTRY_VERIFY(!menu2.isVisible()); QVERIFY(!menu.isVisible()); -#ifdef Q_OS_MAC - if (win.menuBar()->activeAction() != nothing) - QEXPECT_FAIL("", "QTBUG-30565: Unstable test", Continue); -#endif QTRY_COMPARE(win.menuBar()->activeAction(), nothing); - QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, nothingCenter); } void tst_QMenuBar::menubarSizeHint() @@ -1427,9 +1430,6 @@ void tst_QMenuBar::closeOnSecondClickAndOpenOnThirdClick() // QTBUG-32807, menu QMainWindow mainWindow; mainWindow.resize(300, 200); centerOnScreen(&mainWindow); -#ifndef QT_NO_CURSOR - QCursor::setPos(mainWindow.geometry().topLeft() - QPoint(100, 0)); -#endif QMenuBar *menuBar = mainWindow.menuBar(); menuBar->setNativeMenuBar(false); QMenu *fileMenu = menuBar->addMenu(QStringLiteral("OpenCloseOpen")); @@ -1437,14 +1437,17 @@ void tst_QMenuBar::closeOnSecondClickAndOpenOnThirdClick() // QTBUG-32807, menu mainWindow.show(); QApplication::setActiveWindow(&mainWindow); QVERIFY(QTest::qWaitForWindowActive(&mainWindow)); - const QPoint center = menuBar->actionGeometry(fileMenu->menuAction()).center(); - const QPoint globalPos = menuBar->mapToGlobal(center); - QTest::mouseMove(menuBar, center); - QTest::mouseClick(menuBar, Qt::LeftButton, 0, center); + + const QPoint center = menuBarActionWindowPos(mainWindow.menuBar(), fileMenu->menuAction()); + const QPoint globalPos = mainWindow.mapToGlobal(center); + + QWindow *window = mainWindow.windowHandle(); + QTest::mouseMove(window, center); + QTest::mouseClick(window, Qt::LeftButton, 0, center); QTRY_VERIFY(fileMenu->isVisible()); - QTest::mouseClick(fileMenu, Qt::LeftButton, 0, fileMenu->mapFromGlobal(globalPos)); + QTest::mouseClick(window, Qt::LeftButton, 0, fileMenu->mapFromGlobal(globalPos)); QTRY_VERIFY(!fileMenu->isVisible()); - QTest::mouseClick(menuBar, Qt::LeftButton, 0, center); + QTest::mouseClick(window, Qt::LeftButton, 0, center); QTRY_VERIFY(fileMenu->isVisible()); } From 1a647926528136850c8a0e4c2aa5ae23e22172ea Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 30 Oct 2017 09:58:15 +0100 Subject: [PATCH 03/56] tst_QTcpSocket::suddenRemoteDisconnect - fix flakyness This test starts two processes - server and client - and requires an external executable ('stressTest'). In .pro file we have SUBDIRS containing both 'test' (test itself) and 'stressTest' (client/server app), but there is no explicit dependency and as result we run the test before we build 'stressTest' thus failing to start those processes. This patch makes 'test' dependent on 'stressTest'. Task-number: QTBUG-36629 Change-Id: I286b08bcff86b9afc4bbee87a75e887527eaf5f2 Reviewed-by: Gatis Paeglis --- tests/auto/network/socket/qtcpsocket/qtcpsocket.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro b/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro index 1183b235565..1f13a396dd9 100644 --- a/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro +++ b/tests/auto/network/socket/qtcpsocket/qtcpsocket.pro @@ -1,6 +1,8 @@ TEMPLATE = subdirs SUBDIRS = test -!vxworks: SUBDIRS += stressTest - +!vxworks{ +SUBDIRS += stressTest +test.depends = stressTest +} requires(qtConfig(private_tests)) From b409cfa094c327cae0303c6fff39ae5dbb49ad80 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 30 Oct 2017 11:18:44 +0100 Subject: [PATCH 04/56] tst_QNetworkReply::ioHttpRedirectPolicy - blacklist for b2qt 64bit This test fails often and seems to be flaky. Task-number: QTBUG-62583 Change-Id: Id3af283c89e392634a7af6e11bd05775a4295798 Reviewed-by: Gatis Paeglis --- tests/auto/network/access/qnetworkreply/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index f2ccefb9d65..5edae13e346 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -24,6 +24,8 @@ windows windows [ioHttpRedirectMultipartPost] linux +[ioHttpRedirectPolicy] +b2qt 64bit [putWithServerClosingConnectionImmediately] windows [qtbug28035browserDoesNotLoadQtProjectOrgCorrectly] From acdb3340321d1b8823b54f2ea492f975c6f942d8 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 27 Oct 2017 08:36:25 +0200 Subject: [PATCH 05/56] Fix dragging inside a modal window when a QShapedPixmapWindow is used A regression was introduced with a3d59c7c7f675b0a4e128efeb781aa1c2f7db4c0 which caused dragging to fail within a modal dialog on the XCB platform. By adding an exception for the QShapedPixmapWindow, which is the window used for the drag, we can allow that to continue to work whilst blocking to the other newly created windows. Task-number: QTBUG-63846 Change-Id: I7c7f365f30fcf5f04f50dc1a7fff7a09e6e5ed6c Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 43b201e9b03..9e5b6878511 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -54,6 +54,7 @@ # include "qaccessible.h" #endif #include "qhighdpiscaling_p.h" +#include "qshapedpixmapdndwindow_p.h" #include @@ -576,7 +577,9 @@ void QWindow::setVisible(bool visible) QGuiApplicationPrivate::showModalWindow(this); else QGuiApplicationPrivate::hideModalWindow(this); - } else if (visible && QGuiApplication::modalWindow()) { + // QShapedPixmapWindow is used on some platforms for showing a drag pixmap, so don't block + // input to this window as it is performing a drag - QTBUG-63846 + } else if (visible && QGuiApplication::modalWindow() && !qobject_cast(this)) { QGuiApplicationPrivate::updateBlockedStatus(this); } From 8f1277da8c137270ff857128d8fea1423d8a7700 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 22 Oct 2017 21:39:31 +0200 Subject: [PATCH 06/56] QStorageInfo: Properly decode labels from /dev/disk/by-label udev encodes the labels for /dev/disk/by-label/ with ID_LABEL_FS_ENC which is done with blkid_encode_string(). This function encodes some unsafe 1-byte utf-8 characters as hex (e.g. '\' or ' ') Task-number: QTBUG-61420 Change-Id: If82f4381d348acf9008b79ec5ac7c55e6d3819de Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 9072b34f547..1fc32e0f2d8 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -544,6 +544,38 @@ void QStorageInfoPrivate::initRootPath() } } +#ifdef Q_OS_LINUX +// udev encodes the labels with ID_LABEL_FS_ENC which is done with +// blkid_encode_string(). Within this function some 1-byte utf-8 +// characters not considered safe (e.g. '\' or ' ') are encoded as hex +static QString decodeFsEncString(const QString &str) +{ + QString decoded; + decoded.reserve(str.size()); + + int i = 0; + while (i < str.size()) { + if (i <= str.size() - 4) { // we need at least four characters \xAB + if (str.at(i) == QLatin1Char('\\') && + str.at(i+1) == QLatin1Char('x')) { + bool bOk; + const int code = str.midRef(i+2, 2).toInt(&bOk, 16); + // only decode characters between 0x20 and 0x7f but not + // the backslash to prevent collisions + if (bOk && code >= 0x20 && code < 0x80 && code != '\\') { + decoded += QChar(code); + i += 4; + continue; + } + } + } + decoded += str.at(i); + ++i; + } + return decoded; +} +#endif + static inline QString retrieveLabel(const QByteArray &device) { #ifdef Q_OS_LINUX @@ -557,7 +589,7 @@ static inline QString retrieveLabel(const QByteArray &device) it.next(); QFileInfo fileInfo(it.fileInfo()); if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath) - return fileInfo.fileName(); + return decodeFsEncString(fileInfo.fileName()); } #elif defined Q_OS_HAIKU fs_info fsInfo; From a4f9cf23444dd76a11d4eb67c4ea65d5c3948894 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sat, 29 Jul 2017 11:28:13 +0200 Subject: [PATCH 07/56] Disable window shortcuts if there is a window modal dialog If a window is blocked by a WindowModal dialog, it should not be possible to trigger window shortcuts on that window if it receives a WindowActivate event. This currently happens if the blocked window gets clicked, because the window becomes the active_window and then QApplication sends it a WindowActivate event (this doesn't happen with application modal dialogs). The correctWidgetContext() function calls QApplicationPrivate::tryModalHelper() only if the shortcut context is ApplicationShortcut. This patch makes it call even if the shortcut context is WindowShortcut. Change-Id: Iff87d85bcae603a6a24128e0cedfa9d33b6485fd Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qshortcut.cpp | 2 +- .../widgets/kernel/qaction/tst_qaction.cpp | 52 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index f944a7097b4..32600d41522 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -205,7 +205,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge #if defined(DEBUG_QSHORTCUTMAP) qDebug().nospace() << "..true [Pass-through]"; #endif - return true; + return QApplicationPrivate::tryModalHelper(w, nullptr); } #if QT_CONFIG(graphicsview) diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 3535e465b3c..88ddb7c11d2 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -26,7 +26,8 @@ ** ****************************************************************************/ - +#include +#include #include #include @@ -63,6 +64,8 @@ private slots: void task229128TriggeredSignalWhenInActiongroup(); void repeat(); void setData(); + void disableShortcutsWithBlockedWidgets_data(); + void disableShortcutsWithBlockedWidgets(); private: int m_lastEventType; @@ -424,5 +427,52 @@ void tst_QAction::setData() // QTBUG-62006 QCOMPARE(spy.count(), 1); } +void tst_QAction::disableShortcutsWithBlockedWidgets_data() +{ + QTest::addColumn("shortcutContext"); + QTest::addColumn("windowModality"); + + QTest::newRow("application modal dialog should block window shortcut.") + << Qt::WindowShortcut << Qt::ApplicationModal; + + QTest::newRow("application modal dialog should block application shortcut.") + << Qt::ApplicationShortcut << Qt::ApplicationModal; + + QTest::newRow("window modal dialog should block application shortcut.") + << Qt::ApplicationShortcut << Qt::WindowModal; + + QTest::newRow("window modal dialog should block window shortcut.") + << Qt::WindowShortcut << Qt::WindowModal; +} + + +void tst_QAction::disableShortcutsWithBlockedWidgets() +{ + QMainWindow window; + + QFETCH(Qt::ShortcutContext, shortcutContext); + QAction action(&window); + window.addAction(&action); + action.setShortcut(QKeySequence(Qt::Key_1)); + action.setShortcutContext(shortcutContext); + + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QDialog dialog(&window); + QFETCH(Qt::WindowModality, windowModality); + dialog.setWindowModality(windowModality); + + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + + QApplication::setActiveWindow(&window); + QVERIFY(QTest::qWaitForWindowActive(&window)); + + QSignalSpy spy(&action, &QAction::triggered); + QTest::keyPress(&window, Qt::Key_1); + QCOMPARE(spy.count(), 0); +} + QTEST_MAIN(tst_QAction) #include "tst_qaction.moc" From 937ded010b09250c6ab9a57917f2e430fb5875f5 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 28 Oct 2017 19:13:58 +0200 Subject: [PATCH 08/56] QListView: make sure to respect grid size during dataChanged() handling When the dataChanged() signal is handled by QIconModeViewBase, the size of the items are recalculated. During this operation the optional grid size is not taken into account which leads to a screwed up layout. This patch adds the missing check similar it is done in doStaticLayout()/doDynamicLayout(). Task-number: QTBUG-45427 Change-Id: Iba7adb44b1510c511a69c289ccb4f168992a6871 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qlistview.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 9e959c8e1ec..9217fec10e8 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -2874,10 +2874,19 @@ void QIconModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { if (column() >= topLeft.column() && column() <= bottomRight.column()) { - QStyleOptionViewItem option = viewOptions(); - int bottom = qMin(items.count(), bottomRight.row() + 1); + const QStyleOptionViewItem option = viewOptions(); + const int bottom = qMin(items.count(), bottomRight.row() + 1); + const bool useItemSize = !dd->grid.isValid(); for (int row = topLeft.row(); row < bottom; ++row) - items[row].resize(itemSize(option, modelIndex(row))); + { + QSize s = itemSize(option, modelIndex(row)); + if (!useItemSize) + { + s.setWidth(qMin(dd->grid.width(), s.width())); + s.setHeight(qMin(dd->grid.height(), s.height())); + } + items[row].resize(s); + } } } From ca0f05ebe2a6a8e51e4c58b2994620cc51638a3f Mon Sep 17 00:00:00 2001 From: Sami Nurmenniemi Date: Fri, 3 Nov 2017 09:47:00 +0200 Subject: [PATCH 09/56] Skip d-bus tests also on armv7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both of the new toolchains (armv7 + arm64) have some problems with d-bus tests. Skip them until the toolchain has been fixed. Task-number: QTBUG-60263 Change-Id: Ic300f419635fb6b49b3ea7f48fa76c19088c88bd Reviewed-by: Tony Sarajärvi --- tests/auto/auto.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 3caa6a3b65b..a1ffe5b3cee 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -46,5 +46,5 @@ else:!qtConfig(process): SUBDIRS -= tools # QTBUG-63915 boot2qt: { - contains(QT_ARCH, arm64): SUBDIRS -= dbus + SUBDIRS -= dbus } From 851c226247d692a608d78a1d7f9e621f4a82f40d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 2 Nov 2017 08:56:09 +0100 Subject: [PATCH 10/56] QFilesystemWatcher/Windows: Use event dispatcher of thread Previously, the native event filter listening on removable drivers was installed on QCoreApplication::eventDispatcher() which led to a mismatch when launched from a non-GUI thread since ~QAbstractNativeEventFilter() removes itself from QAbstractEventDispatcher::instance(). Amends 45580aa92557caa4f3f5be783573ddb80602e494, e612fe8d47bc0fe762668617a5189117ad1aee15. Task-number: QTBUG-64171 Change-Id: Icbe289bd585f124d66989d0cd574040b986e680c Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemwatcher_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index cdb79e7c97d..9e43d11e714 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -308,7 +308,7 @@ void QWindowsRemovableDriveListener::addPath(const QString &p) notify.dbch_size = sizeof(notify); notify.dbch_devicetype = DBT_DEVTYP_HANDLE; notify.dbch_handle = volumeHandle; - QEventDispatcherWin32 *winEventDispatcher = static_cast(QCoreApplication::eventDispatcher()); + QEventDispatcherWin32 *winEventDispatcher = static_cast(QAbstractEventDispatcher::instance()); re.devNotify = RegisterDeviceNotification(winEventDispatcher->internalHwnd(), ¬ify, DEVICE_NOTIFY_WINDOW_HANDLE); // Empirically found: The notifications also work when the handle is immediately @@ -336,7 +336,7 @@ QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent : QFileSystemWatcherEngine(parent) { #ifndef Q_OS_WINRT - if (QAbstractEventDispatcher *eventDispatcher = QCoreApplication::eventDispatcher()) { + if (QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance()) { m_driveListener = new QWindowsRemovableDriveListener(this); eventDispatcher->installNativeEventFilter(m_driveListener); parent->setProperty("_q_driveListener", From d366d6dfd30de6e6f83afc807a4648f008b396e5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Oct 2017 13:21:22 +0200 Subject: [PATCH 11/56] Windows QPA: Restrict file dialog to file system items in Directory mode Qt cannot handle places like 'Network', etc. Task-number: QTBUG-63645 Change-Id: I53d0eedc2996af6a1ec3230e3d65a3e272aa3710 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index f4527bcc600..75ca090ceff 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1010,7 +1010,9 @@ void QWindowsNativeFileDialogBase::setMode(QFileDialogOptions::FileMode mode, break; case QFileDialogOptions::Directory: case QFileDialogOptions::DirectoryOnly: - flags |= FOS_PICKFOLDERS | FOS_FILEMUSTEXIST; + // QTBUG-63645: Restrict to file system items, as Qt cannot deal with + // places like 'Network', etc. + flags |= FOS_PICKFOLDERS | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM; break; case QFileDialogOptions::ExistingFiles: flags |= FOS_FILEMUSTEXIST | FOS_ALLOWMULTISELECT; @@ -1219,6 +1221,8 @@ void QWindowsNativeFileDialogBase::onSelectionChange() { const QList current = selectedFiles(); m_data.setSelectedFiles(current); + qDebug() << __FUNCTION__ << current << current.size(); + if (current.size() == 1) emit currentChanged(current.front()); } From b4ac5525612812dd411c93e671813d079a152e57 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Oct 2017 13:28:44 +0200 Subject: [PATCH 12/56] Windows QPA: Pass on Url of non-filesystem directory items Do not attempt to copy directory items, which will fail and result in empty result lists. Amends 5865e582fd537fff530c13301e5229a7b4ed21c7. Task-number: QTBUG-57070 Task-number: QTBUG-63645 Change-Id: I59efce196b28099ec8aff5a802ef0a4d9a098453 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 75ca090ceff..4b08528d174 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1419,7 +1419,7 @@ QList QWindowsNativeOpenFileDialog::dialogResult() const for (IShellItem *item : QWindowsShellItem::itemsFromItemArray(items)) { QWindowsShellItem qItem(item); const QString path = qItem.path(); - if (path.isEmpty()) { + if (path.isEmpty() && !qItem.isDir()) { const QString temporaryCopy = createTemporaryItemCopy(qItem); if (temporaryCopy.isEmpty()) qWarning() << "Unable to create a local copy of" << qItem; From 92c61b11c1704450adfa3a8ac839478c0f3dd19d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Oct 2017 15:23:39 +0200 Subject: [PATCH 13/56] Windows: Use SM_CXSMICON instead of SM_CXICON for the tray icon size Partially reverts b465fe759695bb7e1de693c3d4d20acfd2c49779. Task-number: QTBUG-63447 Change-Id: Iaf8a54b59a054e33811f65f64322af3aa746885e Reviewed-by: Oliver Wolff --- src/widgets/util/qsystemtrayicon_win.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index 3f007f24c19..57d46912e01 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -313,9 +313,8 @@ HICON QSystemTrayIconSys::createIcon() const QIcon icon = q->icon(); if (icon.isNull()) return oldIcon; - const QSize requestedSize = QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA - ? QSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)) - : QSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); + // When merging this to 5.10, change at src/plugins/platforms/windows/qwindowssystemtrayicon.cpp:351. + const QSize requestedSize = QSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); const QSize size = icon.actualSize(requestedSize); const QPixmap pm = icon.pixmap(size); if (pm.isNull()) From d674d227f7ab22aed206d3a7f5c96e5e8dfa48f2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 6 Apr 2017 13:20:18 -0700 Subject: [PATCH 14/56] qGlobalQHashSeed: initialize the seed before returning it If you had never used QHash before, this function returned -1. That's not useful if you're trying to implement your own QHash that uses Qt's global seed. Change-Id: Ib0e40a7a3ebc44329f23fffd14b2e875b970a55c Reviewed-by: Lars Knoll --- src/corelib/tools/qhash.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 4cc9ec8ec81..1662e944cf8 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -361,6 +361,7 @@ static void qt_initialize_qhash_seed() */ int qGlobalQHashSeed() { + qt_initialize_qhash_seed(); return qt_qhash_seed.load(); } From 484a186f50de59279cf3c02088273ff114f4cfcf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 4 Oct 2017 12:00:57 -0700 Subject: [PATCH 15/56] QNativeSocketEngine/Win: fix getting the datagram destination Looks like I never even tested this. There were two problems: 1) when we asked for the recvmsg and sendmsg functions, we used the wrong variable (socketDescriptor was still -1) 2) we extracted the destination addresses, but never set them in the QIpPacketHeader object The added tests confirm that this works on Windows, Linux, Darwin, FreeBSD. There also seems to be a problem, obtaining the destination address on an IPv4 socket with a dual-stack sender (I can reproduce that on FreeBSD, macOS and Windows, plus an old version of Linux). Task-number: QTBUG-63605 Change-Id: I638cf58bfa7b4e5fb386fffd14ea732bddbc0c42 Reviewed-by: Timur Pocheptsov --- .../socket/qnativesocketengine_win.cpp | 20 +- .../network/socket/qudpsocket/test/test.pro | 1 + .../socket/qudpsocket/tst_qudpsocket.cpp | 171 +++++++++++++----- 3 files changed, 137 insertions(+), 55 deletions(-) diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index eb633eb1d2e..3ecfb06411d 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -408,13 +408,13 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc // get the pointer to sendmsg and recvmsg DWORD bytesReturned; GUID recvmsgguid = WSAID_WSARECVMSG; - if (WSAIoctl(socketDescriptor, SIO_GET_EXTENSION_FUNCTION_POINTER, + if (WSAIoctl(socket, SIO_GET_EXTENSION_FUNCTION_POINTER, &recvmsgguid, sizeof(recvmsgguid), &recvmsg, sizeof(recvmsg), &bytesReturned, NULL, NULL) == SOCKET_ERROR) recvmsg = 0; GUID sendmsgguid = WSAID_WSASENDMSG; - if (WSAIoctl(socketDescriptor, SIO_GET_EXTENSION_FUNCTION_POINTER, + if (WSAIoctl(socket, SIO_GET_EXTENSION_FUNCTION_POINTER, &sendmsgguid, sizeof(sendmsgguid), &sendmsg, sizeof(sendmsg), &bytesReturned, NULL, NULL) == SOCKET_ERROR) sendmsg = 0; @@ -1257,26 +1257,28 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxL qt_socket_getPortAndAddress(socketDescriptor, &aa, &header->senderPort, &header->senderAddress); } - if (ret != -1 && recvmsg) { + if (ret != -1 && recvmsg && options != QAbstractSocketEngine::WantNone) { // get the ancillary data + header->destinationPort = localPort; WSACMSGHDR *cmsgptr; for (cmsgptr = WSA_CMSG_FIRSTHDR(&msg); cmsgptr != NULL; cmsgptr = WSA_CMSG_NXTHDR(&msg, cmsgptr)) { if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_PKTINFO && cmsgptr->cmsg_len >= WSA_CMSG_LEN(sizeof(in6_pktinfo))) { in6_pktinfo *info = reinterpret_cast(WSA_CMSG_DATA(cmsgptr)); - QHostAddress target(reinterpret_cast(&info->ipi6_addr)); - if (info->ipi6_ifindex) - target.setScopeId(QString::number(info->ipi6_ifindex)); + + header->destinationAddress.setAddress(reinterpret_cast(&info->ipi6_addr)); + header->ifindex = info->ipi6_ifindex; + if (header->ifindex) + header->destinationAddress.setScopeId(QString::number(info->ipi6_ifindex)); } if (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_PKTINFO && cmsgptr->cmsg_len >= WSA_CMSG_LEN(sizeof(in_pktinfo))) { in_pktinfo *info = reinterpret_cast(WSA_CMSG_DATA(cmsgptr)); u_long addr; WSANtohl(socketDescriptor, info->ipi_addr.s_addr, &addr); - QHostAddress target(addr); - if (info->ipi_ifindex) - target.setScopeId(QString::number(info->ipi_ifindex)); + header->destinationAddress.setAddress(addr); + header->ifindex = info->ipi_ifindex; } if (cmsgptr->cmsg_len == WSA_CMSG_LEN(sizeof(int)) diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index 73486a2bc3e..e856776ddcf 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -1,6 +1,7 @@ CONFIG += testcase testcase.timeout = 800 # this test is slow SOURCES += ../tst_qudpsocket.cpp +INCLUDEPATH += ../../../../../shared/ QT = core network testlib MOC_DIR=tmp diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index aeb6e61cd21..0f46caa7c29 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2017 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -45,6 +45,7 @@ #include #include "../../../network-settings.h" +#include "emulationdetector.h" #ifndef QT_NO_BEARERMANAGEMENT #include @@ -227,6 +228,9 @@ void tst_QUdpSocket::initTestCase() QSKIP("No network test server available"); allAddresses = QNetworkInterface::allAddresses(); m_skipUnsupportedIPv6Tests = shouldSkipIpv6TestsForBrokenSetsockopt(); + + if (EmulationDetector::isRunningArmOnX86()) + QSKIP("This test is unreliable due to QEMU emulation shortcomings."); } void tst_QUdpSocket::init() @@ -445,31 +449,58 @@ void tst_QUdpSocket::loop() paul.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - QVERIFY2(peter.bind(), peter.errorString().toLatin1().constData()); - QVERIFY2(paul.bind(), paul.errorString().toLatin1().constData()); + // make sure we bind to IPv4 + QHostAddress localhost = QHostAddress::LocalHost; + QVERIFY2(peter.bind(localhost), peter.errorString().toLatin1().constData()); + QVERIFY2(paul.bind(localhost), paul.errorString().toLatin1().constData()); QHostAddress peterAddress = makeNonAny(peter.localAddress()); - QHostAddress pualAddress = makeNonAny(paul.localAddress()); + QHostAddress paulAddress = makeNonAny(paul.localAddress()); QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), - pualAddress, paul.localPort()), qint64(peterMessage.length())); + paulAddress, paul.localPort()), qint64(peterMessage.length())); QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), peterAddress, peter.localPort()), qint64(paulMessage.length())); QVERIFY2(peter.waitForReadyRead(9000), QtNetworkSettings::msgSocketError(peter).constData()); QVERIFY2(paul.waitForReadyRead(9000), QtNetworkSettings::msgSocketError(paul).constData()); - char peterBuffer[16*1024]; - char paulBuffer[16*1024]; + + QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.length() * 2); + QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.length() * 2); if (success) { - QCOMPARE(peter.readDatagram(peterBuffer, sizeof(peterBuffer)), qint64(paulMessage.length())); - QCOMPARE(paul.readDatagram(paulBuffer, sizeof(peterBuffer)), qint64(peterMessage.length())); + QCOMPARE(peterDatagram.data().length(), qint64(paulMessage.length())); + QCOMPARE(paulDatagram.data().length(), qint64(peterMessage.length())); } else { - QVERIFY(peter.readDatagram(peterBuffer, sizeof(peterBuffer)) != paulMessage.length()); - QVERIFY(paul.readDatagram(paulBuffer, sizeof(peterBuffer)) != peterMessage.length()); + // this code path seems to never be executed + QVERIFY(peterDatagram.data().length() != paulMessage.length()); + QVERIFY(paulDatagram.data().length() != peterMessage.length()); } - QCOMPARE(QByteArray(peterBuffer, paulMessage.length()), paulMessage); - QCOMPARE(QByteArray(paulBuffer, peterMessage.length()), peterMessage); + QCOMPARE(peterDatagram.data().left(paulMessage.length()), paulMessage); + QCOMPARE(paulDatagram.data().left(peterMessage.length()), peterMessage); + + QCOMPARE(peterDatagram.senderAddress(), paulAddress); + QCOMPARE(paulDatagram.senderAddress(), peterAddress); + QCOMPARE(paulDatagram.senderPort(), int(peter.localPort())); + QCOMPARE(peterDatagram.senderPort(), int(paul.localPort())); + + // Unlike for IPv6 with IPV6_PKTINFO, IPv4 has no standardized way of + // obtaining the packet's destination addresses. The destinationAddress and + // destinationPort calls could fail, so whitelist the OSes for which we + // know we have an implementation. +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) || defined(Q_OS_WIN) + QVERIFY(peterDatagram.destinationPort() != -1); + QVERIFY(paulDatagram.destinationPort() != -1); +#endif + if (peterDatagram.destinationPort() == -1) { + QCOMPARE(peterDatagram.destinationAddress().protocol(), QAbstractSocket::UnknownNetworkLayerProtocol); + QCOMPARE(paulDatagram.destinationAddress().protocol(), QAbstractSocket::UnknownNetworkLayerProtocol); + } else { + QCOMPARE(peterDatagram.destinationAddress(), makeNonAny(peter.localAddress())); + QCOMPARE(paulDatagram.destinationAddress(), makeNonAny(paul.localAddress())); + QVERIFY(peterDatagram.destinationAddress().isEqual(makeNonAny(peter.localAddress()))); + QVERIFY(paulDatagram.destinationAddress().isEqual(makeNonAny(paul.localAddress()))); + } } //---------------------------------------------------------------------------------- @@ -492,8 +523,8 @@ void tst_QUdpSocket::ipv6Loop() paul.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - quint16 peterPort; - quint16 paulPort; + int peterPort; + int paulPort; if (!peter.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)) { QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError); @@ -502,6 +533,8 @@ void tst_QUdpSocket::ipv6Loop() QVERIFY(paul.bind(QHostAddress(QHostAddress::LocalHostIPv6), 0)); + QHostAddress peterAddress = makeNonAny(peter.localAddress()); + QHostAddress paulAddress = makeNonAny(paul.localAddress()); peterPort = peter.localPort(); paulPort = paul.localPort(); @@ -510,20 +543,33 @@ void tst_QUdpSocket::ipv6Loop() QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), QHostAddress("::1"), peterPort), qint64(paulMessage.length())); - char peterBuffer[16*1024]; - char paulBuffer[16*1024]; QVERIFY(peter.waitForReadyRead(5000)); QVERIFY(paul.waitForReadyRead(5000)); + QNetworkDatagram peterDatagram = peter.receiveDatagram(paulMessage.length() * 2); + QNetworkDatagram paulDatagram = paul.receiveDatagram(peterMessage.length() * 2); + if (success) { - QCOMPARE(peter.readDatagram(peterBuffer, sizeof(peterBuffer)), qint64(paulMessage.length())); - QCOMPARE(paul.readDatagram(paulBuffer, sizeof(peterBuffer)), qint64(peterMessage.length())); + QCOMPARE(peterDatagram.data().length(), qint64(paulMessage.length())); + QCOMPARE(paulDatagram.data().length(), qint64(peterMessage.length())); } else { - QVERIFY(peter.readDatagram(peterBuffer, sizeof(peterBuffer)) != paulMessage.length()); - QVERIFY(paul.readDatagram(paulBuffer, sizeof(peterBuffer)) != peterMessage.length()); + // this code path seems to never be executed + QVERIFY(peterDatagram.data().length() != paulMessage.length()); + QVERIFY(paulDatagram.data().length() != peterMessage.length()); } - QCOMPARE(QByteArray(peterBuffer, paulMessage.length()), paulMessage); - QCOMPARE(QByteArray(paulBuffer, peterMessage.length()), peterMessage); + QCOMPARE(peterDatagram.data().left(paulMessage.length()), paulMessage); + QCOMPARE(paulDatagram.data().left(peterMessage.length()), peterMessage); + + QCOMPARE(peterDatagram.senderAddress(), paulAddress); + QCOMPARE(paulDatagram.senderAddress(), peterAddress); + QCOMPARE(paulDatagram.senderPort(), peterPort); + QCOMPARE(peterDatagram.senderPort(), paulPort); + + // For IPv6, IPV6_PKTINFO is a mandatory feature (RFC 3542). + QCOMPARE(peterDatagram.destinationAddress(), makeNonAny(peter.localAddress())); + QCOMPARE(paulDatagram.destinationAddress(), makeNonAny(paul.localAddress())); + QCOMPARE(peterDatagram.destinationPort(), peterPort); + QCOMPARE(paulDatagram.destinationPort(), paulPort); } void tst_QUdpSocket::dualStack() @@ -539,17 +585,23 @@ void tst_QUdpSocket::dualStack() QByteArray v4Data("v4"); QVERIFY(v4Sock.bind(QHostAddress(QHostAddress::AnyIPv4), 0)); - QHostAddress from; - quint16 port; - QByteArray buffer; //test v4 -> dual QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.length(), QHostAddress(QHostAddress::LocalHost), dualSock.localPort()), v4Data.length()); QVERIFY2(dualSock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(dualSock).constData()); - buffer.reserve(100); - qint64 size = dualSock.readDatagram(buffer.data(), 100, &from, &port); - QCOMPARE((int)size, v4Data.length()); - buffer.resize(size); - QCOMPARE(buffer, v4Data); + QNetworkDatagram dgram = dualSock.receiveDatagram(100); + QVERIFY(dgram.isValid()); + QCOMPARE(dgram.data(), v4Data); + QCOMPARE(dgram.senderPort(), int(v4Sock.localPort())); + // receiving v4 on dual stack will receive as IPv6, so use isEqual() + QVERIFY(dgram.senderAddress().isEqual(makeNonAny(v4Sock.localAddress(), QHostAddress::Null))); + if (dualSock.localAddress().protocol() == QAbstractSocket::IPv4Protocol) + QCOMPARE(dgram.senderAddress(), makeNonAny(v4Sock.localAddress(), QHostAddress::Null)); + if (dgram.destinationPort() != -1) { + QCOMPARE(dgram.destinationPort(), int(dualSock.localPort())); + QVERIFY(dgram.destinationAddress().isEqual(dualSock.localAddress())); + } else { + qInfo("Getting IPv4 destination address failed."); + } if (QtNetworkSettings::hasIPv6()) { QUdpSocket v6Sock; @@ -559,30 +611,41 @@ void tst_QUdpSocket::dualStack() //test v6 -> dual QCOMPARE((int)v6Sock.writeDatagram(v6Data.constData(), v6Data.length(), QHostAddress(QHostAddress::LocalHostIPv6), dualSock.localPort()), v6Data.length()); QVERIFY2(dualSock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(dualSock).constData()); - buffer.reserve(100); - size = dualSock.readDatagram(buffer.data(), 100, &from, &port); - QCOMPARE((int)size, v6Data.length()); - buffer.resize(size); - QCOMPARE(buffer, v6Data); + dgram = dualSock.receiveDatagram(100); + QVERIFY(dgram.isValid()); + QCOMPARE(dgram.data(), v6Data); + QCOMPARE(dgram.senderPort(), int(v6Sock.localPort())); + QCOMPARE(dgram.senderAddress(), makeNonAny(v6Sock.localAddress(), QHostAddress::LocalHostIPv6)); + QCOMPARE(dgram.destinationPort(), int(dualSock.localPort())); + QCOMPARE(dgram.destinationAddress(), makeNonAny(dualSock.localAddress(), QHostAddress::LocalHostIPv6)); //test dual -> v6 QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length()); QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData()); - buffer.reserve(100); - size = v6Sock.readDatagram(buffer.data(), 100, &from, &port); - QCOMPARE((int)size, dualData.length()); - buffer.resize(size); - QCOMPARE(buffer, dualData); + dgram = v6Sock.receiveDatagram(100); + QVERIFY(dgram.isValid()); + QCOMPARE(dgram.data(), dualData); + QCOMPARE(dgram.senderPort(), int(dualSock.localPort())); + QCOMPARE(dgram.senderAddress(), makeNonAny(dualSock.localAddress(), QHostAddress::LocalHostIPv6)); + QCOMPARE(dgram.destinationPort(), int(v6Sock.localPort())); + QCOMPARE(dgram.destinationAddress(), makeNonAny(v6Sock.localAddress(), QHostAddress::LocalHostIPv6)); } //test dual -> v4 QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length()); QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData()); - buffer.reserve(100); - size = v4Sock.readDatagram(buffer.data(), 100, &from, &port); - QCOMPARE((int)size, dualData.length()); - buffer.resize(size); - QCOMPARE(buffer, dualData); + dgram = v4Sock.receiveDatagram(100); + QVERIFY(dgram.isValid()); + QCOMPARE(dgram.data(), dualData); + QCOMPARE(dgram.senderPort(), int(dualSock.localPort())); + QCOMPARE(dgram.senderAddress(), makeNonAny(dualSock.localAddress(), QHostAddress::LocalHost)); +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) || defined(Q_OS_WIN) + QVERIFY(dgram.destinationPort() != -1); +#endif + if (dgram.destinationPort() != -1) { + QCOMPARE(dgram.destinationPort(), int(v4Sock.localPort())); + QCOMPARE(dgram.destinationAddress(), makeNonAny(v4Sock.localAddress(), QHostAddress::LocalHost)); + } } void tst_QUdpSocket::dualStackAutoBinding() @@ -1603,6 +1666,8 @@ void tst_QUdpSocket::linkLocalIPv6() QVERIFY(dgram.isValid()); QCOMPARE(dgram.senderAddress(), s->localAddress()); QCOMPARE(dgram.senderPort(), int(s->localPort())); + QCOMPARE(dgram.destinationAddress(), s->localAddress()); + QCOMPARE(dgram.destinationPort(), int(neutral.localPort())); QCOMPARE(dgram.data().length(), testData.length()); QCOMPARE(dgram.data(), testData); @@ -1684,6 +1749,20 @@ void tst_QUdpSocket::linkLocalIPv4() QCOMPARE(dgram.data().length(), testData.length()); QCOMPARE(dgram.data(), testData); + // Unlike for IPv6 with IPV6_PKTINFO, IPv4 has no standardized way of + // obtaining the packet's destination addresses. The destinationAddress + // and destinationPort calls could fail, so whitelist the OSes we know + // we have an implementation. +#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) || defined(Q_OS_WIN) + QVERIFY(dgram.destinationPort() != -1); +#endif + if (dgram.destinationPort() == -1) { + QCOMPARE(dgram.destinationAddress().protocol(), QAbstractSocket::UnknownNetworkLayerProtocol); + } else { + QCOMPARE(dgram.destinationAddress(), s->localAddress()); + QCOMPARE(dgram.destinationPort(), int(neutral.localPort())); + } + QVERIFY(neutral.writeDatagram(dgram.makeReply(testData))); dgram = s->receiveDatagram(testData.length() * 2); From 84396a3f938453b81e6ecc73bd54ff6b08960e8f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 3 Nov 2017 13:55:50 +0100 Subject: [PATCH 16/56] tst_QNetworkReply: Blacklist ioHttpRedirectPostPut for Linux Change-Id: I7db143bbd2e178e944f4cfc6c184850238f3bc8c Reviewed-by: Timur Pocheptsov --- tests/auto/network/access/qnetworkreply/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index 5edae13e346..091ec28beaa 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -26,6 +26,8 @@ windows linux [ioHttpRedirectPolicy] b2qt 64bit +[ioHttpRedirectPostPut] +linux [putWithServerClosingConnectionImmediately] windows [qtbug28035browserDoesNotLoadQtProjectOrgCorrectly] From 254849b62a4aa5a34f18bf8e47a9cb9293d3f8b9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 30 Oct 2017 09:15:23 +0100 Subject: [PATCH 17/56] macOS: Blacklist tst_QSequentialAnimationGroup::groupWithZeroDurationAnimations() Task-number: QTBUG-64109 Change-Id: Iebe5a07d108ba647baa74ded71b730c867bd1c41 Reviewed-by: Jesus Fernandez --- .../auto/corelib/animation/qsequentialanimationgroup/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST index 391e3f67af8..2a31afd7352 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST @@ -3,3 +3,5 @@ windows [finishWithUncontrolledAnimation] windows osx-10.12 +[groupWithZeroDurationAnimations] +osx From 01f5f77c66dd6e4c15e0e0d8445e3560543e1973 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 30 Oct 2017 13:44:03 +0100 Subject: [PATCH 18/56] tests: skip tst_QMenuBar::check_cursorKeys* on Unity This test is flaky on Unity due to regression introduced by QTBUG-39362. Skip the test functions until QTBUG-39362 is resolved. These test functions do not fail on Gnome and KDE, so the functionality tested by check_cursorKeys* will be covered by other linux distributions in CI. Change-Id: Ifd1a7779a9728142424f4956dd6466c822ccde91 Reviewed-by: Frederik Gladhorn --- tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 12afb772813..65181a9516d 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -633,6 +633,9 @@ void tst_QMenuBar::check_accelKeys() #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys1() { + if (qgetenv("XDG_CURRENT_DESKTOP") == "Unity") + QSKIP("This test is flaky on Ubuntu/Unity due to regression introduced by QTBUG-39362"); + QMainWindow w; initWindowWithComplexMenuBar(w); w.show(); @@ -667,6 +670,9 @@ void tst_QMenuBar::check_cursorKeys1() #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys2() { + if (qgetenv("XDG_CURRENT_DESKTOP") == "Unity") + QSKIP("This test is flaky on Ubuntu/Unity due to regression introduced by QTBUG-39362"); + QMainWindow w; initWindowWithComplexMenuBar(w); w.show(); @@ -700,6 +706,9 @@ void tst_QMenuBar::check_cursorKeys2() #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys3() { + if (qgetenv("XDG_CURRENT_DESKTOP") == "Unity") + QSKIP("This test is flaky on Ubuntu/Unity due to regression introduced by QTBUG-39362"); + QMainWindow w; initWindowWithComplexMenuBar(w); w.show(); From ad36da8ff416501e249beb098e5b84eaa2fba43d Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 30 Oct 2017 13:45:18 +0100 Subject: [PATCH 19/56] testlib: start sharing common helper functions ... by moving them in QTestPrivate namespace (qtesthelpers_p.h). This header file is a convenient staging area for helper APIs, eventually some could be moved to public QTest API. This header file utilizes the same pattern as other qtestlib header files - wrapping functions with QT_${LIBNAME}_LIB to automatically enable certain APIs based on what is in the projects dependencies, e.g. QT += widgets. Change-Id: Ic0266429939c1f3788912ad8b84fc6e0d5edd68b Reviewed-by: Edward Welbourne --- src/testlib/qtesthelpers_p.h | 112 ++++++++++++++++++ src/testlib/testlib.pro | 3 +- .../io/qtemporarydir/qtemporarydir.pro | 2 +- .../io/qtemporarydir/tst_qtemporarydir.cpp | 13 +- .../io/qtemporaryfile/qtemporaryfile.pro | 2 +- .../io/qtemporaryfile/tst_qtemporaryfile.cpp | 16 +-- .../other/qaccessibility/qaccessibility.pro | 2 +- .../qaccessibility/tst_qaccessibility.cpp | 12 +- .../qgraphicsitem/qgraphicsitem.pro | 2 +- .../qgraphicsitem/tst_qgraphicsitem.cpp | 14 +-- .../qgraphicsview/qgraphicsview.pro | 2 +- .../qgraphicsview/tst_qgraphicsview.cpp | 12 +- .../qabstractitemview/qabstractitemview.pro | 2 +- .../tst_qabstractitemview.cpp | 15 +-- .../itemviews/qcolumnview/qcolumnview.pro | 2 +- .../itemviews/qcolumnview/tst_qcolumnview.cpp | 11 +- .../widgets/itemviews/qlistview/qlistview.pro | 2 +- .../itemviews/qlistview/tst_qlistview.cpp | 14 +-- .../itemviews/qtableview/qtableview.pro | 2 +- .../itemviews/qtableview/tst_qtableview.cpp | 14 +-- .../widgets/itemviews/qtreeview/qtreeview.pro | 2 +- .../itemviews/qtreeview/tst_qtreeview.cpp | 14 +-- .../widgets/kernel/qboxlayout/qboxlayout.pro | 2 +- .../kernel/qboxlayout/tst_qboxlayout.cpp | 10 +- .../kernel/qformlayout/qformlayout.pro | 2 +- .../kernel/qformlayout/tst_qformlayout.cpp | 12 +- .../kernel/qgridlayout/qgridlayout.pro | 2 +- .../kernel/qgridlayout/tst_qgridlayout.cpp | 12 +- tests/auto/widgets/kernel/qlayout/qlayout.pro | 2 +- .../widgets/kernel/qlayout/tst_qlayout.cpp | 10 +- tests/auto/widgets/kernel/qwidget/qwidget.pro | 2 +- .../widgets/kernel/qwidget/tst_qwidget.cpp | 19 +-- .../kernel/qwidget_window/qwidget_window.pro | 2 +- .../qwidget_window/tst_qwidget_window.cpp | 10 +- .../kernel/qwidgetaction/qwidgetaction.pro | 2 +- .../qwidgetaction/tst_qwidgetaction.cpp | 10 +- tests/auto/widgets/styles/qstyle/qstyle.pro | 2 +- .../auto/widgets/styles/qstyle/tst_qstyle.cpp | 12 +- .../qstylesheetstyle/qstylesheetstyle.pro | 2 +- .../qstylesheetstyle/tst_qstylesheetstyle.cpp | 7 +- .../widgets/util/qcompleter/qcompleter.pro | 2 +- .../util/qcompleter/tst_qcompleter.cpp | 10 +- .../qabstractslider/qabstractslider.pro | 2 +- .../qabstractslider/tst_qabstractslider.cpp | 12 +- .../qabstractspinbox/qabstractspinbox.pro | 2 +- .../qabstractspinbox/tst_qabstractspinbox.cpp | 13 +- .../widgets/widgets/qcombobox/qcombobox.pro | 2 +- .../widgets/qcombobox/tst_qcombobox.cpp | 10 +- .../widgets/widgets/qlineedit/qlineedit.pro | 2 +- .../widgets/qlineedit/tst_qlineedit.cpp | 12 +- tests/auto/widgets/widgets/qmenu/qmenu.pro | 2 +- .../auto/widgets/widgets/qmenu/tst_qmenu.cpp | 14 +-- .../widgets/widgets/qmenubar/qmenubar.pro | 2 +- .../widgets/widgets/qmenubar/tst_qmenubar.cpp | 10 +- .../widgets/widgets/qscrollbar/qscrollbar.pro | 2 +- .../widgets/qscrollbar/tst_qscrollbar.cpp | 11 +- 56 files changed, 223 insertions(+), 275 deletions(-) create mode 100644 src/testlib/qtesthelpers_p.h diff --git a/src/testlib/qtesthelpers_p.h b/src/testlib/qtesthelpers_p.h new file mode 100644 index 00000000000..0e39f7aea2a --- /dev/null +++ b/src/testlib/qtesthelpers_p.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $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 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 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. +** +** 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$ +** +****************************************************************************/ + +#ifndef QTESTHELPERS_P_H +#define QTESTHELPERS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +#ifdef QT_GUI_LIB +#include +#include +#endif + +#ifdef QT_WIDGETS_LIB +#include +#endif + +QT_BEGIN_NAMESPACE + +namespace QTestPrivate { + +static inline bool canHandleUnicodeFileNames() +{ +#if defined(Q_OS_WIN) + return true; +#else + // Check for UTF-8 by converting the Euro symbol (see tst_utf8) + return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254"); +#endif +} + +#ifdef QT_WIDGETS_LIB +static inline void centerOnScreen(QWidget *w, const QSize &size) +{ + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); +} + +static inline void centerOnScreen(QWidget *w) +{ + centerOnScreen(w, w->geometry().size()); +} + +/*! \internal + + Make a widget frameless to prevent size constraints of title bars from interfering (Windows). +*/ +static inline void setFrameless(QWidget *w) +{ + Qt::WindowFlags flags = w->windowFlags(); + flags |= Qt::FramelessWindowHint; + flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint + | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + w->setWindowFlags(flags); +} +#endif // QT_WIDGETS_LIB + +} // namespace QTestPrivate + +QT_END_NAMESPACE + +#endif // QTESTHELPERS_P_H diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index e11e25e1dac..f99f28ca849 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -37,7 +37,8 @@ HEADERS = qbenchmark.h \ qtestspontaneevent.h \ qtestsystem.h \ qtesttouch.h \ - qtestblacklist_p.h + qtestblacklist_p.h \ + qtesthelpers_p.h SOURCES = qtestcase.cpp \ qtestlog.cpp \ diff --git a/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro b/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro index 351e2630939..5908648378d 100644 --- a/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro +++ b/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro @@ -4,4 +4,4 @@ SOURCES += tst_qtemporarydir.cpp INCLUDEPATH += ../../../../shared/ HEADERS += ../../../../shared/emulationdetector.h -QT = core testlib +QT = core testlib testlib-private diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 4bed8d0fd6b..4cb3bfe5490 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef Q_OS_WIN # include #endif @@ -112,16 +113,6 @@ void tst_QTemporaryDir::getSetCheck() QCOMPARE(true, obj1.autoRemove()); } -static inline bool canHandleUnicodeFileNames() -{ -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - return true; -#else - // Check for UTF-8 by converting the Euro symbol (see tst_utf8) - return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254"); -#endif -} - static QString hanTestText() { QString text; @@ -160,7 +151,7 @@ void tst_QTemporaryDir::fileTemplate_data() QTest::newRow("constructor with XXXX suffix") << "qt_XXXXXX_XXXX" << "qt_"; QTest::newRow("constructor with XXXX prefix") << "qt_XXXX" << "qt_"; QTest::newRow("constructor with XXXXX prefix") << "qt_XXXXX" << "qt_"; - if (canHandleUnicodeFileNames()) { + if (QTestPrivate::canHandleUnicodeFileNames()) { // Test Umlauts (contained in Latin1) QString prefix = "qt_" + umlautTestText(); QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix; diff --git a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro index a89e5c66ff2..e17cb05cd8b 100644 --- a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro +++ b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qtemporaryfile -QT = core testlib +QT = core testlib testlib-private SOURCES = tst_qtemporaryfile.cpp TESTDATA += tst_qtemporaryfile.cpp RESOURCES += qtemporaryfile.qrc diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index ab6b4351252..64b61839c12 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -36,6 +36,8 @@ #include #include +#include + #if defined(Q_OS_WIN) # include #endif @@ -141,16 +143,6 @@ void tst_QTemporaryFile::getSetCheck() QCOMPARE(true, obj1.autoRemove()); } -static inline bool canHandleUnicodeFileNames() -{ -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - return true; -#else - // Check for UTF-8 by converting the Euro symbol (see tst_utf8) - return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254"); -#endif -} - static QString hanTestText() { QString text; @@ -199,7 +191,7 @@ void tst_QTemporaryFile::fileTemplate_data() QTest::newRow("set template, with xxx") << "" << "qt_" << ".xxx" << "qt_XXXXXX.xxx"; QTest::newRow("set template, with >6 X's") << "" << "qt_" << ".xxx" << "qt_XXXXXXXXXXXXXX.xxx"; QTest::newRow("set template, with >6 X's, no suffix") << "" << "qt_" << "" << "qt_XXXXXXXXXXXXXX"; - if (canHandleUnicodeFileNames()) { + if (QTestPrivate::canHandleUnicodeFileNames()) { // Test Umlauts (contained in Latin1) QString prefix = "qt_" + umlautTestText(); QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix << QString() << QString(); @@ -761,7 +753,7 @@ void tst_QTemporaryFile::QTBUG_4796_data() QTest::newRow("XXXXXXbla") << QString() << QString("bla") << true; QTest::newRow("does-not-exist/qt_temp.XXXXXX") << QString("does-not-exist/qt_temp") << QString() << false; - if (canHandleUnicodeFileNames()) { + if (QTestPrivate::canHandleUnicodeFileNames()) { QTest::newRow("XXXXXX") << QString() << unicode << true; QTest::newRow("XXXXXX") << unicode << QString() << true; QTest::newRow("XXXXXX") << unicode << unicode << true; diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index 727d5fe0d7b..bfe652d25a3 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qaccessibility requires(qtConfig(accessibility)) -QT += testlib core-private gui-private widgets-private +QT += testlib core-private gui-private widgets-private testlib-private SOURCES += tst_qaccessibility.cpp HEADERS += accessiblewidgets.h diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index b857501e8f6..d98bbe28b79 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -59,15 +59,9 @@ #include "accessiblewidgets.h" -// Make a widget frameless to prevent size constraints of title bars -// from interfering (Windows). -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +#include + +using namespace QTestPrivate; static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, int index, const QRect &domain) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro b/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro index 88526144fcb..ae6de481954 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/qgraphicsitem.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qgraphicsitem -QT += widgets widgets-private testlib +QT += widgets widgets-private testlib testlib-private QT += core-private gui-private SOURCES += tst_qgraphicsitem.cpp DEFINES += QT_NO_CAST_TO_ASCII diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 96827022a84..0fc1a643b44 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -28,6 +28,7 @@ #include +#include #include #include @@ -127,17 +128,6 @@ static void sendKeyClick(QGraphicsScene *scene, Qt::Key key) sendKeyRelease(scene, key); } -static inline void centerOnScreen(QWidget *w, const QSize &size) -{ - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} - -static inline void centerOnScreen(QWidget *w) -{ - centerOnScreen(w, w->geometry().size()); -} - class EventSpy : public QGraphicsWidget { Q_OBJECT @@ -4211,7 +4201,7 @@ void tst_QGraphicsItem::cursor() QWidget topLevel; topLevel.resize(250, 150); - centerOnScreen(&topLevel); + QTestPrivate::centerOnScreen(&topLevel); QGraphicsView view(&scene,&topLevel); view.setFixedSize(200, 100); topLevel.show(); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro index 258b5e0e141..8ed19697a4e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro @@ -3,7 +3,7 @@ testcase.timeout = 500 # this test is slow TARGET = tst_qgraphicsview QT += widgets widgets-private testlib -QT += core-private gui-private +QT += core-private gui-private testlib-private SOURCES += tst_qgraphicsview.cpp tst_qgraphicsview_2.cpp HEADERS += tst_qgraphicsview.h diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 5900c85627b..5b557dba58c 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -61,6 +61,10 @@ #include "tst_qgraphicsview.h" +#include + +using namespace QTestPrivate; + Q_DECLARE_METATYPE(ExpectedValueDescription) Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QList) @@ -130,14 +134,6 @@ class FriendlyGraphicsScene : public QGraphicsScene }; #endif -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} - class tst_QGraphicsView : public QObject { Q_OBJECT diff --git a/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro b/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro index 2f0ca732654..4ee7f28af6c 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro +++ b/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qabstractitemview -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qabstractitemview.cpp diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 2234b2b4888..165c4b079e1 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -28,6 +28,7 @@ #include +#include #include #include @@ -57,19 +58,7 @@ Q_DECLARE_METATYPE(Qt::ItemFlags); -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} - -static inline void centerOnScreen(QWidget *w) -{ - const QPoint offset = QPoint(w->width() / 2, w->height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} +using namespace QTestPrivate; // Move cursor out of widget area to avoid undesired interaction on Mac. static inline void moveCursorAway(const QWidget *topLevel) diff --git a/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro b/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro index 5096cc691af..0b3dcd9e801 100644 --- a/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro +++ b/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro @@ -1,6 +1,6 @@ CONFIG += testcase QT += widgets widgets-private -QT += gui-private core-private testlib +QT += gui-private core-private testlib testlib-private SOURCES += tst_qcolumnview.cpp HEADERS += ../../../../shared/fakedirmodel.h diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp index 62acf49f4aa..38e6d95ba4c 100644 --- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp @@ -28,6 +28,7 @@ #include "../../../../shared/fakedirmodel.h" #include +#include #include #include #include @@ -369,12 +370,6 @@ void tst_QColumnView::scrollTo_data() QTest::newRow("reverse") << true << false; } -static inline void centerOnScreen(QWidget *w) -{ - const QPoint offset = QPoint(w->width() / 2, w->height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} - void tst_QColumnView::scrollTo() { QFETCH(bool, reverse); @@ -386,7 +381,7 @@ void tst_QColumnView::scrollTo() view.resize(200, 200); topLevel.show(); topLevel.activateWindow(); - centerOnScreen(&topLevel); + QTestPrivate::centerOnScreen(&topLevel); QVERIFY(QTest::qWaitForWindowActive(&topLevel)); view.scrollTo(QModelIndex(), QAbstractItemView::EnsureVisible); @@ -1004,7 +999,7 @@ void tst_QColumnView::dynamicModelChanges() ColumnView view; view.setModel(&model); view.setItemDelegate(&delegate); - centerOnScreen(&view); + QTestPrivate::centerOnScreen(&view); view.show(); QStandardItem *item = new QStandardItem(QLatin1String("item")); diff --git a/tests/auto/widgets/itemviews/qlistview/qlistview.pro b/tests/auto/widgets/itemviews/qlistview/qlistview.pro index 44e25ded662..e49a0c5fbfa 100644 --- a/tests/auto/widgets/itemviews/qlistview/qlistview.pro +++ b/tests/auto/widgets/itemviews/qlistview/qlistview.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qlistview -QT += widgets gui-private widgets-private core-private testlib +QT += widgets gui-private widgets-private core-private testlib testlib-private SOURCES += tst_qlistview.cpp win32:!winrt: LIBS += -luser32 linux*: CONFIG += insignificant_test # Crashes diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index b9785c35ac9..d8b8546d86d 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -46,6 +46,10 @@ #include #include +#include + +using namespace QTestPrivate; + #if defined(Q_OS_WIN) # include # include @@ -64,16 +68,6 @@ Q_DECLARE_METATYPE(QAbstractItemView::ScrollMode) Q_DECLARE_METATYPE(QMargins) Q_DECLARE_METATYPE(QSize) -// Make a widget frameless to prevent size constraints of title bars -// from interfering (Windows). -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} - static QStringList generateList(const QString &prefix, int size) { QStringList result; diff --git a/tests/auto/widgets/itemviews/qtableview/qtableview.pro b/tests/auto/widgets/itemviews/qtableview/qtableview.pro index e02da95ab92..a02f96eb996 100644 --- a/tests/auto/widgets/itemviews/qtableview/qtableview.pro +++ b/tests/auto/widgets/itemviews/qtableview/qtableview.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qtableview QT += widgets widgets-private testlib -QT += core-private gui-private +QT += core-private gui-private testlib-private SOURCES += tst_qtableview.cpp diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index a27e0b6048d..4e401ddd86e 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -35,6 +35,10 @@ #include +#include + +using namespace QTestPrivate; + #ifdef QT_BUILD_INTERNAL #define VERIFY_SPANS_CONSISTENCY(TEST_VIEW_) \ QVERIFY(static_cast(QObjectPrivate::get(TEST_VIEW_))->spans.checkConsistency()) @@ -46,16 +50,6 @@ typedef QList IntList; typedef QList BoolList; -// Make a widget frameless to prevent size constraints of title bars -// from interfering (Windows). -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} - class tst_QTableView : public QObject { Q_OBJECT diff --git a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro index 3abd58e73d9..2530b44935d 100644 --- a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro +++ b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qtreeview QT += widgets testlib -QT += widgets-private gui-private core-private +QT += widgets-private gui-private core-private testlib-private SOURCES += tst_qtreeview.cpp HEADERS += ../../../../shared/fakedirmodel.h diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index e2886cfcfe0..6ee0e50cced 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -33,6 +33,10 @@ #include #include +#include + +using namespace QTestPrivate; + #ifndef QT_NO_DRAGANDDROP Q_DECLARE_METATYPE(QAbstractItemView::DragDropMode) #endif @@ -57,16 +61,6 @@ static void initStandardTreeModel(QStandardItemModel *model) model->insertRow(2, item); } -// Make a widget frameless to prevent size constraints of title bars -// from interfering (Windows). -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} - class tst_QTreeView : public QObject { Q_OBJECT diff --git a/tests/auto/widgets/kernel/qboxlayout/qboxlayout.pro b/tests/auto/widgets/kernel/qboxlayout/qboxlayout.pro index 90e83f52856..1a2c6d6f667 100644 --- a/tests/auto/widgets/kernel/qboxlayout/qboxlayout.pro +++ b/tests/auto/widgets/kernel/qboxlayout/qboxlayout.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qboxlayout -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qboxlayout.cpp diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index 0b35db1b5f2..1dac242114a 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -31,13 +31,9 @@ #include #include -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +#include + +using namespace QTestPrivate; class tst_QBoxLayout : public QObject { diff --git a/tests/auto/widgets/kernel/qformlayout/qformlayout.pro b/tests/auto/widgets/kernel/qformlayout/qformlayout.pro index be944605a3f..617183fee6d 100644 --- a/tests/auto/widgets/kernel/qformlayout/qformlayout.pro +++ b/tests/auto/widgets/kernel/qformlayout/qformlayout.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qformlayout -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qformlayout.cpp diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index c324a4bd565..1ccda25339b 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -41,20 +41,16 @@ #include #include +#include + +using namespace QTestPrivate; + #include // ItemRole has enumerators for numerical values 0..2, thus the only // valid numerical values for storing into an ItemRole variable are 0..3: Q_CONSTEXPR QFormLayout::ItemRole invalidRole = QFormLayout::ItemRole(3); -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} - struct QFormLayoutTakeRowResultHolder { QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) Q_DECL_NOTHROW : labelItem(result.labelItem), diff --git a/tests/auto/widgets/kernel/qgridlayout/qgridlayout.pro b/tests/auto/widgets/kernel/qgridlayout/qgridlayout.pro index ee64f8538f8..8947658e8c1 100644 --- a/tests/auto/widgets/kernel/qgridlayout/qgridlayout.pro +++ b/tests/auto/widgets/kernel/qgridlayout/qgridlayout.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_qgridlayout QT += widgets widgets-private testlib -QT += core-private gui-private +QT += core-private gui-private testlib-private SOURCES += tst_qgridlayout.cpp FORMS += sortdialog.ui diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index c1ab5f51bee..37e2bdb069c 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -41,15 +41,9 @@ #include #include -// Make a widget frameless to prevent size constraints of title bars -// from interfering (Windows). -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +#include + +using namespace QTestPrivate; class tst_QGridLayout : public QObject { diff --git a/tests/auto/widgets/kernel/qlayout/qlayout.pro b/tests/auto/widgets/kernel/qlayout/qlayout.pro index d460785158a..8e0ea1bfdba 100644 --- a/tests/auto/widgets/kernel/qlayout/qlayout.pro +++ b/tests/auto/widgets/kernel/qlayout/qlayout.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qlayout -QT += widgets widgets-private testlib +QT += widgets widgets-private testlib testlib-private SOURCES += tst_qlayout.cpp TESTDATA += baseline/* diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index 829d0ea0980..a55693bb6ce 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -44,13 +44,9 @@ #include #include -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +#include + +using namespace QTestPrivate; class tst_QLayout : public QObject { diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro index 499ca65516c..3e4e96760b3 100644 --- a/tests/auto/widgets/kernel/qwidget/qwidget.pro +++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro @@ -2,7 +2,7 @@ CONFIG += testcase testcase.timeout = 600 # this test is slow TARGET = tst_qwidget -QT += widgets core-private gui-private widgets-private testlib +QT += widgets core-private gui-private widgets-private testlib testlib-private SOURCES += tst_qwidget.cpp RESOURCES = qwidget.qrc diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index baecc43f2cb..a7aa99d2a84 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -72,6 +72,9 @@ #endif #include +#include + +using namespace QTestPrivate; #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) # include @@ -108,22 +111,6 @@ bool macHasAccessToWindowsServer() } #endif -// Make a widget frameless to prevent size constraints of title bars -// from interfering (Windows). -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} - -static inline void centerOnScreen(QWidget *w) -{ - const QPoint offset = QPoint(w->width() / 2, w->height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} - #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) static inline void setWindowsAnimationsEnabled(bool enabled) { diff --git a/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro b/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro index a6248dfd168..00bf763c35e 100644 --- a/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro +++ b/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qwidget_window -QT += widgets testlib core-private gui-private +QT += widgets testlib core-private gui-private testlib-private SOURCES += tst_qwidget_window.cpp diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index f20978c295d..e4564a8640a 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -45,13 +45,9 @@ #include #include -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +#include + +using namespace QTestPrivate; class tst_QWidget_window : public QObject { diff --git a/tests/auto/widgets/kernel/qwidgetaction/qwidgetaction.pro b/tests/auto/widgets/kernel/qwidgetaction/qwidgetaction.pro index e4158559a9d..f443758eea8 100644 --- a/tests/auto/widgets/kernel/qwidgetaction/qwidgetaction.pro +++ b/tests/auto/widgets/kernel/qwidgetaction/qwidgetaction.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qwidgetaction -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qwidgetaction.cpp diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp index 1824285f05d..28731223a9e 100644 --- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp @@ -38,13 +38,9 @@ #include #include -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +#include + +using namespace QTestPrivate; class tst_QWidgetAction : public QObject { diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index a1e5a70a089..0fb74999463 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qstyle -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qstyle.cpp android { diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index fcb05f6b748..5369101dae2 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -60,15 +60,9 @@ #include -// Make a widget frameless to prevent size constraints of title bars -// from interfering (Windows). -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +#include + +using namespace QTestPrivate; class tst_QStyle : public QObject { diff --git a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro index 7d9a8576d3b..3bf1b940502 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qstylesheetstyle -QT += widgets widgets-private gui-private testlib +QT += widgets widgets-private gui-private testlib testlib-private SOURCES += tst_qstylesheetstyle.cpp RESOURCES += resources.qrc diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 693b0b8aee7..7953077152c 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -33,12 +33,9 @@ #include #include +#include -static inline void centerOnScreen(QWidget *w) -{ - const QPoint offset = QPoint(w->width() / 2, w->height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} +using namespace QTestPrivate; class tst_QStyleSheetStyle : public QObject { diff --git a/tests/auto/widgets/util/qcompleter/qcompleter.pro b/tests/auto/widgets/util/qcompleter/qcompleter.pro index 19d8d500b82..fcdce93079a 100644 --- a/tests/auto/widgets/util/qcompleter/qcompleter.pro +++ b/tests/auto/widgets/util/qcompleter/qcompleter.pro @@ -1,6 +1,6 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qcompleter -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qcompleter.cpp diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 3818b83584a..92bcd5c350b 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -34,15 +34,11 @@ #include #include +#include + #include "../../../../shared/filesystem.h" -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +using namespace QTestPrivate; class CsvCompleter : public QCompleter { diff --git a/tests/auto/widgets/widgets/qabstractslider/qabstractslider.pro b/tests/auto/widgets/widgets/qabstractslider/qabstractslider.pro index 64539997865..95385e21724 100644 --- a/tests/auto/widgets/widgets/qabstractslider/qabstractslider.pro +++ b/tests/auto/widgets/widgets/qabstractslider/qabstractslider.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qabstractslider -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qabstractslider.cpp diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index f0d74e77978..70ae453896c 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -36,17 +36,13 @@ #include #include +#include + +using namespace QTestPrivate; + // defined to be 120 by the wheel mouse vendors according to the docs #define WHEEL_DELTA 120 -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} - class Slider : public QAbstractSlider { public: diff --git a/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro b/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro index be758a8bdd5..a4a6f84ee47 100644 --- a/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro +++ b/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro @@ -4,7 +4,7 @@ CONFIG += testcase TARGET = tst_qabstractspinbox -QT += widgets gui-private core-private testlib +QT += widgets gui-private core-private testlib testlib-private SOURCES += tst_qabstractspinbox.cpp diff --git a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp index 3fb4863b0ed..0ce3b4cefe5 100644 --- a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp +++ b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp @@ -28,6 +28,7 @@ #include +#include #include #include @@ -38,16 +39,6 @@ #include "../../../shared/platforminputcontext.h" #include -static inline void centerOnScreen(QWidget *w, const QSize &size) -{ - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} - -static inline void centerOnScreen(QWidget *w) -{ - centerOnScreen(w, w->geometry().size()); -} class tst_QAbstractSpinBox : public QObject { @@ -182,7 +173,7 @@ void tst_QAbstractSpinBox::inputMethodUpdate() QSpinBox *testWidget = &box; testWidget->setRange(0, 1); - centerOnScreen(testWidget); + QTestPrivate::centerOnScreen(testWidget); testWidget->clear(); testWidget->show(); QVERIFY(QTest::qWaitForWindowExposed(testWidget)); diff --git a/tests/auto/widgets/widgets/qcombobox/qcombobox.pro b/tests/auto/widgets/widgets/qcombobox/qcombobox.pro index 88b9d085572..939153dc881 100644 --- a/tests/auto/widgets/widgets/qcombobox/qcombobox.pro +++ b/tests/auto/widgets/widgets/qcombobox/qcombobox.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qcombobox -QT += widgets widgets-private gui-private core-private testlib +QT += widgets widgets-private gui-private core-private testlib testlib-private SOURCES += tst_qcombobox.cpp diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index bf190cf60ae..2195f43ef14 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -67,13 +67,9 @@ #include "../../../shared/platforminputcontext.h" #include -static inline void setFrameless(QWidget *w) -{ - Qt::WindowFlags flags = w->windowFlags(); - flags |= Qt::FramelessWindowHint; - flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - w->setWindowFlags(flags); -} +#include + +using namespace QTestPrivate; class tst_QComboBox : public QObject { diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro index 636208d67a5..cb24a80afdf 100644 --- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro +++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qlineedit -QT += gui-private core-private widgets widgets-private testlib +QT += gui-private core-private widgets widgets-private testlib testlib-private SOURCES += tst_qlineedit.cpp osx: LIBS += -framework AppKit diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index cf1e19d5989..2c6599631e4 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -28,6 +28,7 @@ #include +#include #include "qlineedit.h" #include "qapplication.h" #include "qstringlist.h" @@ -74,16 +75,7 @@ QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE -static inline void centerOnScreen(QWidget *w, const QSize &size) -{ - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} - -static inline void centerOnScreen(QWidget *w) -{ - centerOnScreen(w, w->geometry().size()); -} +using namespace QTestPrivate; class StyleOptionTestStyle : public QCommonStyle { diff --git a/tests/auto/widgets/widgets/qmenu/qmenu.pro b/tests/auto/widgets/widgets/qmenu/qmenu.pro index 55fff011388..84b6530184b 100644 --- a/tests/auto/widgets/widgets/qmenu/qmenu.pro +++ b/tests/auto/widgets/widgets/qmenu/qmenu.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qmenu -QT += gui-private widgets testlib +QT += gui-private widgets testlib testlib-private SOURCES += tst_qmenu.cpp macx:{ OBJECTIVE_SOURCES += tst_qmenu_mac.mm diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index ad30db501a2..99d29d487d4 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include +#include #include #include #include @@ -48,15 +49,11 @@ #include +using namespace QTestPrivate; + Q_DECLARE_METATYPE(Qt::Key); Q_DECLARE_METATYPE(Qt::KeyboardModifiers); -static inline void centerOnScreen(QWidget *w, const QSize &size) -{ - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} - struct MenuMetrics { int fw; int hmargin; @@ -71,11 +68,6 @@ struct MenuMetrics { } }; -static inline void centerOnScreen(QWidget *w) -{ - centerOnScreen(w, w->geometry().size()); -} - class tst_QMenu : public QObject { Q_OBJECT diff --git a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro index e680cf4d7d8..bde00265178 100644 --- a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro +++ b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qmenubar -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qmenubar.cpp macos: { diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 65181a9516d..417fa9befa3 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -48,6 +48,10 @@ QT_FORWARD_DECLARE_CLASS(QMainWindow) #include +#include + +using namespace QTestPrivate; + // Helper to calculate the action position in window coordinates static inline QPoint widgetToWindowPos(const QWidget *w, const QPoint &pos) { @@ -73,12 +77,6 @@ class Menu : public QMenu } }; -static inline void centerOnScreen(QWidget *w) -{ - const QPoint offset = QPoint(w->width() / 2, w->height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} - struct TestMenu { QList menus; diff --git a/tests/auto/widgets/widgets/qscrollbar/qscrollbar.pro b/tests/auto/widgets/widgets/qscrollbar/qscrollbar.pro index 2863dd2034b..51f955200b9 100644 --- a/tests/auto/widgets/widgets/qscrollbar/qscrollbar.pro +++ b/tests/auto/widgets/widgets/qscrollbar/qscrollbar.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qscrollbar -QT += widgets testlib +QT += widgets testlib testlib-private SOURCES += tst_qscrollbar.cpp diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index 5238eea5922..f9a3e519777 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -33,16 +33,9 @@ #include #include -static inline void centerOnScreen(QWidget *w, const QSize &size) -{ - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); -} +#include -static inline void centerOnScreen(QWidget *w) -{ - centerOnScreen(w, w->geometry().size()); -} +using namespace QTestPrivate; class tst_QScrollBar : public QObject { From 435c4b2ccbbb7284918dd2d4a14f8e44c3977d98 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Fri, 20 Oct 2017 22:51:07 +0200 Subject: [PATCH 20/56] QPSQL: Fix detection of PostreSQL version 9.x and later Fixed parsing version string for PostgreSQL. PostgreSQL versioning changed since version 10, see link: https://www.postgresql.org/support/versioning Extended QPSQLDriver::Protocol enum for PostreSQL 9.x and later, added underscore to item names to separate major and minor version. Changed long switch-case statements to if-else. Change-Id: Ib19ae7ba426f262e80c52670e7ecb3532ff460a0 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 194 +++++++++++----------- src/plugins/sqldrivers/psql/qsql_psql_p.h | 24 ++- 2 files changed, 114 insertions(+), 104 deletions(-) diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index acadc830b26..f650e4cca88 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -187,7 +187,7 @@ public: void QPSQLDriverPrivate::appendTables(QStringList &tl, QSqlQuery &t, QChar type) { QString query; - if (pro >= QPSQLDriver::Version73) { + if (pro >= QPSQLDriver::Version7_3) { query = QString::fromLatin1("select pg_class.relname, pg_namespace.nspname from pg_class " "left join pg_namespace on (pg_class.relnamespace = pg_namespace.oid) " "where (pg_class.relkind = '%1') and (pg_class.relname !~ '^Inv') " @@ -525,7 +525,7 @@ int QPSQLResult::numRowsAffected() QVariant QPSQLResult::lastInsertId() const { Q_D(const QPSQLResult); - if (d->drv_d_func()->pro >= QPSQLDriver::Version81) { + if (d->drv_d_func()->pro >= QPSQLDriver::Version8_1) { QSqlQuery qry(driver()->createResult()); // Most recent sequence value obtained from nextval if (qry.exec(QLatin1String("SELECT lastval();")) && qry.next()) @@ -697,7 +697,7 @@ void QPSQLDriverPrivate::detectBackslashEscape() { // standard_conforming_strings option introduced in 8.2 // http://www.postgresql.org/docs/8.2/static/runtime-config-compatible.html - if (pro < QPSQLDriver::Version82) { + if (pro < QPSQLDriver::Version8_2) { hasBackslashEscape = true; } else { hasBackslashEscape = false; @@ -719,11 +719,11 @@ static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin) { switch (vMin) { case 1: - return QPSQLDriver::Version71; + return QPSQLDriver::Version7_1; case 3: - return QPSQLDriver::Version73; + return QPSQLDriver::Version7_3; case 4: - return QPSQLDriver::Version74; + return QPSQLDriver::Version7_4; default: return QPSQLDriver::Version7; } @@ -733,24 +733,68 @@ static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin) { switch (vMin) { case 1: - return QPSQLDriver::Version81; + return QPSQLDriver::Version8_1; case 2: - return QPSQLDriver::Version82; + return QPSQLDriver::Version8_2; case 3: - return QPSQLDriver::Version83; + return QPSQLDriver::Version8_3; case 4: - return QPSQLDriver::Version84; + return QPSQLDriver::Version8_4; default: return QPSQLDriver::Version8; } break; } case 9: - return QPSQLDriver::Version9; - break; - default: + { + switch (vMin) { + case 1: + return QPSQLDriver::Version9_1; + case 2: + return QPSQLDriver::Version9_2; + case 3: + return QPSQLDriver::Version9_3; + case 4: + return QPSQLDriver::Version9_4; + case 5: + return QPSQLDriver::Version9_5; + case 6: + return QPSQLDriver::Version9_6; + default: + return QPSQLDriver::Version9; + } break; } + case 10: + return QPSQLDriver::Version10; + default: + if (vMaj > 10) + return QPSQLDriver::UnknownLaterVersion; + break; + } + return QPSQLDriver::VersionUnknown; +} + +static QPSQLDriver::Protocol qFindPSQLVersion(const QString &versionString) +{ + const QRegExp rx(QStringLiteral("(\\d+)(?:\\.(\\d+))?")); + if (rx.indexIn(versionString) != -1) { + // Beginning with PostgreSQL version 10, a major release is indicated by + // increasing the first part of the version, e.g. 10 to 11. + // Before version 10, a major release was indicated by increasing either + // the first or second part of the version number, e.g. 9.5 to 9.6. + int vMaj = rx.cap(1).toInt(); + int vMin; + if (vMaj >= 10) { + vMin = 0; + } else { + if (rx.cap(2).isEmpty()) + return QPSQLDriver::VersionUnknown; + vMin = rx.cap(2).toInt(); + } + return qMakePSQLVersion(vMaj, vMin); + } + return QPSQLDriver::VersionUnknown; } @@ -760,49 +804,38 @@ QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion() PGresult* result = exec("select version()"); int status = PQresultStatus(result); if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) { - QString val = QString::fromLatin1(PQgetvalue(result, 0, 0)); - - QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)")); - rx.setMinimal(true); // enforce non-greedy RegExp - - if (rx.indexIn(val) != -1) { - int vMaj = rx.cap(1).toInt(); - int vMin = rx.cap(2).toInt(); - serverVersion = qMakePSQLVersion(vMaj, vMin); -#if defined(PG_MAJORVERSION) - if (rx.indexIn(QLatin1String(PG_MAJORVERSION)) != -1) -#elif defined(PG_VERSION) - if (rx.indexIn(QLatin1String(PG_VERSION)) != -1) -#else - if (0) -#endif - { - vMaj = rx.cap(1).toInt(); - vMin = rx.cap(2).toInt(); - QPSQLDriver::Protocol clientVersion = qMakePSQLVersion(vMaj, vMin); - - if (serverVersion >= QPSQLDriver::Version9 && clientVersion < QPSQLDriver::Version9) { - //Client version before QPSQLDriver::Version9 only supports escape mode for bytea type, - //but bytea format is set to hex by default in PSQL 9 and above. So need to force the - //server use the old escape mode when connects to the new server with old client library. - PQclear(result); - result = exec("SET bytea_output=escape; "); - status = PQresultStatus(result); - } else if (serverVersion == QPSQLDriver::VersionUnknown) { - serverVersion = clientVersion; - if (serverVersion != QPSQLDriver::VersionUnknown) - qWarning("The server version of this PostgreSQL is unknown, falling back to the client version."); - } - } - } + serverVersion = qFindPSQLVersion( + QString::fromLatin1(PQgetvalue(result, 0, 0))); } PQclear(result); - //keep the old behavior unchanged + QPSQLDriver::Protocol clientVersion = +#if defined(PG_MAJORVERSION) + qFindPSQLVersion(QLatin1String(PG_MAJORVERSION)); +#elif defined(PG_VERSION) + qFindPSQLVersion(QLatin1String(PG_VERSION)); +#else + QPSQLDriver::VersionUnknown; +#endif + + if (serverVersion >= QPSQLDriver::Version9 && clientVersion < QPSQLDriver::Version9) { + // Client version before QPSQLDriver::Version9 only supports escape mode for bytea type, + // but bytea format is set to hex by default in PSQL 9 and above. So need to force the + // server use the old escape mode when connects to the new server with old client library. + result = exec("SET bytea_output=escape; "); + status = PQresultStatus(result); + PQclear(result); + } else if (serverVersion == QPSQLDriver::VersionUnknown) { + serverVersion = clientVersion; + if (serverVersion != QPSQLDriver::VersionUnknown) + qWarning("The server version of this PostgreSQL is unknown, falling back to the client version."); + } + + // Keep the old behavior unchanged if (serverVersion == QPSQLDriver::VersionUnknown) serverVersion = QPSQLDriver::Version6; - if (serverVersion < QPSQLDriver::Version71) { + if (serverVersion < QPSQLDriver::Version7_1) { qWarning("This version of PostgreSQL is not supported and may not work."); } @@ -852,7 +885,7 @@ bool QPSQLDriver::hasFeature(DriverFeature f) const return true; case PreparedQueries: case PositionalPlaceholders: - return d->pro >= QPSQLDriver::Version82; + return d->pro >= QPSQLDriver::Version8_2; case BatchOperations: case NamedPlaceholders: case SimpleLocking: @@ -861,7 +894,7 @@ bool QPSQLDriver::hasFeature(DriverFeature f) const case CancelQuery: return false; case BLOB: - return d->pro >= QPSQLDriver::Version71; + return d->pro >= QPSQLDriver::Version7_1; case Unicode: return d->isUtf8; } @@ -988,12 +1021,7 @@ bool QPSQLDriver::commitTransaction() // This hack is used to tell if the transaction has succeeded for the protocol versions of // PostgreSQL below. For 7.x and other protocol versions we are left in the dark. // This hack can dissapear once there is an API to query this sort of information. - if (d->pro == QPSQLDriver::Version8 || - d->pro == QPSQLDriver::Version81 || - d->pro == QPSQLDriver::Version82 || - d->pro == QPSQLDriver::Version83 || - d->pro == QPSQLDriver::Version84 || - d->pro == QPSQLDriver::Version9) { + if (d->pro >= QPSQLDriver::Version8) { transaction_failed = qstrcmp(PQcmdStatus(res), "ROLLBACK") == 0; } @@ -1080,8 +1108,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const else schema = std::move(schema).toLower(); - switch(d->pro) { - case QPSQLDriver::Version6: + if (d->pro == QPSQLDriver::Version6) { stmt = QLatin1String("select pg_att1.attname, int(pg_att1.atttypid), pg_cl.relname " "from pg_attribute pg_att1, pg_attribute pg_att2, pg_class pg_cl, pg_index pg_ind " "where pg_cl.relname = '%1_pkey' " @@ -1090,9 +1117,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const "and pg_att1.attrelid = pg_ind.indrelid " "and pg_att1.attnum = pg_ind.indkey[pg_att2.attnum-1] " "order by pg_att2.attnum"); - break; - case QPSQLDriver::Version7: - case QPSQLDriver::Version71: + } else if (d->pro == QPSQLDriver::Version7 || d->pro == QPSQLDriver::Version7_1) { stmt = QLatin1String("select pg_att1.attname, pg_att1.atttypid::int, pg_cl.relname " "from pg_attribute pg_att1, pg_attribute pg_att2, pg_class pg_cl, pg_index pg_ind " "where pg_cl.relname = '%1_pkey' " @@ -1101,15 +1126,7 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const "and pg_att1.attrelid = pg_ind.indrelid " "and pg_att1.attnum = pg_ind.indkey[pg_att2.attnum-1] " "order by pg_att2.attnum"); - break; - case QPSQLDriver::Version73: - case QPSQLDriver::Version74: - case QPSQLDriver::Version8: - case QPSQLDriver::Version81: - case QPSQLDriver::Version82: - case QPSQLDriver::Version83: - case QPSQLDriver::Version84: - case QPSQLDriver::Version9: + } else if (d->pro >= QPSQLDriver::Version7_3) { stmt = QLatin1String("SELECT pg_attribute.attname, pg_attribute.atttypid::int, " "pg_class.relname " "FROM pg_attribute, pg_class " @@ -1124,10 +1141,8 @@ QSqlIndex QPSQLDriver::primaryIndex(const QString& tablename) const else stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from " "pg_namespace where pg_namespace.nspname = '%1') AND ").arg(schema)); - break; - case QPSQLDriver::VersionUnknown: - qFatal("PSQL version is unknown"); - break; + } else { + qFatal("QPSQLDriver::primaryIndex(tablename): unknown PSQL version, query statement not set"); } i.exec(stmt.arg(tbl)); @@ -1161,8 +1176,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const schema = std::move(schema).toLower(); QString stmt; - switch(d->pro) { - case QPSQLDriver::Version6: + if (d->pro == QPSQLDriver::Version6) { stmt = QLatin1String("select pg_attribute.attname, int(pg_attribute.atttypid), " "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " "int(pg_attribute.attrelid), pg_attribute.attnum " @@ -1170,8 +1184,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const "where pg_class.relname = '%1' " "and pg_attribute.attnum > 0 " "and pg_attribute.attrelid = pg_class.oid "); - break; - case QPSQLDriver::Version7: + } else if (d->pro == QPSQLDriver::Version7) { stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, " "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " "pg_attribute.attrelid::int, pg_attribute.attnum " @@ -1179,8 +1192,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const "where pg_class.relname = '%1' " "and pg_attribute.attnum > 0 " "and pg_attribute.attrelid = pg_class.oid "); - break; - case QPSQLDriver::Version71: + } else if (d->pro == QPSQLDriver::Version7_1) { stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, " "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " "pg_attrdef.adsrc " @@ -1191,15 +1203,7 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const "and pg_attribute.attnum > 0 " "and pg_attribute.attrelid = pg_class.oid " "order by pg_attribute.attnum "); - break; - case QPSQLDriver::Version73: - case QPSQLDriver::Version74: - case QPSQLDriver::Version8: - case QPSQLDriver::Version81: - case QPSQLDriver::Version82: - case QPSQLDriver::Version83: - case QPSQLDriver::Version84: - case QPSQLDriver::Version9: + } else if (d->pro >= QPSQLDriver::Version7_3) { stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, " "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " "pg_attrdef.adsrc " @@ -1217,15 +1221,13 @@ QSqlRecord QPSQLDriver::record(const QString& tablename) const else stmt = stmt.arg(QString::fromLatin1("pg_class.relnamespace = (select oid from " "pg_namespace where pg_namespace.nspname = '%1')").arg(schema)); - break; - case QPSQLDriver::VersionUnknown: - qFatal("PSQL version is unknown"); - break; + } else { + qFatal("QPSQLDriver::record(tablename): unknown PSQL version, query statement not set"); } QSqlQuery query(createResult()); query.exec(stmt.arg(tbl)); - if (d->pro >= QPSQLDriver::Version71) { + if (d->pro >= QPSQLDriver::Version7_1) { while (query.next()) { int len = query.value(3).toInt(); int precision = query.value(4).toInt(); diff --git a/src/plugins/sqldrivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h index 8468b9af938..f5cb2e9bd07 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql_p.h +++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h @@ -76,15 +76,23 @@ public: VersionUnknown = -1, Version6 = 6, Version7 = 7, - Version71 = 8, - Version73 = 9, - Version74 = 10, + Version7_1 = 8, + Version7_3 = 9, + Version7_4 = 10, Version8 = 11, - Version81 = 12, - Version82 = 13, - Version83 = 14, - Version84 = 15, - Version9 = 16 + Version8_1 = 12, + Version8_2 = 13, + Version8_3 = 14, + Version8_4 = 15, + Version9 = 16, + Version9_1 = 17, + Version9_2 = 18, + Version9_3 = 19, + Version9_4 = 20, + Version9_5 = 21, + Version9_6 = 22, + Version10 = 23, + UnknownLaterVersion = 100000 }; explicit QPSQLDriver(QObject *parent=0); From ff914ea59c3788b2359ddb8d607299576b7a1296 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Fri, 20 Oct 2017 23:31:12 +0200 Subject: [PATCH 21/56] QPSQL: Fix handling binary data for PostgreSQL 9.x and later Set byte_output to 'escape' mode for server version 9 and later, no matter what version of client library we use. Since setting byte_output doesn't depend on client version anymore, we can move it to separate function. This fixes qtbase\tests\auto\sql\kernel\qsqldatabase tst_QSqlDatabase::psql_escapeBytea() test (before this change test did not pass on PostgreSQL 9.6) Change-Id: I37aaa18267d7e6459c00010ed899536c01e8124e Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index f650e4cca88..aac9a1fa13c 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -181,6 +181,7 @@ public: QPSQLDriver::Protocol getPSQLVersion(); bool setEncodingUtf8(); void setDatestyle(); + void setByteaOutput(); void detectBackslashEscape(); }; @@ -693,6 +694,20 @@ void QPSQLDriverPrivate::setDatestyle() PQclear(result); } +void QPSQLDriverPrivate::setByteaOutput() +{ + if (pro >= QPSQLDriver::Version9) { + // Server version before QPSQLDriver::Version9 only supports escape mode for bytea type, + // but bytea format is set to hex by default in PSQL 9 and above. So need to force the + // server to use the old escape mode when connects to the new server. + PGresult *result = exec("SET bytea_output TO escape"); + int status = PQresultStatus(result); + if (status != PGRES_COMMAND_OK) + qWarning("%s", PQerrorMessage(connection)); + PQclear(result); + } +} + void QPSQLDriverPrivate::detectBackslashEscape() { // standard_conforming_strings option introduced in 8.2 @@ -818,14 +833,7 @@ QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion() QPSQLDriver::VersionUnknown; #endif - if (serverVersion >= QPSQLDriver::Version9 && clientVersion < QPSQLDriver::Version9) { - // Client version before QPSQLDriver::Version9 only supports escape mode for bytea type, - // but bytea format is set to hex by default in PSQL 9 and above. So need to force the - // server use the old escape mode when connects to the new server with old client library. - result = exec("SET bytea_output=escape; "); - status = PQresultStatus(result); - PQclear(result); - } else if (serverVersion == QPSQLDriver::VersionUnknown) { + if (serverVersion == QPSQLDriver::VersionUnknown) { serverVersion = clientVersion; if (serverVersion != QPSQLDriver::VersionUnknown) qWarning("The server version of this PostgreSQL is unknown, falling back to the client version."); @@ -957,6 +965,7 @@ bool QPSQLDriver::open(const QString & db, d->detectBackslashEscape(); d->isUtf8 = d->setEncodingUtf8(); d->setDatestyle(); + d->setByteaOutput(); setOpen(true); setOpenError(false); From b35a27676bec7f79761be83b2a7764ac0470e789 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Fri, 20 Oct 2017 23:55:16 +0200 Subject: [PATCH 22/56] QPSQL: Fix check for minimum supported PostgreSQL version According to Qt documentation http://doc.qt.io/qt-5/sql-driver.html#qpsql minimum supported version of PostgreSQL is 7.3 Change-Id: I30cffaddc29fd56b534bfd259cc235ea1204a21f Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index aac9a1fa13c..8f7d261bdc4 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -843,7 +843,7 @@ QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion() if (serverVersion == QPSQLDriver::VersionUnknown) serverVersion = QPSQLDriver::Version6; - if (serverVersion < QPSQLDriver::Version7_1) { + if (serverVersion < QPSQLDriver::Version7_3) { qWarning("This version of PostgreSQL is not supported and may not work."); } From 385589ef458715fcaa533bbd01ca421dc1040eba Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 20 Oct 2017 17:39:08 +0700 Subject: [PATCH 23/56] QCocoaMenu: Attach menu items when updating the menubar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of waiting for the menu delegate to update each item, we can attach an NSMenu to its NSMenuItem as soon as we update the current window's menubar. This is safe to do because we know that this is going to be the main menubar right after, so we're not orphaning any NSMenuItem from its NSMenu at the wrong moment. By doing this, we also ensure that all menus from the active menubar are reachable by the key-equivalent dispatching logic, even before we display the actual menu. This was shown in BigMenuCreator where, under the menubar's ASP and SAP menus, all A*S submenus would be disabled. Furthermore, on the same menus, SAP would show the same issue. Added test in Menurama as well. Change-Id: If6e7311072e6b53ad1cbced73623d1832aa0df8e Task-number: QTBUG-57076 Task-number: QTBUG-63712 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenu.h | 2 ++ src/plugins/platforms/cocoa/qcocoamenu.mm | 16 +++++++++++++++- src/plugins/platforms/cocoa/qcocoamenubar.h | 2 ++ src/plugins/platforms/cocoa/qcocoamenubar.mm | 11 ++++++++--- tests/manual/cocoa/menurama/mainwindow.cpp | 5 +++++ tests/manual/cocoa/menurama/mainwindow.ui | 1 + 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index 06688dbf3df..7baaf971f4c 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -98,6 +98,8 @@ public: void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; + void syncMenuItem_helper(QPlatformMenuItem *menuItem, bool menubarUpdate); + private: QCocoaMenuItem *itemOrNull(int index) const; void insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem); diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 3a11023a4d6..8bdd0512de4 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -434,6 +434,11 @@ void QCocoaMenu::timerEvent(QTimerEvent *e) } void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) +{ + syncMenuItem_helper(menuItem, false /*menubarUpdate*/); +} + +void QCocoaMenu::syncMenuItem_helper(QPlatformMenuItem *menuItem, bool menubarUpdate) { QMacAutoReleasePool pool; QCocoaMenuItem *cocoaItem = static_cast(menuItem); @@ -444,8 +449,9 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) const bool wasMerged = cocoaItem->isMerged(); NSMenuItem *oldItem = cocoaItem->nsItem(); + NSMenuItem *syncedItem = cocoaItem->sync(); - if (cocoaItem->sync() != oldItem) { + if (syncedItem != oldItem) { // native item was changed for some reason if (oldItem) { if (wasMerged) { @@ -463,6 +469,14 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem) // when an item's enabled state changes after menuWillOpen: scheduleUpdate(); } + + // This may be a good moment to attach this item's eventual submenu to the + // synced item, but only on the condition we're all currently hooked to the + // menunbar. A good indicator of this being the right moment is knowing that + // we got called from QCocoaMenuBar::updateMenuBarImmediately(). + if (menubarUpdate) + if (QCocoaMenu *submenu = cocoaItem->menu()) + submenu->setAttachedItem(syncedItem); } void QCocoaMenu::syncSeparatorsCollapsible(bool enable) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.h b/src/plugins/platforms/cocoa/qcocoamenubar.h index 0725e9db681..a4ee531e91a 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.h +++ b/src/plugins/platforms/cocoa/qcocoamenubar.h @@ -72,6 +72,8 @@ public: QList merged() const; NSMenuItem *itemForRole(QPlatformMenuItem::MenuRole r); + void syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate); + private: static QCocoaWindow *findWindowForMenubar(); static QCocoaMenuBar *findGlobalMenubar(); diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 3e466c95875..a4cd465dae3 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -155,7 +155,7 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor } } - syncMenu(menu); + syncMenu_helper(menu, false /*internaCall*/); if (needsImmediateUpdate()) updateMenuBarImmediately(); @@ -182,12 +182,17 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu) } void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) +{ + syncMenu_helper(menu, false /*internaCall*/); +} + +void QCocoaMenuBar::syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate) { QMacAutoReleasePool pool; QCocoaMenu *cocoaMenu = static_cast(menu); Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items()) - cocoaMenu->syncMenuItem(item); + cocoaMenu->syncMenuItem_helper(item, menubarUpdate); BOOL shouldHide = YES; if (cocoaMenu->isVisible()) { @@ -357,7 +362,7 @@ void QCocoaMenuBar::updateMenuBarImmediately() menu->setAttachedItem(item); menu->setMenuParent(mb); // force a sync? - mb->syncMenu(menu); + mb->syncMenu_helper(menu, true /*menubarUpdate*/); menu->propagateEnabledState(!disableForModal); } diff --git a/tests/manual/cocoa/menurama/mainwindow.cpp b/tests/manual/cocoa/menurama/mainwindow.cpp index 06867bd7c98..086fc1e2fa8 100644 --- a/tests/manual/cocoa/menurama/mainwindow.cpp +++ b/tests/manual/cocoa/menurama/mainwindow.cpp @@ -37,6 +37,11 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); + auto *a = ui->menuStuff->addAction("Enabled Submenu (QTBUG-63172)"); + auto *qtbug63172_Menu = new QMenu; + qtbug63172_Menu->addAction("We're Good!"); + a->setMenu(qtbug63172_Menu); + startTimer(1000); connect(ui->menuAfter_aboutToShow, &QMenu::aboutToShow, [=] { diff --git a/tests/manual/cocoa/menurama/mainwindow.ui b/tests/manual/cocoa/menurama/mainwindow.ui index 18cded70d2c..4fb3e3420eb 100644 --- a/tests/manual/cocoa/menurama/mainwindow.ui +++ b/tests/manual/cocoa/menurama/mainwindow.ui @@ -131,6 +131,7 @@ Click on "Dynamic Stuff" then move left and right to other menus. Disa + From d2b8a01ab0670337bd29f6f9b76069cc2599cc75 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Wed, 1 Nov 2017 22:21:35 +0100 Subject: [PATCH 24/56] Fix indentation Tabs and white spaces were mixed. Change-Id: I498944334b68b5c23a61e6f4ba6a0e8df77799c6 Reviewed-by: Timur Pocheptsov --- src/network/kernel/kernel.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index 00c115da842..1b62892c9f9 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -6,7 +6,7 @@ INCLUDEPATH += $$PWD HEADERS += kernel/qtnetworkglobal.h \ kernel/qtnetworkglobal_p.h \ kernel/qauthenticator.h \ - kernel/qauthenticator_p.h \ + kernel/qauthenticator_p.h \ kernel/qdnslookup.h \ kernel/qdnslookup_p.h \ kernel/qhostaddress.h \ From e45ffd7bf6b05062590da039e0de64707d2fb536 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 26 Oct 2017 13:26:56 +0200 Subject: [PATCH 25/56] Xinput: Avoid misdetecting certain trackballs as tablets The algorithm triggers on the word "cursor" in the device name, which would also happen for devices from the manufacturer Cursor Controls. Task-number: QTBUG-48034 Change-Id: I9645c0d0bc1fa951d0ea00480572fd0df0220eb5 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 6f20ec25e3c..26a9ba8d267 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -220,7 +220,7 @@ void QXcbConnection::xi2SetupDevices() isTablet = true; tabletData.pointerType = QTabletEvent::Eraser; dbgType = QLatin1String("eraser"); - } else if (name.contains("cursor")) { + } else if (name.contains("cursor") && !(name.contains("cursor controls") && name.contains("trackball"))) { isTablet = true; tabletData.pointerType = QTabletEvent::Cursor; dbgType = QLatin1String("cursor"); From b5b1e1036ff59b584719b8af7b3be8223a662233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Sun, 5 Nov 2017 14:08:56 +0200 Subject: [PATCH 26/56] Extend blacklisting in qnetworkreply While removing insignificant flag in commit 38a0909d4ed39b49e0463bd780d20a82ea672d35 and blacklisting autotests that still failed, qtbase builds didn't verify VS2017. That broke qt5 builds which do build VS2017. Task-number: QTBUG-64264 Change-Id: I5fdfa5dac6192f449a05146a9a422e428a710c84 Reviewed-by: Liang Qi --- tests/auto/network/access/qnetworkreply/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index 091ec28beaa..4785c5b6501 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -32,3 +32,5 @@ linux windows [qtbug28035browserDoesNotLoadQtProjectOrgCorrectly] windows +[getFromUnreachableIp] +windows msvc-2017 From c8fa698e9928783ee7257134e72c3c5927fe5698 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 6 Nov 2017 13:45:23 +0100 Subject: [PATCH 27/56] tst_QNetworkReply: Blacklist ioHttpRedirectPolicy for Linux Task-number: QTBUG-62583 Change-Id: I9723a465f1d36aec823ce3459fd03b9492a3b778 Reviewed-by: Timur Pocheptsov --- tests/auto/network/access/qnetworkreply/BLACKLIST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index 4785c5b6501..9ae424943d5 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -25,7 +25,7 @@ windows [ioHttpRedirectMultipartPost] linux [ioHttpRedirectPolicy] -b2qt 64bit +b2qt linux 64bit [ioHttpRedirectPostPut] linux [putWithServerClosingConnectionImmediately] From 7df4dcff2cafcd9b57eb7a4812be871d956f0ec8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 3 Nov 2017 14:40:46 +0100 Subject: [PATCH 28/56] Fix memory corruption on scaled emojis Bitmap glyphs are returned prescaled, which means we should include the transform in their bounding box. Additionally painting them should stick the smallest rect to avoid writing outside the allocated area, and assert in debug builds. Task-number: QTBUG-64239 Change-Id: I5f877d36566891323f528018f910798344ba4ce2 Reviewed-by: Konstantin Ritt Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qtextureglyphcache.cpp | 3 +- .../fontdatabases/freetype/qfontengine_ft.cpp | 30 ++++++++++++------- .../fontdatabases/freetype/qfontengine_ft_p.h | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 86a53c21a38..2a7e0eaa0c3 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -318,11 +318,12 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP return; } #endif + Q_ASSERT(mask.width() <= c.w && mask.height() <= c.h); if (m_format == QFontEngine::Format_A32 || m_format == QFontEngine::Format_ARGB) { QImage ref(m_image.bits() + (c.x * 4 + c.y * m_image.bytesPerLine()), - qMax(mask.width(), c.w), qMax(mask.height(), c.h), m_image.bytesPerLine(), + qMin(mask.width(), c.w), qMin(mask.height(), c.h), m_image.bytesPerLine(), m_image.format()); QPainter p(&ref); p.setCompositionMode(QPainter::CompositionMode_Source); diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index 64a0ef6fe8d..85bedff5e6e 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -1776,15 +1776,25 @@ QFixed QFontEngineFT::scaledBitmapMetrics(QFixed m) const return m * scalableBitmapScaleFactor; } -glyph_metrics_t QFontEngineFT::scaledBitmapMetrics(const glyph_metrics_t &m) const +glyph_metrics_t QFontEngineFT::scaledBitmapMetrics(const glyph_metrics_t &m, const QTransform &t) const { + QTransform trans(t); + const qreal scaleFactor = scalableBitmapScaleFactor.toReal(); + trans.scale(scaleFactor, scaleFactor); + + QRectF rect(m.x.toReal(), m.y.toReal(), m.width.toReal(), m.height.toReal()); + QPointF offset(m.xoff.toReal(), m.yoff.toReal()); + + rect = trans.mapRect(rect); + offset = trans.map(offset); + glyph_metrics_t metrics; - metrics.x = scaledBitmapMetrics(m.x); - metrics.y = scaledBitmapMetrics(m.y); - metrics.width = scaledBitmapMetrics(m.width); - metrics.height = scaledBitmapMetrics(m.height); - metrics.xoff = scaledBitmapMetrics(m.xoff); - metrics.yoff = scaledBitmapMetrics(m.yoff); + metrics.x = QFixed::fromReal(rect.x()); + metrics.y = QFixed::fromReal(rect.y()); + metrics.width = QFixed::fromReal(rect.width()); + metrics.height = QFixed::fromReal(rect.height()); + metrics.xoff = QFixed::fromReal(offset.x()); + metrics.yoff = QFixed::fromReal(offset.y()); return metrics; } @@ -1878,7 +1888,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) unlockFace(); if (isScalableBitmap()) - overall = scaledBitmapMetrics(overall); + overall = scaledBitmapMetrics(overall, QTransform()); return overall; } @@ -1917,7 +1927,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph) unlockFace(); if (isScalableBitmap()) - overall = scaledBitmapMetrics(overall); + overall = scaledBitmapMetrics(overall, QTransform()); return overall; } @@ -1955,7 +1965,7 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, QFixed subPixe } if (isScalableBitmap()) - overall = scaledBitmapMetrics(overall); + overall = scaledBitmapMetrics(overall, matrix); return overall; } diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h b/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h index 2993e3b6163..c063f5df30c 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft_p.h @@ -321,7 +321,7 @@ private: int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const; bool shouldUseDesignMetrics(ShaperFlags flags) const; QFixed scaledBitmapMetrics(QFixed m) const; - glyph_metrics_t scaledBitmapMetrics(const glyph_metrics_t &m) const; + glyph_metrics_t scaledBitmapMetrics(const glyph_metrics_t &m, const QTransform &matrix) const; GlyphFormat defaultFormat; FT_Matrix matrix; From 5194817941985c766bbc7f80039a58e0cf504b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 6 Nov 2017 15:08:37 +0100 Subject: [PATCH 29/56] Cocoa: optimize backingstore flush on 10-bit displays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt draws the backing store to the window using CoreGrahics, which will trigger a slow RGB32 -> RGB64 conversion when the output display is a deep color display. Disable NSWindow dynamicDepthLimit and force the depthLimit to WindowDepthTwentyforBitRGB for the common case of 8-bit-per-component raster surfaces. This was benchmarked by resizing a simple QRasterWindow test case which fills the window area using QPainter::fillRect(). Before: 67.1% rgba64_image_mark_rgb32 10.8% __vImageCopyBuffer_block_invoke 6.0% madvise 5.0% _kernelrpc_mach_vm_deallocate_trap 4.1% qt_memfill32(unsigned int*, unsigned int, int) After: 30.7% __vImageCopyBuffer_block_invoke 20.3% madvise 12.3% __vOverwriteChannelsWithScalar_ARGB8888_block_invoke 12.2% qt_memfill32(unsigned int*, unsigned int, int) 4.6% _kernelrpc_mach_vm_deallocate_trap The test program now spends significantly more of its time allocating/deallocating the backing store (madvise), and running the Qt paint event (qt_memfill32). Task-number: QTBUG-47660 Change-Id: I878be7a0e6eee4ad798f7a53f7f9f79b7950af26 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c6fa6795c15..5cd4beb4f0e 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1887,6 +1887,21 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBeChildNSWindow, bool sh applyContentBorderThickness(window); + // Prevent CoreGraphics RGB32 -> RGB64 backing store conversions on deep color + // displays by forcing 8-bit components, unless a deep color format has been + // requested. This conversion uses significant CPU time. + QSurface::SurfaceType surfaceType = QPlatformWindow::window()->surfaceType(); + bool usesCoreGraphics = surfaceType == QSurface::RasterSurface || surfaceType == QSurface::RasterGLSurface; + QSurfaceFormat surfaceFormat = QPlatformWindow::window()->format(); + bool usesDeepColor = surfaceFormat.redBufferSize() > 8 || + surfaceFormat.greenBufferSize() > 8 || + surfaceFormat.blueBufferSize() > 8; + bool usesLayer = view().layer; + if (usesCoreGraphics && !usesDeepColor && !usesLayer) { + [window setDynamicDepthLimit:NO]; + [window setDepthLimit:NSWindowDepthTwentyfourBitRGB]; + } + return window; } From eb5994df1307b2e17e729374e1f7ab1c8fe82750 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 3 Nov 2017 13:40:17 +0100 Subject: [PATCH 30/56] tst_QWidget::multipleToplevelFocusCheck(): Avoid overlapping The test showed flakyness on Linux. It has been observed that its windows overlap. Position the windows beside each other. Change-Id: I4ff1b9cafaf753a6844b3dfabb576a07f74b396a Reviewed-by: Gatis Paeglis --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index a7aa99d2a84..c1bff5b00ad 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -5176,19 +5176,22 @@ void tst_QWidget::multipleToplevelFocusCheck() TopLevelFocusCheck w1; TopLevelFocusCheck w2; + const QString title = QLatin1String(QTest::currentTestFunction()); + w1.setWindowTitle(title + QLatin1String("_W1")); + w1.move(m_availableTopLeft + QPoint(20, 20)); w1.resize(200, 200); w1.show(); QVERIFY(QTest::qWaitForWindowExposed(&w1)); + w2.setWindowTitle(title + QLatin1String("_W2")); + w2.move(w1.frameGeometry().topRight() + QPoint(20, 0)); w2.resize(200,200); w2.show(); QVERIFY(QTest::qWaitForWindowExposed(&w2)); - QTest::qWait(50); QApplication::setActiveWindow(&w1); w1.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&w1)); QCOMPARE(QApplication::activeWindow(), static_cast(&w1)); - QTest::qWait(50); QTest::mouseDClick(&w1, Qt::LeftButton); QTRY_COMPARE(QApplication::focusWidget(), static_cast(w1.edit)); From 0445065645daab1dd9c328e52313646dcfcc80c2 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Sun, 5 Nov 2017 12:56:50 +0100 Subject: [PATCH 31/56] Run oraArrayBind() test only for Oracle DBMS This test contains Oracle specific queries and will fail for other DBMS. Currently it doesn't fail, because it is skipped for drivers that doesn't support BatchOperations and only QOCI supports batch operations. Change-Id: I8f1e7c7244726fa11c841023dec186553747a6b5 Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 35f86772e2a..dc304513e26 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -146,7 +146,7 @@ private slots: void batchExec(); void QTBUG_43874_data() { generic_data(); } void QTBUG_43874(); - void oraArrayBind_data() { generic_data(); } + void oraArrayBind_data() { generic_data("QOCI"); } void oraArrayBind(); void lastInsertId_data() { generic_data(); } void lastInsertId(); From b4f4c384d9ee7cf93cc3db289a7d4275ac10a618 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 28 Oct 2017 13:20:53 +0200 Subject: [PATCH 32/56] QHeaderView: Honor maximumSectionSize property during resizeSections() Resizing a QTreeeView section with double click or resizeColumnToContents() does not respect the maximumSectionSize when the resize mode is Interactive or Fixed. Since the documentation of maximumSectionSize states that it should honor this property for those cases either the documentation or implementation is incorrect. This patch fixes the latter. Task-number: QTBUG-64036 Change-Id: Ic14c8e444d50b9c50a117efed19d0bca7ec1cf82 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qheaderview.cpp | 2 +- tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 213cc96b032..3af191b06c2 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3364,7 +3364,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool // because it isn't stretch, determine its width and remove that from lengthToStretch int sectionSize = 0; if (resizeMode == QHeaderView::Interactive || resizeMode == QHeaderView::Fixed) { - sectionSize = headerSectionSize(i); + sectionSize = qBound(q->minimumSectionSize(), headerSectionSize(i), q->maximumSectionSize()); } else { // resizeMode == QHeaderView::ResizeToContents int logicalIndex = q->logicalIndex(i); sectionSize = qMax(viewSectionSizeHint(logicalIndex), diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index b13e7b2f339..fa543ae2c32 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -3006,6 +3006,7 @@ void tst_QHeaderView::stretchAndRestoreLastSection() tv.setModel(&m); tv.showMaximized(); + const int minimumSectionSize = 20; const int defaultSectionSize = 30; const int someOtherSectionSize = 40; const int biggerSizeThanAnySection = 50; @@ -3013,6 +3014,9 @@ void tst_QHeaderView::stretchAndRestoreLastSection() QVERIFY(QTest::qWaitForWindowExposed(&tv)); QHeaderView &header = *tv.horizontalHeader(); + // set minimum size before resizeSections() is called + // which is done inside setStretchLastSection + header.setMinimumSectionSize(minimumSectionSize); header.setDefaultSectionSize(defaultSectionSize); header.resizeSection(9, someOtherSectionSize); header.setStretchLastSection(true); From 2937ab9e320ea04fdfda8e3a252559d4762e811e Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 31 Oct 2017 19:47:12 +0100 Subject: [PATCH 33/56] QHeaderView: Skip hidden sections on cascading resize When a section is hidden, QHeaderViewPrivate::cascadingResize() does resize a section even it is hidden. This leads to space between the neighbor sections and also some unneeded calculations. Task-number: QTBUG-54601 Change-Id: Ie139417ae2c77ef25e66cf628bfe400185f88ee8 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qheaderview.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 3af191b06c2..298270a7852 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3539,6 +3539,8 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) // cascade the section size change for (int i = visual + 1; i < sectionCount(); ++i) { + if (isVisualIndexHidden(i)) + continue; if (!sectionIsCascadable(i)) continue; int currentSectionSize = headerSectionSize(i); @@ -3581,6 +3583,8 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) // cascade the section size change if (delta < 0 && newSize < minimumSize) { for (int i = visual - 1; i >= 0; --i) { + if (isVisualIndexHidden(i)) + continue; if (!sectionIsCascadable(i)) continue; int sectionSize = headerSectionSize(i); @@ -3595,6 +3599,8 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) // let the next section get the space from the resized section if (!sectionResized) { for (int i = visual + 1; i < sectionCount(); ++i) { + if (isVisualIndexHidden(i)) + continue; if (!sectionIsCascadable(i)) continue; int currentSectionSize = headerSectionSize(i); From 28937559b1e03f959cd012c6b42ca988311893f5 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 3 Nov 2017 12:02:12 +0100 Subject: [PATCH 34/56] tst_qxmlsimplereader::inputFromSocket - fix race condition(s) This test was failing recently on Windows 7, mingw, x86. It's not failing now and attempts to reproduce the failure on CI's VM were unsuccessful. Anyway, just reading the code is enough to spot race-conditions: two threads are accessing two shared boolean variables without any protection. It's unclear if these races were the reason why the test was failing, but we fix them for good anyway. Also, a failure to start a thread or to start listening on a TCP socket is not treated as XML-related failure anymore and QSKIPped instead. Change-Id: I5115ce6c33cafc91485f8cf6e7e268d954976556 Reviewed-by: Timur Pocheptsov --- .../qxmlsimplereader/tst_qxmlsimplereader.cpp | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp index f77fd2ebab0..8c4c6c7179d 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -47,10 +49,11 @@ class XmlServer : public QThread { Q_OBJECT public: - XmlServer(QObject *parent = 0) : QThread(parent), quit_soon(false), listening(false) {} + XmlServer(QObject *parent = 0) : QThread(parent) {} - bool quit_soon; - bool listening; + QSemaphore threadStarted; + bool listening = false; + QAtomicInt quitSoon; protected: virtual void run(); @@ -63,6 +66,8 @@ void XmlServer::run() QTcpServer srv; listening = srv.listen(QHostAddress::Any, TEST_PORT); + threadStarted.release(); + if (!listening) { qWarning() << "Failed to listen on" << TEST_PORT << srv.errorString(); return; @@ -95,14 +100,13 @@ void XmlServer::run() QByteArray data = file.readAll(); for (int i = 0; i < data.size();) { -// sock->putChar(data.at(i)); int cnt = qMin(CHUNK_SIZE, data.size() - i); sock->write(data.constData() + i, cnt); i += cnt; sock->flush(); QTest::qSleep(1); - if (quit_soon) { + if (quitSoon.loadAcquire()) { sock->abort(); break; } @@ -112,7 +116,7 @@ void XmlServer::run() delete sock; } - if (quit_soon) + if (quitSoon.loadAcquire()) break; } @@ -162,7 +166,7 @@ tst_QXmlSimpleReader::tst_QXmlSimpleReader() : server(new XmlServer(this)) tst_QXmlSimpleReader::~tst_QXmlSimpleReader() { - server->quit_soon = true; + server->quitSoon.storeRelease(1); server->wait(); } @@ -562,7 +566,19 @@ void tst_QXmlSimpleReader::inputFromSocket() QSKIP("WinRT does not support connecting to localhost"); #endif - QTRY_VERIFY_WITH_TIMEOUT(server->listening, 15000); + if (!server->threadStarted.tryAcquire(1, 15000)) { + // If something is wrong with QThreads, it's not a reason to fail + // XML-test, we are not testing QThread here after all! + QSKIP("XmlServer/thread has not started yet"); + } + + // Subsequent runs should be able to acquire the semaphore. + server->threadStarted.release(1); + + if (!server->listening) { + // Again, QTcpServer is not the subject of this test! + QSKIP("QTcpServer::listen failed, bailing out"); + } QTcpSocket sock; sock.connectToHost(QHostAddress::LocalHost, TEST_PORT); From b084837ffc34439710552cb6ed31054c60f6b2d4 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 1 Nov 2017 15:19:45 +0100 Subject: [PATCH 35/56] Update bundled libpng to version 1.6.34 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an upstream bug in the existing version 1.6.32 which would cause certain valid png files to be rejected. The remaining diff to clean 1.6.34 is archived in the qtpatches.diff file. [ChangeLog][Third-Party Code] libpng was updated to version 1.6.34 Task-number: QTBUG-63950 Change-Id: Ie6f2a09c78a93b6e5623848776b75650bb5bca66 Reviewed-by: André Klitzing Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/libpng/ANNOUNCE | 77 ++++--------------------- src/3rdparty/libpng/CHANGES | 51 +++++++++++++++- src/3rdparty/libpng/LICENSE | 4 +- src/3rdparty/libpng/README | 2 +- src/3rdparty/libpng/libpng-manual.txt | 21 +++++-- src/3rdparty/libpng/png.c | 34 +++++------ src/3rdparty/libpng/png.h | 28 ++++----- src/3rdparty/libpng/pngconf.h | 2 +- src/3rdparty/libpng/pnglibconf.h | 4 +- src/3rdparty/libpng/pngread.c | 14 ++++- src/3rdparty/libpng/pngrtran.c | 22 +++---- src/3rdparty/libpng/pngrutil.c | 47 +++++++-------- src/3rdparty/libpng/pngtrans.c | 6 +- src/3rdparty/libpng/pngwrite.c | 2 +- src/3rdparty/libpng/qt_attribution.json | 2 +- 15 files changed, 162 insertions(+), 154 deletions(-) diff --git a/src/3rdparty/libpng/ANNOUNCE b/src/3rdparty/libpng/ANNOUNCE index 3cbe5a926e9..0f66c0d1da6 100644 --- a/src/3rdparty/libpng/ANNOUNCE +++ b/src/3rdparty/libpng/ANNOUNCE @@ -1,4 +1,4 @@ -Libpng 1.6.32 - August 24, 2017 +Libpng 1.6.34 - September 29, 2017 This is a public release of libpng, intended for use in production codes. @@ -7,79 +7,24 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - libpng-1.6.32.tar.xz (LZMA-compressed, recommended) - libpng-1.6.32.tar.gz + libpng-1.6.34.tar.xz (LZMA-compressed, recommended) + libpng-1.6.34.tar.gz Source files with CRLF line endings (for Windows), without the "configure" script - lpng1632.7z (LZMA-compressed, recommended) - lpng1632.zip + lpng1634.7z (LZMA-compressed, recommended) + lpng1634.zip Other information: - libpng-1.6.32-README.txt - libpng-1.6.32-LICENSE.txt - libpng-1.6.32-*.asc (armored detached GPG signatures) + libpng-1.6.34-README.txt + libpng-1.6.34-LICENSE.txt + libpng-1.6.34-*.asc (armored detached GPG signatures) -Changes since the last public release (1.6.31): - Avoid possible NULL dereference in png_handle_eXIf when benign_errors - are allowed. Avoid leaking the input buffer "eXIf_buf". - Eliminated png_ptr->num_exif member from pngstruct.h and added num_exif - to arguments for png_get_eXIf() and png_set_eXIf(). - Added calls to png_handle_eXIf(() in pngread.c and png_write_eXIf() in - pngwrite.c, and made various other fixes to png_write_eXIf(). - Changed name of png_get_eXIF and png_set_eXIf() to png_get_eXIf_1() and - png_set_eXIf_1(), respectively, to avoid breaking API compatibility - with libpng-1.6.31. - Updated contrib/libtests/pngunknown.c with eXIf chunk. - Initialized btoa[] in pngstest.c - Stop memory leak when returning from png_handle_eXIf() with an error - (Bug report from the OSS-fuzz project). - Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf(). - Update libpng.3 and libpng-manual.txt about eXIf functions. - Restored png_get_eXIf() and png_set_eXIf() to maintain API compatability. - Removed png_get_eXIf_1() and png_set_eXIf_1(). - Check length of all chunks except IDAT against user limit to fix an - OSS-fuzz issue. - Check length of IDAT against maximum possible IDAT size, accounting - for height, rowbytes, interlacing and zlib/deflate overhead. - Restored png_get_eXIf_1() and png_set_eXIf_1(), because strlen(eXIf_buf) - does not work (the eXIf chunk data can contain zeroes). - Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation, - no longer using deprecated cmake LOCATION feature (Clifford Yapp). - Fixed five-byte error in the calculation of IDAT maximum possible size. - Moved chunk-length check into a png_check_chunk_length() private - function (Suggested by Max Stepin). - Moved bad pngs from tests to contrib/libtests/crashers - Moved testing of bad pngs into a separate tests/pngtest-badpngs script - Added the --xfail (expected FAIL) option to pngtest.c. It writes XFAIL - in the output but PASS for the libpng test. - Require cmake-3.0.2 in CMakeLists.txt (Clifford Yapp). - Fix "const" declaration info_ptr argument to png_get_eXIf_1() and the - num_exif argument to png_get_eXIf_1() (Github Issue 171). - Added "eXIf" to "chunks_to_ignore[]" in png_set_keep_unknown_chunks(). - Added huge_IDAT.png and empty_ancillary_chunks.png to testpngs/crashers. - Make pngtest --strict, --relax, --xfail options imply -m (multiple). - Removed unused chunk_name parameter from png_check_chunk_length(). - Relocated setting free_me for eXIf data, to stop an OSS-fuzz leak. - Initialize profile_header[] in png_handle_iCCP() to fix OSS-fuzz issue. - Initialize png_ptr->row_buf[0] to 255 in png_read_row() to fix OSS-fuzz UMR. - Attempt to fix a UMR in png_set_text_2() to fix OSS-fuzz issue. - Increase minimum zlib stream from 9 to 14 in png_handle_iCCP(), to account - for the minimum 'deflate' stream, and relocate the test to a point - after the keyword has been read. - Check that the eXIf chunk has at least 2 bytes and begins with "II" or "MM". - Added a set of "huge_xxxx_chunk.png" files to contrib/testpngs/crashers, - one for each known chunk type, with length = 2GB-1. - Check for 0 return from png_get_rowbytes() and added some (size_t) typecasts - in contrib/pngminus/*.c to stop some Coverity issues (162705, 162706, - and 162707). - Renamed chunks in contrib/testpngs/crashers to avoid having files whose - names differ only in case; this causes problems with some platforms - (github issue #172). - Added contrib/oss-fuzz directory which contains files used by the oss-fuzz - project (https://github.com/google/oss-fuzz/tree/master/projects/libpng). +Changes since the last public release (1.6.33): + Removed contrib/pngsuite/i*.png; some of these were incorrect and caused + test failures. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/src/3rdparty/libpng/CHANGES b/src/3rdparty/libpng/CHANGES index 14e60dd2697..4b82118910e 100644 --- a/src/3rdparty/libpng/CHANGES +++ b/src/3rdparty/libpng/CHANGES @@ -833,7 +833,7 @@ Version 1.0.7beta11 [May 7, 2000] Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes which are no longer used. Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is - defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED + defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXt_SUPPORTED is defined. Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory overrun when old applications fill the info_ptr->text structure directly. @@ -5939,7 +5939,7 @@ Version 1.6.32beta06 [August 2, 2017] Version 1.6.32beta07 [August 3, 2017] Check length of all chunks except IDAT against user limit to fix an - OSS-fuzz issue. + OSS-fuzz issue (Fixes CVE-2017-12652). Version 1.6.32beta08 [August 3, 2017] Check length of IDAT against maximum possible IDAT size, accounting @@ -5994,6 +5994,53 @@ Version 1.6.32rc02 [August 22, 2017] Version 1.6.32 [August 24, 2017] No changes. +Version 1.6.33beta01 [August 28, 2017] + Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing + parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse). + Fixed off-by-one error in png_do_check_palette_indexes() (Bug report + by Mick P., Source Forge Issue #269). + +Version 1.6.33beta02 [September 3, 2017] + Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc + to fix shortlived oss-fuzz issue 3234. + Compute a larger limit on IDAT because some applications write a deflate + buffer for each row (Bug report by Andrew Church). + Use current date (DATE) instead of release-date (RDATE) in last + changed date of contrib/oss-fuzz files. + Enabled ARM support in CMakeLists.txt (Bernd Kuhls). + +Version 1.6.33beta03 [September 14, 2017] + Fixed incorrect typecast of some arguments to png_malloc() and + png_calloc() that were png_uint_32 instead of png_alloc_size_t + (Bug report by "irwir" in Github libpng issue #175). + Use pnglibconf.h.prebuilt when building for ANDROID with cmake (Github + issue 162, by rcdailey). + +Version 1.6.33rc01 [September 20, 2017] + Initialize memory allocated by png_inflate to zero, using memset, to + stop an oss-fuzz "use of uninitialized value" detection in png_set_text_2() + due to truncated iTXt or zTXt chunk. + Initialize memory allocated by png_read_buffer to zero, using memset, to + stop an oss-fuzz "use of uninitialized value" detection in + png_icc_check_tag_table() due to truncated iCCP chunk. + Removed a redundant test (suggested by "irwir" in Github issue #180). + +Version 1.6.33rc02 [September 23, 2017] + Added an interlaced version of each file in contrib/pngsuite. + Relocate new memset() call in pngrutil.c. + Removed more redundant tests (suggested by "irwir" in Github issue #180). + Add support for loading images with associated alpha in the Simplified + API (Samuel Williams). + +Version 1.6.33 [September 28, 2017] + Revert contrib/oss-fuzz/libpng_read_fuzzer.cc to libpng-1.6.32 state. + Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc + Add end_info structure and png_read_end() to the libpng fuzzer. + +Version 1.6.34 [September 29, 2017] + Removed contrib/pngsuite/i*.png; some of these were incorrect and caused + test failures. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/src/3rdparty/libpng/LICENSE b/src/3rdparty/libpng/LICENSE index e803911d37b..4cda4fa0add 100644 --- a/src/3rdparty/libpng/LICENSE +++ b/src/3rdparty/libpng/LICENSE @@ -10,7 +10,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.0.7, July 1, 2000 through 1.6.32, August 24, 2017 are +libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are derived from libpng-1.0.6, and are distributed according to the same disclaimer and license as libpng-1.0.6 with the following individuals @@ -130,4 +130,4 @@ any encryption software. See the EAR, paragraphs 734.3(b)(3) and Glenn Randers-Pehrson glennrp at users.sourceforge.net -April 1, 2017 +September 29, 2017 diff --git a/src/3rdparty/libpng/README b/src/3rdparty/libpng/README index 71292715eba..0da5a5ef839 100644 --- a/src/3rdparty/libpng/README +++ b/src/3rdparty/libpng/README @@ -1,4 +1,4 @@ -README for libpng version 1.6.32 - August 24, 2017 (shared library 16.0) +README for libpng version 1.6.34 - September 29, 2017 (shared library 16.0) See the note about version numbers near the top of png.h See INSTALL for instructions on how to install libpng. diff --git a/src/3rdparty/libpng/libpng-manual.txt b/src/3rdparty/libpng/libpng-manual.txt index e34b1436f55..d4407ef2ea0 100644 --- a/src/3rdparty/libpng/libpng-manual.txt +++ b/src/3rdparty/libpng/libpng-manual.txt @@ -1,6 +1,6 @@ libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.6.32 - August 24, 2017 + libpng version 1.6.34 - September 29, 2017 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2017 Glenn Randers-Pehrson @@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.6.32 - August 24, 2017 + libpng versions 0.97, January 1998, through 1.6.34 - September 29, 2017 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2017 Glenn Randers-Pehrson @@ -986,8 +986,17 @@ premultiplication. png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); -This is the default libpng handling of the alpha channel - it is not -pre-multiplied into the color components. In addition the call states +Choices for the alpha_mode are + + PNG_ALPHA_PNG 0 /* according to the PNG standard */ + PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ + PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ + PNG_ALPHA_PREMULTIPLIED 1 /* as above */ + PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ + PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ + +PNG_ALPHA_PNG is the default libpng handling of the alpha channel. It is not +pre-multiplied into the color components. In addition the call states that the output is for a sRGB system and causes all PNG files without gAMA chunks to be assumed to be encoded using sRGB. @@ -1002,7 +1011,7 @@ early Mac systems behaved. This is the classic Jim Blinn approach and will work in academic environments where everything is done by the book. It has the shortcoming of assuming that input PNG data with no gamma information is linear - this -is unlikely to be correct unless the PNG files where generated locally. +is unlikely to be correct unless the PNG files were generated locally. Most of the time the output precision will be so low as to show significant banding in dark areas of the image. @@ -5405,7 +5414,7 @@ Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.6.32 are Y2K compliant. It is my belief that earlier +upward through 1.6.34 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has two year fields. One is a 2-byte unsigned integer diff --git a/src/3rdparty/libpng/png.c b/src/3rdparty/libpng/png.c index 2352df13cba..ff02c56518c 100644 --- a/src/3rdparty/libpng/png.c +++ b/src/3rdparty/libpng/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.6.32 [August 24, 2017] + * Last changed in libpng 1.6.33 [September 28, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_32 Your_png_h_is_not_version_1_6_32; +typedef png_libpng_version_1_6_34 Your_png_h_is_not_version_1_6_34; #ifdef __GNUC__ /* The version tests may need to be added to, but the problem warning has @@ -816,14 +816,14 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.6.32 - August 24, 2017" PNG_STRING_NEWLINE \ + "libpng version 1.6.34 - September 29, 2017" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.6.32 - August 24, 2017\ + return "libpng version 1.6.34 - September 29, 2017\ Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -1913,12 +1913,12 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, */ if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST) return png_icc_profile_error(png_ptr, colorspace, "sRGB", - (unsigned)intent, "invalid sRGB rendering intent"); + (png_alloc_size_t)intent, "invalid sRGB rendering intent"); if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 && colorspace->rendering_intent != intent) return png_icc_profile_error(png_ptr, colorspace, "sRGB", - (unsigned)intent, "inconsistent rendering intents"); + (png_alloc_size_t)intent, "inconsistent rendering intents"); if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0) { @@ -1979,7 +1979,6 @@ icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, if (profile_length < 132) return png_icc_profile_error(png_ptr, colorspace, name, profile_length, "too short"); - return 1; } @@ -2224,15 +2223,6 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, * being in range. All defined tag types have an 8 byte header - a 4 byte * type signature then 0. */ - if ((tag_start & 3) != 0) - { - /* CNHP730S.icc shipped with Microsoft Windows 64 violates this, it is - * only a warning here because libpng does not care about the - * alignment. - */ - (void)png_icc_profile_error(png_ptr, NULL, name, tag_id, - "ICC profile tag start not a multiple of 4"); - } /* This is a hard error; potentially it can cause read outside the * profile. @@ -2240,6 +2230,16 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, if (tag_start > profile_length || tag_length > profile_length - tag_start) return png_icc_profile_error(png_ptr, colorspace, name, tag_id, "ICC profile tag outside profile"); + + if ((tag_start & 3) != 0) + { + /* CNHP730S.icc shipped with Microsoft Windows 64 violates this; it is + * only a warning here because libpng does not care about the + * alignment. + */ + (void)png_icc_profile_error(png_ptr, NULL, name, tag_id, + "ICC profile tag start not a multiple of 4"); + } } return 1; /* success, maybe with warnings */ @@ -3761,7 +3761,7 @@ png_log16bit(png_uint_32 x) * of getting this accuracy in practice. * * To deal with this the following exp() function works out the exponent of the - * frational part of the logarithm by using an accurate 32-bit value from the + * fractional part of the logarithm by using an accurate 32-bit value from the * top four fractional bits then multiplying in the remaining bits. */ static const png_uint_32 diff --git a/src/3rdparty/libpng/png.h b/src/3rdparty/libpng/png.h index 51ac8abe747..4c873f5c22e 100644 --- a/src/3rdparty/libpng/png.h +++ b/src/3rdparty/libpng/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.32, August 24, 2017 + * libpng version 1.6.34, September 29, 2017 * * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -12,7 +12,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.32, August 24, 2017: + * libpng versions 0.97, January 1998, through 1.6.34, September 29, 2017: * Glenn Randers-Pehrson. * See also "Contributing Authors", below. */ @@ -25,7 +25,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.0.7, July 1, 2000 through 1.6.32, August 24, 2017 are + * libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are * Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are * derived from libpng-1.0.6, and are distributed according to the same * disclaimer and license as libpng-1.0.6 with the following individuals @@ -209,11 +209,11 @@ * ... * 1.0.19 10 10019 10.so.0.19[.0] * ... - * 1.2.57 13 10257 12.so.0.57[.0] + * 1.2.59 13 10257 12.so.0.59[.0] * ... - * 1.5.28 15 10527 15.so.15.28[.0] + * 1.5.30 15 10527 15.so.15.30[.0] * ... - * 1.6.32 16 10632 16.so.16.32[.0] + * 1.6.34 16 10633 16.so.16.34[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -241,13 +241,13 @@ * Y2K compliance in libpng: * ========================= * - * August 24, 2017 + * September 29, 2017 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.6.32 are Y2K compliant. It is my belief that + * upward through 1.6.34 are Y2K compliant. It is my belief that * earlier versions were also Y2K compliant. * * Libpng only has two year fields. One is a 2-byte unsigned integer @@ -309,8 +309,8 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.32" -#define PNG_HEADER_VERSION_STRING " libpng version 1.6.32 - August 24, 2017\n" +#define PNG_LIBPNG_VER_STRING "1.6.34" +#define PNG_HEADER_VERSION_STRING " libpng version 1.6.34 - September 29, 2017\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -318,7 +318,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 32 +#define PNG_LIBPNG_VER_RELEASE 34 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: @@ -349,7 +349,7 @@ * version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10632 /* 1.6.32 */ +#define PNG_LIBPNG_VER 10634 /* 1.6.34 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -459,7 +459,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_32; +typedef char* png_libpng_version_1_6_34; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * @@ -2819,6 +2819,8 @@ typedef struct # define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ #endif +#define PNG_FORMAT_FLAG_ASSOCIATED_ALPHA 0x40U /* alpha channel is associated */ + /* Commonly used formats have predefined macros. * * First the single byte (sRGB) formats: diff --git a/src/3rdparty/libpng/pngconf.h b/src/3rdparty/libpng/pngconf.h index c0f15547be4..d13b13e57ae 100644 --- a/src/3rdparty/libpng/pngconf.h +++ b/src/3rdparty/libpng/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.6.32, August 24, 2017 + * libpng version 1.6.34, September 29, 2017 * * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/src/3rdparty/libpng/pnglibconf.h b/src/3rdparty/libpng/pnglibconf.h index 9e45f73129a..53b5e442c4b 100644 --- a/src/3rdparty/libpng/pnglibconf.h +++ b/src/3rdparty/libpng/pnglibconf.h @@ -1,8 +1,8 @@ -/* libpng 1.6.32 STANDARD API DEFINITION */ +/* libpng 1.6.34 STANDARD API DEFINITION */ /* pnglibconf.h - library build configuration */ -/* Libpng version 1.6.32 - August 24, 2017 */ +/* Libpng version 1.6.34 - September 29, 2017 */ /* Copyright (c) 1998-2017 Glenn Randers-Pehrson */ diff --git a/src/3rdparty/libpng/pngread.c b/src/3rdparty/libpng/pngread.c index e34ddd99a08..da32e9ad9ce 100644 --- a/src/3rdparty/libpng/pngread.c +++ b/src/3rdparty/libpng/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.6.32 [August 24, 2017] + * Last changed in libpng 1.6.33 [September 28, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -3759,7 +3759,13 @@ png_image_read_direct(png_voidp argument) mode = PNG_ALPHA_PNG; output_gamma = PNG_DEFAULT_sRGB; } - + + if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) + { + mode = PNG_ALPHA_OPTIMIZED; + change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA; + } + /* If 'do_local_background' is set check for the presence of gamma * correction; this is part of the work-round for the libpng bug * described above. @@ -3985,6 +3991,10 @@ png_image_read_direct(png_voidp argument) else if (do_local_compose != 0) /* internal error */ png_error(png_ptr, "png_image_read: alpha channel lost"); + if ((format & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) { + info_format |= PNG_FORMAT_FLAG_ASSOCIATED_ALPHA; + } + if (info_ptr->bit_depth == 16) info_format |= PNG_FORMAT_FLAG_LINEAR; diff --git a/src/3rdparty/libpng/pngrtran.c b/src/3rdparty/libpng/pngrtran.c index 9a30ddf22bd..c1896503130 100644 --- a/src/3rdparty/libpng/pngrtran.c +++ b/src/3rdparty/libpng/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.6.31 [July 27, 2017] + * Last changed in libpng 1.6.33 [September 28, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -430,7 +430,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, int i; png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); + (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); for (i = 0; i < num_palette; i++) png_ptr->quantize_index[i] = (png_byte)i; } @@ -447,7 +447,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, /* Initialize an array to sort colors */ png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); + (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); /* Initialize the quantize_sort array */ for (i = 0; i < num_palette; i++) @@ -581,9 +581,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, /* Initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); + (png_alloc_size_t)((png_uint_32)num_palette * + (sizeof (png_byte)))); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); + (png_alloc_size_t)((png_uint_32)num_palette * + (sizeof (png_byte)))); /* Initialize the sort array */ for (i = 0; i < num_palette; i++) @@ -592,7 +594,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, png_ptr->palette_to_index[i] = (png_byte)i; } - hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 * + hash = (png_dsortpp)png_calloc(png_ptr, (png_alloc_size_t)(769 * (sizeof (png_dsortp)))); num_new_palette = num_palette; @@ -623,7 +625,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, { t = (png_dsortp)png_malloc_warn(png_ptr, - (png_uint_32)(sizeof (png_dsort))); + (png_alloc_size_t)(sizeof (png_dsort))); if (t == NULL) break; @@ -748,9 +750,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, png_size_t num_entries = ((png_size_t)1 << total_bits); png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, - (png_uint_32)(num_entries * (sizeof (png_byte)))); + (png_alloc_size_t)(num_entries * (sizeof (png_byte)))); - distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * + distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries * (sizeof (png_byte)))); memset(distance, 0xff, num_entries * (sizeof (png_byte))); @@ -3322,7 +3324,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= + tmp |= (unsigned int)(png_ptr->background.gray << shift); *sp = (png_byte)(tmp & 0xff); } diff --git a/src/3rdparty/libpng/pngrutil.c b/src/3rdparty/libpng/pngrutil.c index a4fa71457b9..8692933bd8b 100644 --- a/src/3rdparty/libpng/pngrutil.c +++ b/src/3rdparty/libpng/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.6.32 [August 24, 2017] + * Last changed in libpng 1.6.33 [September 28, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -314,6 +314,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) if (buffer != NULL) { + memset(buffer, 0, new_size); /* just in case */ png_ptr->read_buffer = buffer; png_ptr->read_buffer_size = new_size; } @@ -673,6 +674,8 @@ png_decompress_chunk(png_structrp png_ptr, if (text != NULL) { + memset(text, 0, buffer_size); + ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, png_ptr->read_buffer + prefix_size, &lzsize, text + prefix_size, newlength); @@ -736,9 +739,7 @@ png_decompress_chunk(png_structrp png_ptr, { /* inflateReset failed, store the error message */ png_zstream_error(png_ptr, ret); - - if (ret == Z_STREAM_END) - ret = PNG_UNEXPECTED_ZLIB_RETURN; + ret = PNG_UNEXPECTED_ZLIB_RETURN; } } @@ -1476,7 +1477,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) /* Now read the tag table; a variable size buffer is * needed at this point, allocate one for the whole * profile. The header check has already validated - * that none of these stuff will overflow. + * that none of this stuff will overflow. */ const png_uint_32 tag_count = png_get_uint_32( profile_header+128); @@ -1583,19 +1584,11 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) return; } } - - else if (size > 0) - errmsg = "truncated"; - -#ifndef __COVERITY__ - else + if (errmsg == NULL) errmsg = png_ptr->zstream.msg; -#endif } - /* else png_icc_check_tag_table output an error */ } - else /* profile truncated */ errmsg = png_ptr->zstream.msg; } @@ -3144,28 +3137,28 @@ png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length) { png_alloc_size_t limit = PNG_UINT_31_MAX; - if (png_ptr->chunk_name != png_IDAT) - { # ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_malloc_max > 0 && - png_ptr->user_chunk_malloc_max < limit) - limit = png_ptr->user_chunk_malloc_max; + if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < limit) + limit = png_ptr->user_chunk_malloc_max; # elif PNG_USER_CHUNK_MALLOC_MAX > 0 - if (PNG_USER_CHUNK_MALLOC_MAX < limit) - limit = PNG_USER_CHUNK_MALLOC_MAX; + if (PNG_USER_CHUNK_MALLOC_MAX < limit) + limit = PNG_USER_CHUNK_MALLOC_MAX; # endif - } - else + if (png_ptr->chunk_name == png_IDAT) { + png_alloc_size_t idat_limit = PNG_UINT_31_MAX; size_t row_factor = (png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1) + 1 + (png_ptr->interlaced? 6: 0)); if (png_ptr->height > PNG_UINT_32_MAX/row_factor) - limit=PNG_UINT_31_MAX; + idat_limit=PNG_UINT_31_MAX; else - limit = png_ptr->height * row_factor; - limit += 6 + 5*(limit/32566+1); /* zlib+deflate overhead */ - limit=limit < PNG_UINT_31_MAX? limit : PNG_UINT_31_MAX; + idat_limit = png_ptr->height * row_factor; + row_factor = row_factor > 32566? 32566 : row_factor; + idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */ + idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX; + limit = limit < idat_limit? idat_limit : limit; } if (length > limit) diff --git a/src/3rdparty/libpng/pngtrans.c b/src/3rdparty/libpng/pngtrans.c index 326ac33f0e9..6882f0fd7b7 100644 --- a/src/3rdparty/libpng/pngtrans.c +++ b/src/3rdparty/libpng/pngtrans.c @@ -1,7 +1,7 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.6.30 [June 28, 2017] + * Last changed in libpng 1.6.33 [September 28, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -609,7 +609,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) return; /* The filler channel has gone already */ /* Fix the rowbytes value. */ - row_info->rowbytes = (unsigned int)(dp-row); + row_info->rowbytes = (png_size_t)(dp-row); } #endif @@ -708,7 +708,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) * forms produced on either GCC or MSVC. */ int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width); - png_bytep rp = png_ptr->row_buf + row_info->rowbytes; + png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1; switch (row_info->bit_depth) { diff --git a/src/3rdparty/libpng/pngwrite.c b/src/3rdparty/libpng/pngwrite.c index a7662acb71c..a16d77ce00c 100644 --- a/src/3rdparty/libpng/pngwrite.c +++ b/src/3rdparty/libpng/pngwrite.c @@ -1940,7 +1940,7 @@ png_image_write_main(png_voidp argument) int colormap = (format & PNG_FORMAT_FLAG_COLORMAP); int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */ int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA); - int write_16bit = linear && !colormap && (display->convert_to_8bit == 0); + int write_16bit = linear && (display->convert_to_8bit == 0); # ifdef PNG_BENIGN_ERRORS_SUPPORTED /* Make sure we error out on any bad situation */ diff --git a/src/3rdparty/libpng/qt_attribution.json b/src/3rdparty/libpng/qt_attribution.json index 7b2d7769784..23fb903bdd2 100644 --- a/src/3rdparty/libpng/qt_attribution.json +++ b/src/3rdparty/libpng/qt_attribution.json @@ -6,7 +6,7 @@ "Description": "libpng is the official PNG reference library.", "Homepage": "http://www.libpng.org/pub/png/libpng.html", - "Version": "1.6.32", + "Version": "1.6.34", "License": "libpng License", "LicenseId": "Libpng", "LicenseFile": "LICENSE", From d4b3ce9a287b81eb9d7c6750ccca89e362343261 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 1 Nov 2017 15:38:31 +0100 Subject: [PATCH 36/56] qudpsocket.pro - fix dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to the problem found in QTcpSocket auto-test recently. While the failure on CI looks differently (apparently, server process starts but does not print anything), fixing the dependency does not hurt and at least fixes the 'make check' scenario. Change-Id: I8f29f3e492d22410533407a527f5fc8f664e7f5c Reviewed-by: Gatis Paeglis Reviewed-by: Mårten Nordheim --- tests/auto/network/socket/qudpsocket/qudpsocket.pro | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/qudpsocket.pro b/tests/auto/network/socket/qudpsocket/qudpsocket.pro index 4ddb7178a4f..b267d5f249c 100644 --- a/tests/auto/network/socket/qudpsocket/qudpsocket.pro +++ b/tests/auto/network/socket/qudpsocket/qudpsocket.pro @@ -1,4 +1,3 @@ TEMPLATE = subdirs SUBDIRS = test clientserver - - +test.depends = clientserver From ab9f4d5db6a4e183b9a26366e659ba642dedcbdd Mon Sep 17 00:00:00 2001 From: Michael Winkelmann Date: Thu, 3 Aug 2017 15:43:26 +0200 Subject: [PATCH 37/56] Revamp QtConcurrent examples to C++11 I updated signals and slots and for each loops to the new syntax and replaced most free functions with std::function. Task-number: QTBUG-60641 Change-Id: I7693f81f71c7f53fcbe83189a0de2fb76ddf99a8 Reviewed-by: Edward Welbourne --- .../imagescaling/imagescaling.cpp | 28 ++++++++------- .../qtconcurrent/imagescaling/imagescaling.h | 4 +-- examples/qtconcurrent/map/main.cpp | 12 ++++--- examples/qtconcurrent/progressdialog/main.cpp | 34 ++++++++++--------- examples/qtconcurrent/wordcount/main.cpp | 27 ++++++++------- 5 files changed, 57 insertions(+), 48 deletions(-) diff --git a/examples/qtconcurrent/imagescaling/imagescaling.cpp b/examples/qtconcurrent/imagescaling/imagescaling.cpp index 0a230c1194b..6d22bb95982 100644 --- a/examples/qtconcurrent/imagescaling/imagescaling.cpp +++ b/examples/qtconcurrent/imagescaling/imagescaling.cpp @@ -48,15 +48,10 @@ ** ****************************************************************************/ #include "imagescaling.h" + #include -const int imageSize = 100; - -QImage scale(const QString &imageFileName) -{ - QImage image(imageFileName); - return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -} +#include Images::Images(QWidget *parent) : QWidget(parent) @@ -65,19 +60,19 @@ Images::Images(QWidget *parent) resize(800, 600); imageScaling = new QFutureWatcher(this); - connect(imageScaling, SIGNAL(resultReadyAt(int)), SLOT(showImage(int))); - connect(imageScaling, SIGNAL(finished()), SLOT(finished())); + connect(imageScaling, &QFutureWatcher::resultReadyAt, this, &Images::showImage); + connect(imageScaling, &QFutureWatcher::finished, this, &Images::finished); openButton = new QPushButton(tr("Open Images")); - connect(openButton, SIGNAL(clicked()), SLOT(open())); + connect(openButton, &QPushButton::clicked, this, &Images::open); cancelButton = new QPushButton(tr("Cancel")); cancelButton->setEnabled(false); - connect(cancelButton, SIGNAL(clicked()), imageScaling, SLOT(cancel())); + connect(cancelButton, &QPushButton::clicked, imageScaling, &QFutureWatcher::cancel); pauseButton = new QPushButton(tr("Pause/Resume")); pauseButton->setEnabled(false); - connect(pauseButton, SIGNAL(clicked()), imageScaling, SLOT(togglePaused())); + connect(pauseButton, &QPushButton::clicked, imageScaling, &QFutureWatcher::togglePaused); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addWidget(openButton); @@ -113,9 +108,11 @@ void Images::open() QStandardPaths::writableLocation(QStandardPaths::PicturesLocation), "*.jpg *.png"); - if (files.count() == 0) + if (files.isEmpty()) return; + const int imageSize = 100; + // Do a simple layout. qDeleteAll(labels); labels.clear(); @@ -130,6 +127,11 @@ void Images::open() } } + std::function scale = [imageSize](const QString &imageFileName) { + QImage image(imageFileName); + return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + }; + // Use mapped to run the thread safe scale function on the files. imageScaling->setFuture(QtConcurrent::mapped(files, scale)); diff --git a/examples/qtconcurrent/imagescaling/imagescaling.h b/examples/qtconcurrent/imagescaling/imagescaling.h index e2168e4b024..fe9c8013874 100644 --- a/examples/qtconcurrent/imagescaling/imagescaling.h +++ b/examples/qtconcurrent/imagescaling/imagescaling.h @@ -57,9 +57,9 @@ class Images : public QWidget { Q_OBJECT public: - Images(QWidget *parent = 0); + Images(QWidget *parent = nullptr); ~Images(); -public Q_SLOTS: +public slots: void open(); void showImage(int num); void finished(); diff --git a/examples/qtconcurrent/map/main.cpp b/examples/qtconcurrent/map/main.cpp index d01b91fe55e..8fc670b64b8 100644 --- a/examples/qtconcurrent/map/main.cpp +++ b/examples/qtconcurrent/map/main.cpp @@ -55,11 +55,7 @@ #include #include -QImage scale(const QImage &image) -{ - qDebug() << "Scaling image in thread" << QThread::currentThread(); - return image.scaled(QSize(100, 100), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -} +#include int main(int argc, char *argv[]) { @@ -72,6 +68,12 @@ int main(int argc, char *argv[]) for (int i = 0; i < imageCount; ++i) images.append(QImage(1600, 1200, QImage::Format_ARGB32_Premultiplied)); + std::function scale = [](const QImage &image) -> QImage + { + qDebug() << "Scaling image in thread" << QThread::currentThread(); + return image.scaled(QSize(100, 100), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + }; + // Use QtConcurrentBlocking::mapped to apply the scale function to all the // images in the list. QList thumbnails = QtConcurrent::blockingMapped(images, scale); diff --git a/examples/qtconcurrent/progressdialog/main.cpp b/examples/qtconcurrent/progressdialog/main.cpp index 0f251c00f1c..c277111813e 100644 --- a/examples/qtconcurrent/progressdialog/main.cpp +++ b/examples/qtconcurrent/progressdialog/main.cpp @@ -51,24 +51,16 @@ #include #include +#include + using namespace QtConcurrent; -const int iterations = 20; - -void spin(int &iteration) -{ - const int work = 1000 * 1000 * 40; - volatile int v = 0; - for (int j = 0; j < work; ++j) - ++v; - - qDebug() << "iteration" << iteration << "in thread" << QThread::currentThreadId(); -} - int main(int argc, char **argv) { QApplication app(argc, argv); + const int iterations = 20; + // Prepare the vector. QVector vector; for (int i = 0; i < iterations; ++i) @@ -80,10 +72,20 @@ int main(int argc, char **argv) // Create a QFutureWatcher and connect signals and slots. QFutureWatcher futureWatcher; - QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset())); - QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel())); - QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int,int)), &dialog, SLOT(setRange(int,int))); - QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int))); + QObject::connect(&futureWatcher, &QFutureWatcher::finished, &dialog, &QProgressDialog::reset); + QObject::connect(&dialog, &QProgressDialog::canceled, &futureWatcher, &QFutureWatcher::cancel); + QObject::connect(&futureWatcher, &QFutureWatcher::progressRangeChanged, &dialog, &QProgressDialog::setRange); + QObject::connect(&futureWatcher, &QFutureWatcher::progressValueChanged, &dialog, &QProgressDialog::setValue); + + // Our function to compute + std::function spin = [](int &iteration) { + const int work = 1000 * 1000 * 40; + volatile int v = 0; + for (int j = 0; j < work; ++j) + ++v; + + qDebug() << "iteration" << iteration << "in thread" << QThread::currentThreadId(); + }; // Start the computation. futureWatcher.setFuture(QtConcurrent::map(vector, spin)); diff --git a/examples/qtconcurrent/wordcount/main.cpp b/examples/qtconcurrent/wordcount/main.cpp index a5f8909f344..ff7ea24ee79 100644 --- a/examples/qtconcurrent/wordcount/main.cpp +++ b/examples/qtconcurrent/wordcount/main.cpp @@ -65,15 +65,17 @@ using namespace QtConcurrent; /* Utility function that recursivily searches for files. */ -QStringList findFiles(const QString &startDir, QStringList filters) +QStringList findFiles(const QString &startDir, const QStringList &filters) { QStringList names; QDir dir(startDir); - foreach (QString file, dir.entryList(filters, QDir::Files)) + const auto files = dir.entryList(filters, QDir::Files); + for (const QString &file : files) names += startDir + '/' + file; - foreach (QString subdir, dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot)) + const auto subdirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + for (const QString &subdir : subdirs) names += findFiles(startDir + '/' + subdir, filters); return names; } @@ -83,17 +85,18 @@ typedef QMap WordCount; /* Single threaded word counter function. */ -WordCount singleThreadedWordCount(QStringList files) +WordCount singleThreadedWordCount(const QStringList &files) { WordCount wordCount; - foreach (QString file, files) { + for (const QString &file : files) { QFile f(file); f.open(QIODevice::ReadOnly); QTextStream textStream(&f); - while (textStream.atEnd() == false) - foreach (const QString &word, textStream.readLine().split(' ')) + while (!textStream.atEnd()) { + const auto words = textStream.readLine().split(' '); + for (const QString &word : words) wordCount[word] += 1; - + } } return wordCount; } @@ -109,9 +112,11 @@ WordCount countWords(const QString &file) QTextStream textStream(&f); WordCount wordCount; - while (textStream.atEnd() == false) - foreach (const QString &word, textStream.readLine().split(' ')) + while (!textStream.atEnd()) { + const auto words = textStream.readLine().split(' '); + for (const QString &word : words) wordCount[word] += 1; + } return wordCount; } @@ -137,8 +142,6 @@ int main(int argc, char** argv) qDebug() << "warmup"; { - QTime time; - time.start(); WordCount total = singleThreadedWordCount(files); } From 75bbbfdc6cadf8572651bd021de616148154c39a Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 25 Oct 2017 10:31:47 +0200 Subject: [PATCH 38/56] Remove BSD-OLD, FDL-OLD license headers All code should be using the license header in header.BSD or header.FDL now. If modules still use outdated headers, they should be fixed or as a stop-gap measure add header.BSD-OLD, header.FDL-OLD files locally. Change-Id: If462f1646ab413c18d2d3c61197773dca2a036ec Reviewed-by: Jani Heikkinen --- header.BSD-OLD | 40 ---------------------------------------- header.FDL-OLD | 27 --------------------------- 2 files changed, 67 deletions(-) delete mode 100644 header.BSD-OLD delete mode 100644 header.FDL-OLD diff --git a/header.BSD-OLD b/header.BSD-OLD deleted file mode 100644 index 5d73a99e9fc..00000000000 --- a/header.BSD-OLD +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD-OLD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - diff --git a/header.FDL-OLD b/header.FDL-OLD deleted file mode 100644 index 58436c482a7..00000000000 --- a/header.FDL-OLD +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL-OLD$ -** 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. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - From 421df7570b80ad7073d1af9b636ad42b8eb79ee8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 7 Nov 2017 10:15:57 +0100 Subject: [PATCH 39/56] Enable glyph cache workaround for GC2000 as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The glyph cache resize is clearly doing something that is not actually legal with OpenGL ES. Until this gets investigated properly, add the Vivante GC2000 (found in the commonly used i.MX6 quad) to the list since reports show that the issue occurs there as well. Task-number: QTBUG-49490 Change-Id: Ia890346d8dbb1691bc113e2ef522713ba6709393 Reviewed-by: Louis Kröger Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/kernel/qopenglcontext.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 3dc06ae60ed..cd6f011fcb7 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -1008,6 +1008,7 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) || qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)' || qstrcmp(rendererString, "GC800 core") == 0 || qstrcmp(rendererString, "GC1000 core") == 0 + || strstr(rendererString, "GC2000") != 0 || qstrcmp(rendererString, "Immersion.16") == 0; } needsWorkaroundSet = true; From c3aa422df6e3eb4af7bd75c7255586e9e5f79197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Nov 2017 15:18:14 +0100 Subject: [PATCH 40/56] QWidget: Propagate window file path after create MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-63340 Change-Id: Ic21964a33ee2910200627fe8a8c8ec2454e2e20c Reviewed-by: Morten Johan Sørvig --- src/widgets/kernel/qwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 9b6c3df828d..de734b6f511 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1372,6 +1372,8 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) d->setWindowIconText_helper(d->topData()->iconText); if (isWindow() && !d->topData()->caption.isEmpty()) d->setWindowTitle_helper(d->topData()->caption); + if (isWindow() && !d->topData()->filePath.isEmpty()) + d->setWindowFilePath_helper(d->topData()->filePath); if (windowType() != Qt::Desktop) { d->updateSystemBackground(); From 31cc29e9be22a5c09cb90d004d967d524a02408f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 26 Oct 2017 09:32:13 +0200 Subject: [PATCH 41/56] Disable Xcode main thread checker by default Xcode 9 introduced the main thread checker, which detects invalid use of AppKit, UIKit, and other APIs from background threads. https://developer.apple.com/documentation/code_diagnostics/main_thread_checker In our case these are accesses to e.g. [UIView layer] and [UIScreen scaleFactor] from the render thread of QtQuick, things we should look at, but that might not be easily solvable. In any case, these are not warnings the user can do anything about, so in lack of a per-library disable of the checker, we have to globally disable it for the whole Xcode project. Task-number: QTBUG-63822 Change-Id: Ibfcdf23891cf6bfbbc9b9b3349e4c256c273c7de Reviewed-by: Eskil Abrahamsen Blomfeldt --- mkspecs/macx-xcode/default.xcscheme | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/macx-xcode/default.xcscheme b/mkspecs/macx-xcode/default.xcscheme index 6beb0d82804..bda2b8c1c08 100644 --- a/mkspecs/macx-xcode/default.xcscheme +++ b/mkspecs/macx-xcode/default.xcscheme @@ -62,6 +62,7 @@ useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" ignoresPersistentStateOnLaunch = "NO" + disableMainThreadChecker = "YES" debugDocumentVersioning = "NO" allowLocationSimulation = "YES"> From b02bd4bbad9f80154307d06ad95a6f96c30858f0 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 15 Aug 2017 11:19:32 +0700 Subject: [PATCH 42/56] QMenuPrivate: Rearrange member variables This saves 32 bytes per instance on 64-bit macOS, from 888 down to 856 bytes. Change-Id: I2592631aa3566d2eab72bad338aacfe76bee8ef3 Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qmenu_p.h | 131 ++++++++++++++++++++-------------- 1 file changed, 77 insertions(+), 54 deletions(-) diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 4b7ce051694..8adfc82ef57 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -92,18 +92,18 @@ class QMenuSloppyState public: QMenuSloppyState() : m_menu(Q_NULLPTR) - , m_enabled(false) - , m_uni_directional(false) - , m_select_other_actions(false) - , m_first_mouse(true) - , m_init_guard(false) - , m_use_reset_action(true) - , m_uni_dir_discarded_count(0) - , m_uni_dir_fail_at_count(0) - , m_timeout(0) , m_reset_action(Q_NULLPTR) , m_origin_action(Q_NULLPTR) , m_parent(Q_NULLPTR) + , m_uni_dir_discarded_count(0) + , m_uni_dir_fail_at_count(0) + , m_timeout(0) + , m_init_guard(false) + , m_first_mouse(true) + , m_enabled(false) + , m_uni_directional(false) + , m_select_other_actions(false) + , m_use_reset_action(true) { } ~QMenuSloppyState() { reset(); } @@ -253,43 +253,59 @@ public: private: QMenu *m_menu; - bool m_enabled; - bool m_uni_directional; - bool m_select_other_actions; - bool m_first_mouse; - bool m_init_guard; - bool m_discard_state_when_entering_parent; - bool m_dont_start_time_on_leave; - bool m_use_reset_action; - short m_uni_dir_discarded_count; - short m_uni_dir_fail_at_count; - short m_timeout; - QBasicTimer m_time; QAction *m_reset_action; QAction *m_origin_action; QRectF m_action_rect; QPointF m_previous_point; QPointer m_sub_menu; QMenuSloppyState *m_parent; + QBasicTimer m_time; + short m_uni_dir_discarded_count; + short m_uni_dir_fail_at_count; + short m_timeout; + bool m_init_guard; + bool m_first_mouse; + + bool m_enabled : 1; + bool m_uni_directional : 1; + bool m_select_other_actions : 1; + bool m_discard_state_when_entering_parent : 1; + bool m_dont_start_time_on_leave : 1; + bool m_use_reset_action : 1; }; class QMenuPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QMenu) public: - QMenuPrivate() : itemsDirty(0), maxIconWidth(0), tabWidth(0), ncols(0), - collapsibleSeparators(true), toolTipsVisible(false), - activationRecursionGuard(false), delayedPopupGuard(false), - hasReceievedEnter(false), - hasHadMouse(0), aboutToHide(0), motions(0), - currentAction(0), + QMenuPrivate() : + currentAction(nullptr), #ifdef QT_KEYPAD_NAVIGATION - selectAction(0), - cancelAction(0), + selectAction(nullptr), + cancelAction(nullptr), #endif - scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0), - hasCheckableItems(0), doChildEffects(false), platformMenu(0), - scrollUpTearOffItem(nullptr), scrollDownItem(nullptr) + scroll(nullptr), + eventLoop(nullptr), + platformMenu(nullptr), + scrollUpTearOffItem(nullptr), + scrollDownItem(nullptr), + maxIconWidth(0), + tabWidth(0), + motions(0), + activationRecursionGuard(false), + ncols(0), + itemsDirty(false), + hasCheckableItems(false), + collapsibleSeparators(true), + toolTipsVisible(false), + delayedPopupGuard(false), + hasReceievedEnter(false), + hasHadMouse(false), + aboutToHide(false), + tearoff(false), + tornoff(false), + tearoffHighlighted(false), + doChildEffects(false) { } ~QMenuPrivate() @@ -310,8 +326,6 @@ public: int scrollerHeight() const; //item calculations - mutable uint itemsDirty : 1; - mutable uint maxIconWidth, tabWidth; QRect actionRect(QAction *) const; mutable QVector actionRects; @@ -320,22 +334,12 @@ public: void updateActionRects(const QRect &screen) const; QRect popupGeometry() const; QRect popupGeometry(int screen) const; - mutable uint ncols : 4; //4 bits is probably plenty - uint collapsibleSeparators : 1; - uint toolTipsVisible : 1; int getLastVisibleAction() const; - bool activationRecursionGuard; - bool delayedPopupGuard; - bool hasReceievedEnter; - //selection static QMenu *mouseDown; QPoint mousePopupPos; - uint hasHadMouse : 1; - uint aboutToHide : 1; - int motions; - int mousePopupDelay; + QAction *currentAction; #ifdef QT_KEYPAD_NAVIGATION QAction *selectAction; @@ -365,8 +369,8 @@ public: } QMenu *parent; - QBasicTimer timer; QAction *action; + QBasicTimer timer; } delayState; enum SelectionReason { SelectedFromKeyboard, @@ -383,11 +387,12 @@ public: struct QMenuScroller { enum ScrollLocation { ScrollStay, ScrollBottom, ScrollTop, ScrollCenter }; enum ScrollDirection { ScrollNone=0, ScrollUp=0x01, ScrollDown=0x02 }; - uint scrollFlags : 2, scrollDirection : 2; int scrollOffset; QBasicTimer scrollTimer; + quint8 scrollFlags; + quint8 scrollDirection; - QMenuScroller() : scrollFlags(ScrollNone), scrollDirection(ScrollNone), scrollOffset(0) { } + QMenuScroller() : scrollOffset(0), scrollFlags(ScrollNone), scrollDirection(ScrollNone) { } ~QMenuScroller() { } } *scroll; void scrollMenu(QMenuScroller::ScrollLocation location, bool active=false); @@ -421,11 +426,8 @@ public: inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); } //tear off support - uint tearoff : 1, tornoff : 1, tearoffHighlighted : 1; QPointer tornPopup; - mutable bool hasCheckableItems; - QMenuSloppyState sloppyState; //default action @@ -450,9 +452,6 @@ public: void adjustMenuScreen(const QPoint &p); void updateLayoutDirection(); - //menu fading/scrolling effects - bool doChildEffects; - QPointer platformMenu; QPointer actionAboutToTrigger; @@ -477,6 +476,30 @@ public: void drawScroller(QPainter *painter, ScrollerTearOffItem::Type type, const QRect &rect); void drawTearOff(QPainter *painter, const QRect &rect); QRect rect() const; + + mutable uint maxIconWidth, tabWidth; + int motions; + int mousePopupDelay; + + bool activationRecursionGuard; + + mutable quint8 ncols; // "255cols ought to be enough for anybody." + + mutable bool itemsDirty : 1; + mutable bool hasCheckableItems : 1; + bool collapsibleSeparators : 1; + bool toolTipsVisible : 1; + bool delayedPopupGuard : 1; + bool hasReceievedEnter : 1; + // Selection + bool hasHadMouse : 1; + bool aboutToHide : 1; + // Tear-off menus + bool tearoff : 1; + bool tornoff : 1; + bool tearoffHighlighted : 1; + //menu fading/scrolling effects + bool doChildEffects : 1; }; QT_END_NAMESPACE From 237b1c1d689fabf1680a8cf3d9226da5f712302d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Sat, 26 Aug 2017 11:26:45 +0700 Subject: [PATCH 43/56] QMenuPrivate: Use in-class initializers where possible Change-Id: I5347cb41443baf96e28bd399c84983a801b10fcd Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qmenu_p.h | 87 +++++++++++++---------------------- 1 file changed, 31 insertions(+), 56 deletions(-) diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 8adfc82ef57..64d22087e3f 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -91,16 +91,7 @@ class QMenuSloppyState Q_DISABLE_COPY(QMenuSloppyState) public: QMenuSloppyState() - : m_menu(Q_NULLPTR) - , m_reset_action(Q_NULLPTR) - , m_origin_action(Q_NULLPTR) - , m_parent(Q_NULLPTR) - , m_uni_dir_discarded_count(0) - , m_uni_dir_fail_at_count(0) - , m_timeout(0) - , m_init_guard(false) - , m_first_mouse(true) - , m_enabled(false) + : m_enabled(false) , m_uni_directional(false) , m_select_other_actions(false) , m_use_reset_action(true) @@ -252,19 +243,19 @@ public: QMenu *subMenu() const { return m_sub_menu; } private: - QMenu *m_menu; - QAction *m_reset_action; - QAction *m_origin_action; + QMenu *m_menu = nullptr; + QAction *m_reset_action = nullptr; + QAction *m_origin_action = nullptr; QRectF m_action_rect; QPointF m_previous_point; QPointer m_sub_menu; - QMenuSloppyState *m_parent; + QMenuSloppyState *m_parent = nullptr; QBasicTimer m_time; - short m_uni_dir_discarded_count; - short m_uni_dir_fail_at_count; - short m_timeout; - bool m_init_guard; - bool m_first_mouse; + short m_uni_dir_discarded_count = 0; + short m_uni_dir_fail_at_count = 0; + short m_timeout = 0; + bool m_init_guard = false; + bool m_first_mouse = true; bool m_enabled : 1; bool m_uni_directional : 1; @@ -279,21 +270,6 @@ class QMenuPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QMenu) public: QMenuPrivate() : - currentAction(nullptr), -#ifdef QT_KEYPAD_NAVIGATION - selectAction(nullptr), - cancelAction(nullptr), -#endif - scroll(nullptr), - eventLoop(nullptr), - platformMenu(nullptr), - scrollUpTearOffItem(nullptr), - scrollDownItem(nullptr), - maxIconWidth(0), - tabWidth(0), - motions(0), - activationRecursionGuard(false), - ncols(0), itemsDirty(false), hasCheckableItems(false), collapsibleSeparators(true), @@ -340,15 +316,13 @@ public: static QMenu *mouseDown; QPoint mousePopupPos; - QAction *currentAction; + QAction *currentAction = nullptr; #ifdef QT_KEYPAD_NAVIGATION - QAction *selectAction; - QAction *cancelAction; + QAction *selectAction = nullptr; + QAction *cancelAction = nullptr; #endif struct DelayState { DelayState() - : parent(0) - , action(0) { } void initialize(QMenu *parent) { @@ -368,8 +342,8 @@ public: timer.stop(); } - QMenu *parent; - QAction *action; + QMenu *parent = nullptr; + QAction *action = nullptr; QBasicTimer timer; } delayState; enum SelectionReason { @@ -387,20 +361,20 @@ public: struct QMenuScroller { enum ScrollLocation { ScrollStay, ScrollBottom, ScrollTop, ScrollCenter }; enum ScrollDirection { ScrollNone=0, ScrollUp=0x01, ScrollDown=0x02 }; - int scrollOffset; + int scrollOffset = 0; QBasicTimer scrollTimer; - quint8 scrollFlags; - quint8 scrollDirection; + quint8 scrollFlags = ScrollNone; + quint8 scrollDirection = ScrollNone; - QMenuScroller() : scrollOffset(0), scrollFlags(ScrollNone), scrollDirection(ScrollNone) { } + QMenuScroller() { } ~QMenuScroller() { } - } *scroll; + } *scroll = nullptr; void scrollMenu(QMenuScroller::ScrollLocation location, bool active=false); void scrollMenu(QMenuScroller::ScrollDirection direction, bool page=false, bool active=false); void scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active=false); //synchronous operation (ie exec()) - QEventLoop *eventLoop; + QEventLoop *eventLoop = nullptr; QPointer syncAction; //search buffer @@ -433,8 +407,8 @@ public: //default action QPointer defaultAction; - QAction *menuAction; - QAction *defaultMenuAction; + QAction *menuAction = nullptr; + QAction *defaultMenuAction = nullptr; void setOverrideMenuAction(QAction *); void _q_overrideMenuActionDestroyed(); @@ -470,20 +444,21 @@ public: QMenuPrivate *menuPrivate; Type scrollType; }; - ScrollerTearOffItem *scrollUpTearOffItem; - ScrollerTearOffItem *scrollDownItem; + ScrollerTearOffItem *scrollUpTearOffItem = nullptr; + ScrollerTearOffItem *scrollDownItem = nullptr; void drawScroller(QPainter *painter, ScrollerTearOffItem::Type type, const QRect &rect); void drawTearOff(QPainter *painter, const QRect &rect); QRect rect() const; - mutable uint maxIconWidth, tabWidth; - int motions; - int mousePopupDelay; + mutable uint maxIconWidth = 0; + mutable uint tabWidth = 0; + int motions = 0; + int mousePopupDelay = 0; - bool activationRecursionGuard; + bool activationRecursionGuard = false; - mutable quint8 ncols; // "255cols ought to be enough for anybody." + mutable quint8 ncols = 0; // "255cols ought to be enough for anybody." mutable bool itemsDirty : 1; mutable bool hasCheckableItems : 1; From 7986e1e2f0c88ea305dd8a842884908ed4724fd7 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 20 Oct 2017 18:12:17 +0700 Subject: [PATCH 44/56] QMenuBar: Update title on change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When one of the menubar actions changed, we would omit to update several properties on the platform menu, most notably its title. Manual tested with BigMenuCreator, where the sequence menu->addAction(action); // A-operation action->setMenu(submenu); // S-operation would result in an "Untitled" menubar item on macOS, and this regardless of when the submenu is populated. Change-Id: I43989f36f6bf3f0b7056310ac986c06f8e02f128 Reviewed-by: Dmitry Shachnev Reviewed-by: Erik Verbruggen Reviewed-by: Morten Johan Sørvig --- src/widgets/widgets/qmenubar.cpp | 52 ++++++++++++++++++-------------- src/widgets/widgets/qmenubar_p.h | 4 ++- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 41b6bf49f8e..6dfbb7c8a1e 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1187,7 +1187,7 @@ void QMenuBar::leaveEvent(QEvent *) d->setCurrentAction(0); } -QPlatformMenu *QMenuBarPrivate::getPlatformMenu(QAction *action) +QPlatformMenu *QMenuBarPrivate::getPlatformMenu(const QAction *action) { if (!action || !action->menu()) return 0; @@ -1202,6 +1202,29 @@ QPlatformMenu *QMenuBarPrivate::getPlatformMenu(QAction *action) return platformMenu; } +QPlatformMenu *QMenuBarPrivate::findInsertionPlatformMenu(const QAction *action) +{ + Q_Q(QMenuBar); + QPlatformMenu *beforeMenu = nullptr; + for (int beforeIndex = indexOf(const_cast(action)) + 1; + !beforeMenu && (beforeIndex < q->actions().size()); + ++beforeIndex) { + beforeMenu = getPlatformMenu(q->actions().at(beforeIndex)); + } + + return beforeMenu; +} + +void QMenuBarPrivate::copyActionToPlatformMenu(const QAction *action, QPlatformMenu *menu) +{ + const auto tag = reinterpret_cast(action); + if (menu->tag() != tag) + menu->setTag(tag); + menu->setText(action->text()); + menu->setVisible(action->isVisible()); + menu->setEnabled(action->isEnabled()); +} + /*! \reimp */ @@ -1218,16 +1241,9 @@ void QMenuBar::actionEvent(QActionEvent *e) if (e->type() == QEvent::ActionAdded) { QPlatformMenu *menu = d->getPlatformMenu(e->action()); if (menu) { - QPlatformMenu* beforeMenu = NULL; - for (int beforeIndex = d->indexOf(e->action()) + 1; - !beforeMenu && (beforeIndex < actions().size()); - ++beforeIndex) - { - beforeMenu = d->getPlatformMenu(actions().at(beforeIndex)); - } + d->copyActionToPlatformMenu(e->action(), menu); - menu->setTag(reinterpret_cast(e->action())); - menu->setText(e->action()->text()); + QPlatformMenu *beforeMenu = d->findInsertionPlatformMenu(e->action()); d->platformMenuBar->insertMenu(menu, beforeMenu); } } else if (e->type() == QEvent::ActionRemoved) { @@ -1235,7 +1251,7 @@ void QMenuBar::actionEvent(QActionEvent *e) if (menu) d->platformMenuBar->removeMenu(menu); } else if (e->type() == QEvent::ActionChanged) { - QPlatformMenu* cur = d->platformMenuBar->menuForTag(reinterpret_cast(e->action())); + QPlatformMenu *cur = d->platformMenuBar->menuForTag(reinterpret_cast(e->action())); QPlatformMenu *menu = d->getPlatformMenu(e->action()); // the menu associated with the action can change, need to @@ -1244,21 +1260,13 @@ void QMenuBar::actionEvent(QActionEvent *e) if (cur) d->platformMenuBar->removeMenu(cur); if (menu) { - menu->setTag(reinterpret_cast(e->action())); + d->copyActionToPlatformMenu(e->action(), menu); - QPlatformMenu* beforeMenu = NULL; - for (int beforeIndex = d->indexOf(e->action()) + 1; - !beforeMenu && (beforeIndex < actions().size()); - ++beforeIndex) - { - beforeMenu = d->getPlatformMenu(actions().at(beforeIndex)); - } + QPlatformMenu *beforeMenu = d->findInsertionPlatformMenu(e->action()); d->platformMenuBar->insertMenu(menu, beforeMenu); } } else if (menu) { - menu->setText(e->action()->text()); - menu->setVisible(e->action()->isVisible()); - menu->setEnabled(e->action()->isEnabled()); + d->copyActionToPlatformMenu(e->action(), menu); d->platformMenuBar->syncMenu(menu); } } diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h index 01d8793a3a8..c276a4512d8 100644 --- a/src/widgets/widgets/qmenubar_p.h +++ b/src/widgets/widgets/qmenubar_p.h @@ -132,7 +132,9 @@ public: QBasicTimer autoReleaseTimer; QPlatformMenuBar *platformMenuBar; - QPlatformMenu *getPlatformMenu(QAction *action); + QPlatformMenu *getPlatformMenu(const QAction *action); + QPlatformMenu *findInsertionPlatformMenu(const QAction *action); + void copyActionToPlatformMenu(const QAction *e, QPlatformMenu *menu); inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); } }; From 5d6878f234d1d8697bba43cb5140094dee722a86 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Oct 2017 14:53:31 +0700 Subject: [PATCH 45/56] QMainWindow: Clear menubar parent when new one is set In QMainWindow::setMenuBar(), we hide and schedule the current menubar, if any, to be deleted later. However, it remains installed as its whole ancestry's event filter, which could conflict with the newly assigned menubar until the old menubar is destroyed. In our case, we have noticed issues with the Cocoa QPA plugin. We force uninstalling the old menubar as event filter by setting its parent to null, pending its deletion shortly after. This fixes BigMenuCreator's empty menubar when calling it with only the "--new-menubar" option. It also fixes QTBUG-34160 example which was not behaving as well as it should. Task-number: QTBUG-34160 Change-Id: Ifefb72affad01e7b7371005442074afd6a39a5b8 Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qmainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 5c6f9831492..ced7ec38ea3 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -574,6 +574,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) menuBar->setCornerWidget(cornerWidget, Qt::TopRightCorner); } oldMenuBar->hide(); + oldMenuBar->setParent(nullptr); oldMenuBar->deleteLater(); } topLayout->setMenuBar(menuBar); From 3f519ffa150ce5a2d9e3ad3f147745b312d29afb Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 25 Oct 2017 09:32:48 +0700 Subject: [PATCH 46/56] QCocoaMenuItem: Don't clear NSMenuItem.action when setting submenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contrarily to what the comment stated, we actually rely on automatic menu validation, even for submenu items. This is visible in the menu delegate's validateMenuItem: and itemFired: methods. This solves the last visible issue in BigMenuCreator where, under ASP/ASP, ASP/SAP, SAP/ASP and SAP/SAP, all A*S submenus would be disabled. The cause was an incorrect target/action setup. Menurama still behaves as expected. Change-Id: I2599d6fb0d51f56f5d36f03b69647e35ff6c550a Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index ecbab38a835..394e0fb8e46 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -150,10 +150,6 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu) QMacAutoReleasePool pool; m_menu = static_cast(menu); if (m_menu) { - if (m_native) { - // Skip automatic menu item validation - m_native.action = nil; - } m_menu->setMenuParent(this); m_menu->propagateEnabledState(isEnabled()); } else { From 159b3306d66d91274feb9fd28fdc176cecf47755 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Wed, 27 Sep 2017 10:11:50 +0200 Subject: [PATCH 47/56] Change fallthrough detection order to fix clang detection Clang compiler defines fallthrough, but wrongly detects QT_HAS_CPP_ATTRIBUTE(fallthrough). This makes compiler breaks compilation due clang be expecting clang::fallthrough. Change the order makes the exceptions. clang/gnu, been tested before the generic, setting then proper defines at end. LLVM-bug: https://bugs.llvm.org/show_bug.cgi?id=33518 Change-Id: Ic287e9028936af3bdade5c1ee319ca8914b36ea7 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 2c58ff87e9e..231ac2c9b09 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1347,12 +1347,12 @@ } while (false) #if defined(__cplusplus) -#if QT_HAS_CPP_ATTRIBUTE(fallthrough) -# define Q_FALLTHROUGH() [[fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) +#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) # define Q_FALLTHROUGH() [[clang::fallthrough]] #elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) # define Q_FALLTHROUGH() [[gnu::fallthrough]] +#elif QT_HAS_CPP_ATTRIBUTE(fallthrough) +# define Q_FALLTHROUGH() [[fallthrough]] #endif #endif #ifndef Q_FALLTHROUGH From fad8f340333f1c9ec7b6cebe521d53f4b1da4f8d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 7 Nov 2017 09:47:56 +0100 Subject: [PATCH 48/56] Extend blacklisting in qnetworkreply - Blacklist ioHttpRedirectPostPut for Windows - Amend 84396a3f938453b81e6ecc73bd54ff6b08960e8f: Keys need to be on subsequent lines Task-number: QTBUG-62583 Change-Id: I6360ec7bd87de65a3294a0d22148f13579fcd292 Reviewed-by: Timur Pocheptsov --- tests/auto/network/access/qnetworkreply/BLACKLIST | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index 9ae424943d5..acea0a5aad3 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -25,9 +25,11 @@ windows [ioHttpRedirectMultipartPost] linux [ioHttpRedirectPolicy] -b2qt linux 64bit +b2qt 64bit +linux [ioHttpRedirectPostPut] linux +windows [putWithServerClosingConnectionImmediately] windows [qtbug28035browserDoesNotLoadQtProjectOrgCorrectly] From 39355daa40438eef386ce55f02e7ba9ff824993f Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 7 Nov 2017 11:51:57 +0100 Subject: [PATCH 49/56] tst_QNetworkReply::getFromUnreachableIp - fix a failing test This patch works around Windows X86 on QEMU antics. It appears on this platform the test behaves in some unpredictable manner: - WSAConnect with 255.255.255.255 does not always immediately fail with some error, so socket engine waits for a connection timeout (30 s.), but the test itself - only waits for 5 seconds and then tests that a request has finished with error, which is not true (we are still connecting). To make it work - whenever we have bearermanager feature enabled, set a connection timeout to something reasonable, not 30 s. Since we try to connect to each address twice, make timeout 1.5 s (so it's 3 s. in total and still is < 5 s.). Task-number: QTBUG-64264 Change-Id: I1d40c140667fca8402ec9344e66d313b6df54256 Reviewed-by: Timur Pocheptsov --- .../qnetworkreply/tst_qnetworkreply.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 099ea8ff39c..b86750a9009 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -6766,6 +6766,48 @@ void tst_QNetworkReply::getFromUnreachableIp() { QNetworkAccessManager manager; +#ifdef Q_OS_WIN32 + // This test assumes that attempt to connect to 255.255.255.255 fails more + // or less fast/immediately. This is not what we observe on Windows x86: + // WSAConnect on non-blocking socket returns SOCKET_ERROR, WSAGetLastError + // returns WSAEWOULDBLOCK (expected) and getsockopt most of the time returns + // NOERROR; so socket engine starts a timer (30 s.) and waits for a timeout/ + // error/success. Unfortunately, the test itself is waiting only for 5 s. + // So we have to adjust the connection timeout or skip the test completely + // if the 'bearermanagement' feature is not available. +#if QT_CONFIG(bearermanagement) + class ConfigurationGuard + { + public: + explicit ConfigurationGuard(QNetworkAccessManager *m) + : manager(m) + { + Q_ASSERT(m); + auto conf = manager->configuration(); + previousTimeout = conf.connectTimeout(); + conf.setConnectTimeout(1500); + manager->setConfiguration(conf); + } + ~ConfigurationGuard() + { + Q_ASSERT(manager); + auto conf = manager->configuration(); + conf.setConnectTimeout(previousTimeout); + manager->setConfiguration(conf); + } + private: + QNetworkAccessManager *manager = nullptr; + int previousTimeout = 0; + + Q_DISABLE_COPY(ConfigurationGuard) + }; + + const ConfigurationGuard restorer(&manager); +#else // bearermanagement + QSKIP("This test is non-deterministic on Windows x86"); +#endif // !bearermanagement +#endif // Q_OS_WIN32 + QNetworkRequest request(QUrl("http://255.255.255.255/42/23/narf/narf/narf")); QNetworkReplyPtr reply(manager.get(request)); From dfdd99fc123ee80e162f0c14b4687fa00a328215 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 25 Sep 2017 12:09:08 +0200 Subject: [PATCH 50/56] Doc: Be more specific on full stop in QVersionNumber So far we just write ... '.'. , which looks weird. Change-Id: Iac6fc781c80976994ea0a182b55958baa39a7e52 Reviewed-by: Leena Miettinen --- src/corelib/tools/qversionnumber.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp index 97e5da8b3c3..d2667ddea9d 100644 --- a/src/corelib/tools/qversionnumber.cpp +++ b/src/corelib/tools/qversionnumber.cpp @@ -388,7 +388,7 @@ QVersionNumber QVersionNumber::commonPrefix(const QVersionNumber &v1, /*! \fn QString QVersionNumber::toString() const - Returns a string with all of the segments delimited by a '.'. + Returns a string with all of the segments delimited by a period (\c{.}). \sa majorVersion(), minorVersion(), microVersion(), segments() */ @@ -411,7 +411,7 @@ QString QVersionNumber::toString() const int *suffixIndex) Constructs a QVersionNumber from a specially formatted \a string of - non-negative decimal numbers delimited by '.'. + non-negative decimal numbers delimited by a period (\c{.}). Once the numerical segments have been parsed, the remainder of the string is considered to be the suffix string. The start index of that string will be From 7d10936443750b8b0c90bf1c979ad6ab51eb92a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Sun, 5 Nov 2017 16:18:54 +0100 Subject: [PATCH 51/56] Fix QHighDpi::fromNativeLocalExposedRegion rounding errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ceiling width/height fails to take into account rects that do no have their top left position on an exact point boundary. Example: QRect(0,0 20x20) and QRect(1,1 20x20) with scale 2.0 would give the same result of QRect(0,0 10x10). The correct rects are QRect(0,0 10x10) and QRect(0,0 11x11), so that we are sure to repaint all pixels within the exposed region. Before 5138fada0b9c, rects were also rounded incorrectly. The old method would give the result of QRect(0,0 11x11) in both cases, causing the exposed region to be larger than a window. Amends 5138fada0b9ce3968b23ec11df5f0d4e67544c43 Task-number: QTBUG-63943 Change-Id: I9f3dddf649bdc506c23bce1b6704860d61481459 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qhighdpiscaling_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 0a060a2d2c4..83fc9452c5e 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -402,7 +402,8 @@ inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QW const QPointF topLeftP = rect.topLeft() / scaleFactor; const QSizeF sizeP = rect.size() / scaleFactor; pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())), - QSize(qCeil(sizeP.width()), qCeil(sizeP.height()))); + QPoint(qCeil(topLeftP.x() + sizeP.width() - 1.0), + qCeil(topLeftP.y() + sizeP.height() - 1.0))); } return pointRegion; } From 429d5f0c5edf776004a8a28c3a93f97e41f2ef85 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Mon, 23 Oct 2017 23:56:51 +0200 Subject: [PATCH 52/56] Set correct datatype for column 'more_data' in PostgreSQL Task-number: QTBUG-63861 Change-Id: Ice9e788841046482bf5c4653eb859d00bc6b1c59 Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw --- tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp index 8f8cfe009d6..81206a58562 100644 --- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp @@ -77,6 +77,8 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db) doubleField = "more_data double"; else if (dbType == QSqlDriver::Oracle) doubleField = "more_data number(8,7)"; + else if (dbType == QSqlDriver::PostgreSQL) + doubleField = "more_data double precision"; else doubleField = "more_data double(8,7)"; QVERIFY_SQL( q, exec("create table " + relTEST1 + From e27bd981373cc3d22e54d8cbe030e5c329f9beda Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 8 Nov 2017 12:10:29 +0100 Subject: [PATCH 53/56] qfile tests: Make sure files are writable before deleting them On some platforms (like UWP) files that are copied during qfile auto tests are not writable by default. The cleanup will fail for these files if the permissions are not set accordingly. Change-Id: Id925dcadfc6b505c87f1f55d5ea05e286b60a5a5 Reviewed-by: Maurice Kalinowski Reviewed-by: Friedemann Kleint --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 5f3ebeadd76..8db89b9f058 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -405,6 +405,8 @@ void tst_QFile::cleanup() QDir remainingDir(absoluteFilePath); QVERIFY2(remainingDir.removeRecursively(), qPrintable(absoluteFilePath)); } else { + if (!(QFile::permissions(absoluteFilePath) & QFile::WriteUser)) + QVERIFY2(QFile::setPermissions(absoluteFilePath, QFile::WriteUser), qPrintable(absoluteFilePath)); QVERIFY2(QFile::remove(absoluteFilePath), qPrintable(absoluteFilePath)); } } From bbc68dc815122e6be9ea44adadd93ffb715c7792 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 8 Nov 2017 12:12:06 +0100 Subject: [PATCH 54/56] Fix tst_QFile::useQFileInAFileHandler for systems using resources for test data Resource files are extracted to m_dataDir in tst_QFile::initTestCase. Instead of trying to access the file from the resource on systems that use qrc for bundling the test data, we have to use the files that were extracted at the beginning of the test. Change-Id: I35453fbdeb27e317d1342ff1cb7bbea9cebea14d Reviewed-by: Maurice Kalinowski Reviewed-by: Friedemann Kleint --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 8db89b9f058..8a3d490925a 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2190,12 +2190,20 @@ public: if (fileName.startsWith(":!")) { QDir dir; - QString realFile = QFINDTESTDATA(fileName.mid(2)); +#ifndef BUILTIN_TESTDATA + const QString realFile = QFINDTESTDATA(fileName.mid(2)); +#else + const QString realFile = m_dataDir->filePath(fileName.mid(2)); +#endif if (dir.exists(realFile)) return new QFSFileEngine(realFile); } return 0; } + +#ifdef BUILTIN_TESTDATA + QSharedPointer m_dataDir; +#endif }; #endif @@ -2204,6 +2212,9 @@ void tst_QFile::useQFileInAFileHandler() { // This test should not dead-lock MyRecursiveHandler handler; +#ifdef BUILTIN_TESTDATA + handler.m_dataDir = m_dataDir; +#endif QFile file(":!tst_qfile.cpp"); QVERIFY(file.exists()); } From 82c3c9d45d5fad0ed18e096f09729579a0902a71 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 8 Nov 2017 13:58:19 +0100 Subject: [PATCH 55/56] Fix tst_QFile::handle for systems using builtin test data To obtain the file's handle, we need to obtain it from the extracted test data instead of qrc. Change-Id: I89c5c3f3a7da7e36205a439581a6d83efffdc07c Reviewed-by: Maurice Kalinowski Reviewed-by: Friedemann Kleint --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 8a3d490925a..16a3cfd7662 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -445,8 +445,6 @@ void tst_QFile::initTestCase() m_stdinProcessDir = QFINDTESTDATA("stdinprocess"); QVERIFY(!m_stdinProcessDir.isEmpty()); #endif - m_testSourceFile = QFINDTESTDATA("tst_qfile.cpp"); - QVERIFY(!m_testSourceFile.isEmpty()); m_testLogFile = QFINDTESTDATA("testlog.txt"); QVERIFY(!m_testLogFile.isEmpty()); m_dosFile = QFINDTESTDATA("dosfile.txt"); @@ -459,12 +457,15 @@ void tst_QFile::initTestCase() QVERIFY(!m_twoDotsFile.isEmpty()); #ifndef BUILTIN_TESTDATA + m_testSourceFile = QFINDTESTDATA("tst_qfile.cpp"); + QVERIFY(!m_testSourceFile.isEmpty()); m_testFile = QFINDTESTDATA("testfile.txt"); QVERIFY(!m_testFile.isEmpty()); #else m_dataDir = QEXTRACTTESTDATA("/"); QVERIFY2(!m_dataDir.isNull(), qPrintable("Could not extract test data")); m_testFile = m_dataDir->path() + "/testfile.txt"; + m_testSourceFile = m_dataDir->path() + "/tst_qfile.cpp"; #endif m_resourcesDir = QFINDTESTDATA("resources"); QVERIFY(!m_resourcesDir.isEmpty()); From 579d0cb2bed193ccb1901b121a360f85d1c57a54 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 8 Nov 2017 14:09:11 +0100 Subject: [PATCH 56/56] Fix tst_QFile::openDirectory for systems using builtin test data To obtain "proper" directory behavior, we have to check against the extracted "resources" directory instead of its qrc counterpart. Change-Id: I4996ba74419945f78d356ad953a5b826ff663687 Reviewed-by: Maurice Kalinowski --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 16a3cfd7662..5f0eae6fc35 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -461,14 +461,15 @@ void tst_QFile::initTestCase() QVERIFY(!m_testSourceFile.isEmpty()); m_testFile = QFINDTESTDATA("testfile.txt"); QVERIFY(!m_testFile.isEmpty()); + m_resourcesDir = QFINDTESTDATA("resources"); + QVERIFY(!m_resourcesDir.isEmpty()); #else m_dataDir = QEXTRACTTESTDATA("/"); QVERIFY2(!m_dataDir.isNull(), qPrintable("Could not extract test data")); m_testFile = m_dataDir->path() + "/testfile.txt"; m_testSourceFile = m_dataDir->path() + "/tst_qfile.cpp"; + m_resourcesDir = m_dataDir->path() + "/resources"; #endif - m_resourcesDir = QFINDTESTDATA("resources"); - QVERIFY(!m_resourcesDir.isEmpty()); m_noEndOfLineFile = QFINDTESTDATA("noendofline.txt"); QVERIFY(!m_noEndOfLineFile.isEmpty());