From 509bc7e59c69937900cf258e64889a6e88edbcf0 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 3 Mar 2015 09:39:22 +0100 Subject: Fix another crash when converting format of buffer-created QImage This continues 68762151dbf45fbb44e140ac2ad13dbe8d357352 When doing format conversion, the optimized inplace codepath did not check if the image data was external, i.e. if the QImage had been created by the constructor taking an existing external buffer. The previous commit fixed the readonly case. But in the case of the QImage constructor taking non-const uchar*, data will be read-write, but still external. This would of course crash if the converter tries to realloc it. Task-number: QTBUG-44610 Change-Id: I94d275d464e8af221682b538fc3e4897a59c061e Reviewed-by: Allan Sandfeld Jensen --- tests/auto/gui/image/qimage/tst_qimage.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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 e8da3263ae..309d3a80c5 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -2456,6 +2456,7 @@ void tst_QImage::inplaceConversion_data() QTest::addColumn("format"); QTest::addColumn("dest_format"); + QTest::newRow("Format_RGB32 -> RGB16") << QImage::Format_RGB32 << QImage::Format_RGB16; QTest::newRow("Format_ARGB32 -> Format_RGBA8888") << QImage::Format_ARGB32 << QImage::Format_RGBA8888; QTest::newRow("Format_RGB888 -> Format_ARGB6666_Premultiplied") << QImage::Format_RGB888 << QImage::Format_ARGB6666_Premultiplied; QTest::newRow("Format_RGB16 -> Format_RGB555") << QImage::Format_RGB16 << QImage::Format_RGB555; @@ -2494,16 +2495,21 @@ void tst_QImage::inplaceConversion() QCOMPARE(imageConverted.constScanLine(0), originalPtr); { - // Test attempted inplace conversion of images created on existing, readonly buffer + // Test attempted inplace conversion of images created on existing buffer static const quint32 readOnlyData[] = { 0x00010203U, 0x04050607U, 0x08091011U, 0x12131415U }; + quint32 readWriteData[] = { 0x00010203U, 0x04050607U, 0x08091011U, 0x12131415U }; QImage roImage((const uchar *)readOnlyData, 2, 2, format); - QImage inplaceConverted = std::move(roImage).convertToFormat(dest_format); + QImage roInplaceConverted = std::move(roImage).convertToFormat(dest_format); + + QImage rwImage((uchar *)readWriteData, 2, 2, format); + QImage rwInplaceConverted = std::move(rwImage).convertToFormat(dest_format); QImage roImage2((const uchar *)readOnlyData, 2, 2, format); QImage normalConverted = roImage2.convertToFormat(dest_format); - QCOMPARE(normalConverted, inplaceConverted); + QCOMPARE(normalConverted, roInplaceConverted); + QCOMPARE(normalConverted, rwInplaceConverted); } #endif } -- cgit v1.2.3 From 208cd9ebf16afd2b7a5b08d62ac2647b99a3f612 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 2 Mar 2015 13:11:26 -0800 Subject: tst_QDnsLookup: Update to match the new zone for test.qt-project.org This commit updates the NS records and disables the lookup for ptr-single.test.qt-project.org, as the new provider does not support adding PTR records outside of the in-addr.arpa zone. This commit reverts f9c70128bbb45ea4b206920dda7c330afa74916a, which was a reversal of 24c52bd44b700725d4feec0d2e05a7e382e59c4e. Change-Id: Ia0aac2f09e9245339951ffff13c7cab530a41515 Reviewed-by: Lars Knoll --- tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index fd1e8a1267..481d7d7cfe 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -67,8 +67,8 @@ private slots: void tst_QDnsLookup::initTestCase() { QTest::addColumn("tld"); - QTest::newRow("normal") << ".test.macieira.org"; - QTest::newRow("idn") << ".alqualond\xc3\xab.test.macieira.org"; + QTest::newRow("normal") << ".test.qt-project.org"; + QTest::newRow("idn") << ".alqualond\xc3\xab.test.qt-project.org"; } QString tst_QDnsLookup::domainName(const QString &input) @@ -145,12 +145,16 @@ void tst_QDnsLookup::lookup_data() QTest::newRow("ns-empty") << int(QDnsLookup::NS) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; QTest::newRow("ns-notfound") << int(QDnsLookup::NS) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; - QTest::newRow("ns-single") << int(QDnsLookup::NS) << "ns-single" << int(QDnsLookup::NoError) << "" << "" << "" << "ns3.macieira.info." << "" << "" << ""; - QTest::newRow("ns-multi") << int(QDnsLookup::NS) << "ns-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "gondolin.macieira.info.;ns3.macieira.info." << "" << "" << ""; + QTest::newRow("ns-single") << int(QDnsLookup::NS) << "ns-single" << int(QDnsLookup::NoError) << "" << "" << "" << "ns11.cloudns.net." << "" << "" << ""; + QTest::newRow("ns-multi") << int(QDnsLookup::NS) << "ns-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "ns11.cloudns.net.;ns12.cloudns.net." << "" << "" << ""; QTest::newRow("ptr-empty") << int(QDnsLookup::PTR) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; QTest::newRow("ptr-notfound") << int(QDnsLookup::PTR) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; +#if 0 + // temporarily disabled since the new hosting provider can't insert + // PTR records outside of the in-addr.arpa zone QTest::newRow("ptr-single") << int(QDnsLookup::PTR) << "ptr-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "a-single" << "" << ""; +#endif QTest::newRow("srv-empty") << int(QDnsLookup::SRV) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; QTest::newRow("srv-notfound") << int(QDnsLookup::SRV) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; -- cgit v1.2.3 From ed0c0070f9b05c647019270dfc42073d071c830a Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Mon, 8 Dec 2014 15:29:19 +0100 Subject: Introduce qt_subtract_from_timeout to reduce code duplication. The same qt_timeout_value function was copied 5 times in qtbase's code, so provide a common implementation in QIoDevice that can be used by everyone. This commit also corrects the remaining time calculation in QProcess::waitForBytesWritten and QProcess::waitForFinished by using this new function. For QProcess::waitForFinished, if the process started within almost exactly the timeout time passed to waitForFinished, msecs - stopWatch.elapsed() would be -1, which is a special value. Change-Id: I7b76ee6bae695eafdd02e3db03e2ff1e23a7f40c Reviewed-by: Oswald Buddenhagen --- tests/auto/other/networkselftest/networkselftest.pro | 2 +- tests/auto/other/networkselftest/tst_networkselftest.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/networkselftest/networkselftest.pro b/tests/auto/other/networkselftest/networkselftest.pro index c8b870128d..22208e02fb 100644 --- a/tests/auto/other/networkselftest/networkselftest.pro +++ b/tests/auto/other/networkselftest/networkselftest.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_networkselftest SOURCES += tst_networkselftest.cpp -QT = core network testlib +QT = core core-private network testlib win32:CONFIG += insignificant_test # QTBUG-27571 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 36c9027aca..5472b74c07 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #ifndef QT_NO_BEARERMANAGEMENT #include @@ -171,10 +172,11 @@ static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout forever { if (socket->bytesAvailable() >= minBytesAvailable) return true; + timeout = qt_subtract_from_timeout(timeout, timer.elapsed()); if (socket->state() == QAbstractSocket::UnconnectedState - || timer.elapsed() >= timeout) + || timeout == 0) return false; - if (!socket->waitForReadyRead(timeout - timer.elapsed())) + if (!socket->waitForReadyRead(timeout)) return false; } } @@ -202,10 +204,11 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) #endif ) return true; + timeout = qt_subtract_from_timeout(timeout, timer.elapsed()); if (socket->state() == QAbstractSocket::UnconnectedState - || timer.elapsed() >= timeout) + || timeout == 0) return false; - if (!socket->waitForBytesWritten(timeout - timer.elapsed())) + if (!socket->waitForBytesWritten(timeout)) return false; } } -- cgit v1.2.3 From 416438c2f35dc774e4c52a705c5a7098a69647fc Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 9 Mar 2015 17:04:20 +0100 Subject: QMimeDatabase: Fix magic rules with \t \t was not interpreted as a tab character. Task-number: QTBUG-44884 Change-Id: I3c733e227fba7e5fd5153df0ae4d0431903bb104 Reviewed-by: Daniel Teske Reviewed-by: David Faure --- tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 1513a75148..b449a78200 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -460,6 +460,7 @@ void tst_QMimeDatabase::mimeTypeForData_data() QTest::newRow("tnef data, needs smi >= 0.20") << QByteArray("\x78\x9f\x3e\x22") << "application/vnd.ms-tnef"; QTest::newRow("PDF magic") << QByteArray("%PDF-") << "application/pdf"; QTest::newRow("PHP, High-priority rule") << QByteArray(" Date: Mon, 29 Dec 2014 10:35:09 +0100 Subject: QComboBox: Update completer on setCurrentIndex() When the ComboBox currentText() was changed by key LineUp or LineDown or mouse click, the completer still contained the last inserted characters. If now all text was selected (by Ctrl+A or selectAll()), the old item and index was restored on next Enter press. Task-number: QTBUG-41288 Change-Id: I6916fd31c8b8fbacfb12e1a62c3e46823cf918b4 Reviewed-by: Timur Pocheptsov --- .../widgets/widgets/qcombobox/tst_qcombobox.cpp | 39 ++++++++++++++++++++++ 1 file changed, 39 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 23d0ffd2d2..4e0808a7b3 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -158,6 +158,7 @@ private slots: void highlightedSignal(); void itemData(); void task_QTBUG_31146_popupCompletion(); + void task_QTBUG_41288_completerChangesCurrentIndex(); void keyboardSelection(); void setCustomModelAndView(); void updateDelegateOnEditableChange(); @@ -3026,6 +3027,44 @@ void tst_QComboBox::task_QTBUG_31146_popupCompletion() QCOMPARE(comboBox.currentIndex(), 0); } +void tst_QComboBox::task_QTBUG_41288_completerChangesCurrentIndex() +{ + QComboBox comboBox; + comboBox.setEditable(true); + + comboBox.addItems(QStringList() << QStringLiteral("111") << QStringLiteral("222")); + + comboBox.show(); + comboBox.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&comboBox)); + + { + // change currentIndex() by keyboard + comboBox.lineEdit()->selectAll(); + QTest::keyClicks(comboBox.lineEdit(), "222"); + QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter); + QCOMPARE(comboBox.currentIndex(), 1); + + QTest::keyClick(&comboBox, Qt::Key_Up); + comboBox.lineEdit()->selectAll(); + QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter); + QCOMPARE(comboBox.currentIndex(), 0); + } + + { + // change currentIndex() programmatically + comboBox.lineEdit()->selectAll(); + QTest::keyClicks(comboBox.lineEdit(), "222"); + QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter); + QCOMPARE(comboBox.currentIndex(), 1); + + comboBox.setCurrentIndex(0); + comboBox.lineEdit()->selectAll(); + QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter); + QCOMPARE(comboBox.currentIndex(), 0); + } +} + void tst_QComboBox::keyboardSelection() { QComboBox comboBox; -- cgit v1.2.3 From d5c6335ff3f86616b49a8ca0cb6f4991ff5dfef9 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 19 Mar 2015 08:46:56 +0100 Subject: Fix rasterization errors in aliased cosmetic drawPolyLine If a cosmetic polyline contained a 1-pixel segment, the next segment would be drawn with wrong starting point. The original fix for QTBUG-26156 had some unwanted side effects (QTBUG-31579 and now QTBUG-42398). It tried to skip start-point update if stroke() did not actually draw anything (because the segment was too small). However, to determine that, it tested for a change in lastPixel. But that was not failsafe; in some cases (1-pixel segment), lastPixel could be unchanged even though the segment had been drawn. With this change, we instead test directly whether stroke() skipped the segment or not. Task-number: QTBUG-42398 Change-Id: Id751db69a18cd1af4f45070db9d5698aa532d22a Reviewed-by: Allan Sandfeld Jensen --- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 8a0705630d..bf19a04203 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -290,6 +290,10 @@ private slots: void RasterOp_NotDestination(); void drawTextNoHinting(); + + void drawPolyline_data(); + void drawPolyline(); + private: void fillData(); void setPenColor(QPainter& p); @@ -4828,6 +4832,39 @@ void tst_QPainter::drawTextNoHinting() QVERIFY(true); } +void tst_QPainter::drawPolyline_data() +{ + QTest::addColumn< QVector >("points"); + + QTest::newRow("basic") << (QVector() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20) << QPointF(10, 20)); + QTest::newRow("clipped") << (QVector() << QPoint(-10, 100) << QPoint(-1, 100) << QPoint(-1, -2) << QPoint(100, -2) << QPoint(100, 40)); // QTBUG-31579 + QTest::newRow("shortsegment") << (QVector() << QPoint(20, 100) << QPoint(20, 99) << QPoint(21, 99) << QPoint(21, 104)); // QTBUG-42398 +} + +void tst_QPainter::drawPolyline() +{ + QFETCH(QVector, points); + QImage images[2]; + + for (int r = 0; r < 2; r++) { + images[r] = QImage(150, 150, QImage::Format_ARGB32); + images[r].fill(Qt::transparent); + QPainter p(images + r); + QPen pen(Qt::red, 0, Qt::SolidLine, Qt::FlatCap); + p.setPen(pen); + QVERIFY(p.pen().isCosmetic()); + if (r) { + for (int i = 0; i < points.count()-1; i++) { + p.drawLine(points.at(i), points.at(i+1)); + } + } else { + p.drawPolyline(points); + } + } + + QCOMPARE(images[0], images[1]); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" -- cgit v1.2.3