From d894cfa863a3fc9cd9a6dcb9f3c7b04e6ce41285 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Wed, 4 Nov 2015 11:35:09 +0200 Subject: Fix QImage::setDotsPerMeterX/Y for images with some orientations Rotation of images with orientation of 90 and 270 degrees dropped DPM values from rotated image. Task-number: QTBUG-49220 Change-Id: I9c23153c49dd63b5f6958fdde72f466873b0a407 Reviewed-by: Friedemann Kleint Reviewed-by: Liang Qi Reviewed-by: aavit --- tests/auto/gui/image/qimage/tst_qimage.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 8286c800c2..939226e2b0 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -2822,15 +2822,17 @@ void tst_QImage::exifOrientation_data() { QTest::addColumn("fileName"); QTest::addColumn("orientation"); - QTest::newRow("Orientation 1, Intel format") << m_prefix + "jpeg_exif_orientation_value_1.jpg" << (int)QImageIOHandler::TransformationNone; - QTest::newRow("Orientation 2, Intel format") << m_prefix + "jpeg_exif_orientation_value_2.jpg" << (int)QImageIOHandler::TransformationMirror; - QTest::newRow("Orientation 3, Intel format") << m_prefix + "jpeg_exif_orientation_value_3.jpg" << (int)QImageIOHandler::TransformationRotate180; - QTest::newRow("Orientation 4, Intel format") << m_prefix + "jpeg_exif_orientation_value_4.jpg" << (int)QImageIOHandler::TransformationFlip; - QTest::newRow("Orientation 5, Intel format") << m_prefix + "jpeg_exif_orientation_value_5.jpg" << (int)QImageIOHandler::TransformationFlipAndRotate90; - QTest::newRow("Orientation 6, Intel format") << m_prefix + "jpeg_exif_orientation_value_6.jpg" << (int)QImageIOHandler::TransformationRotate90; - QTest::newRow("Orientation 6, Motorola format") << m_prefix + "jpeg_exif_orientation_value_6_motorola.jpg" << (int)QImageIOHandler::TransformationRotate90; - QTest::newRow("Orientation 7, Intel format") << m_prefix + "jpeg_exif_orientation_value_7.jpg" << (int)QImageIOHandler::TransformationMirrorAndRotate90; - QTest::newRow("Orientation 8, Intel format") << m_prefix + "jpeg_exif_orientation_value_8.jpg" << (int)QImageIOHandler::TransformationRotate270; + QTest::addColumn("dpmx"); + QTest::addColumn("dpmy"); + QTest::newRow("Orientation 1, Intel format") << m_prefix + "jpeg_exif_orientation_value_1.jpg" << (int)QImageIOHandler::TransformationNone << 39 << 39; + QTest::newRow("Orientation 2, Intel format") << m_prefix + "jpeg_exif_orientation_value_2.jpg" << (int)QImageIOHandler::TransformationMirror << 39 << 39; + QTest::newRow("Orientation 3, Intel format") << m_prefix + "jpeg_exif_orientation_value_3.jpg" << (int)QImageIOHandler::TransformationRotate180 << 39 << 39; + QTest::newRow("Orientation 4, Intel format") << m_prefix + "jpeg_exif_orientation_value_4.jpg" << (int)QImageIOHandler::TransformationFlip << 39 << 39; + QTest::newRow("Orientation 5, Intel format") << m_prefix + "jpeg_exif_orientation_value_5.jpg" << (int)QImageIOHandler::TransformationFlipAndRotate90 << 39 << 39; + QTest::newRow("Orientation 6, Intel format") << m_prefix + "jpeg_exif_orientation_value_6.jpg" << (int)QImageIOHandler::TransformationRotate90 << 39 << 39; + QTest::newRow("Orientation 6, Motorola format") << m_prefix + "jpeg_exif_orientation_value_6_motorola.jpg" << (int)QImageIOHandler::TransformationRotate90 << 39 << 39; + QTest::newRow("Orientation 7, Intel format") << m_prefix + "jpeg_exif_orientation_value_7.jpg" << (int)QImageIOHandler::TransformationMirrorAndRotate90 << 39 << 39; + QTest::newRow("Orientation 8, Intel format") << m_prefix + "jpeg_exif_orientation_value_8.jpg" << (int)QImageIOHandler::TransformationRotate270 << 39 << 39; } QT_BEGIN_NAMESPACE @@ -2842,14 +2844,17 @@ void tst_QImage::exifOrientation() { QFETCH(QString, fileName); QFETCH(int, orientation); + QFETCH(int, dpmx); + QFETCH(int, dpmy); QImageReader imageReader(fileName); imageReader.setAutoTransform(true); QCOMPARE(imageReader.transformation(), orientation); QImage img = imageReader.read(); + QCOMPARE(img.dotsPerMeterX(), dpmx); + QCOMPARE(img.dotsPerMeterY(), dpmy); QRgb px; QVERIFY(!img.isNull()); - px = img.pixel(0, 0); QVERIFY(qRed(px) > 250 && qGreen(px) < 5 && qBlue(px) < 5); -- cgit v1.2.3 From 7aba75ffc52e5dce4b3ada12668611be2ad6787e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 25 Sep 2015 13:23:46 +0200 Subject: Don't let closed http sockets pass as valid connections A QAbstractSocket can be close()'d at any time, independently of its current connection state. being closed means that we cannot use it to read or write data, but internally it might still have some data to send or receive, for example to an http server. We can even get a connected() signal after close()'ing the socket. We need to catch this condition and mark any pending data not yet written to the socket for resending. (cherry picked from commit 0df5d079290b4c3b13e58e9397fabdc1dfdba96b) Task-number: QTBUG-48326 Change-Id: I67d9ad36f7288c9c6bef51aa6253d7b187737601 Reviewed-by: Ulf Hermann Reviewed-by: Markus Goetz (Woboq GmbH) --- .../tst_qhttpnetworkconnection.cpp | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 5d072af6d5..0d188a8fec 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -36,6 +36,7 @@ #include "private/qhttpnetworkconnection_p.h" #include "private/qnoncontiguousbytedevice_p.h" #include +#include #include "../../../network-settings.h" @@ -106,6 +107,8 @@ private Q_SLOTS: void getAndThenDeleteObject(); void getAndThenDeleteObject_data(); + + void overlappingCloseAndWrite(); }; tst_QHttpNetworkConnection::tst_QHttpNetworkConnection() @@ -1112,6 +1115,57 @@ void tst_QHttpNetworkConnection::getAndThenDeleteObject() } } +class TestTcpServer : public QTcpServer +{ + Q_OBJECT +public: + TestTcpServer() : errorCodeReports(0) + { + connect(this, &QTcpServer::newConnection, this, &TestTcpServer::onNewConnection); + QVERIFY(listen(QHostAddress::LocalHost)); + } + + int errorCodeReports; + +public slots: + void onNewConnection() + { + QTcpSocket *socket = nextPendingConnection(); + if (!socket) + return; + // close socket instantly! + connect(socket, &QTcpSocket::readyRead, socket, &QTcpSocket::close); + } + + void onReply(QNetworkReply::NetworkError code) + { + QCOMPARE(code, QNetworkReply::RemoteHostClosedError); + ++errorCodeReports; + } +}; + +void tst_QHttpNetworkConnection::overlappingCloseAndWrite() +{ + // server accepts connections, but closes the socket instantly + TestTcpServer server; + QNetworkAccessManager accessManager; + + // ten requests are scheduled. All should result in an RemoteHostClosed... + QUrl url; + url.setScheme(QStringLiteral("http")); + url.setHost(server.serverAddress().toString()); + url.setPort(server.serverPort()); + for (int i = 0; i < 10; ++i) { + QNetworkRequest request(url); + QNetworkReply *reply = accessManager.get(request); + // Not using Qt5 connection syntax here because of overly baroque syntax to discern between + // different error() methods. + QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), + &server, SLOT(onReply(QNetworkReply::NetworkError))); + } + + QTRY_COMPARE(server.errorCodeReports, 10); +} QTEST_MAIN(tst_QHttpNetworkConnection) -- cgit v1.2.3 From 9daef8a54c32162a50b0f558dac829333165618f Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Thu, 5 Nov 2015 22:35:42 +0100 Subject: QComboBox: Disable wheel events on OS X & iOS This is follow-up for QTabBar fix ea47d152b35158ba07a55d009f57df0e4c2a048f. In native OS X applications using mouse wheel on combo boxes have absolutely no effect. We should bring the same behavior to Qt based OS X apps too, as users are complaining of unexpected behavior, eg. randomly switching Qt Creator sidebar mode when scrolling file list and moving mouse pointer little bit above. Moreover inertial mouse behavior on OS X makes combo box usually move several indexes, rather than single one on slight finger slide. This also applies to iOS apps so the change affects all Apple platforms. Task-number: QTBUG-10707 Change-Id: I6582265039198707ad8c2f54de96ee2a0b0e0b47 Reviewed-by: Adam Strzelecki Reviewed-by: Jake Petroules --- tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 7824172812..21446de069 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2044,7 +2044,13 @@ void tst_QComboBox::mouseWheel_data() QTest::newRow("upper locked") << disabled << start << wheel << expected; wheel = -1; +#ifdef Q_OS_DARWIN + // on OS X & iOS mouse wheel shall have no effect on combo box + expected = start; +#else + // on other OSes we should jump to next enabled item (no. 5) expected = 5; +#endif QTest::newRow("jump over") << disabled << start << wheel << expected; disabled.clear(); -- cgit v1.2.3