From 9cf618492d1c89b489bf7e52e45c9577f9d52c1c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 6 Oct 2009 20:47:52 +0200 Subject: Autotest: use port 12346 instead of 1, to ensure that it's not a firewall issue Also check if we're not timing out instead of being able to fail. --- tests/auto/networkselftest/tst_networkselftest.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index c6a3119..e927a7a 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -335,10 +335,15 @@ void tst_NetworkSelfTest::dnsResolution() void tst_NetworkSelfTest::serverReachability() { - // check that we get a proper error connecting to port 1 + // check that we get a proper error connecting to port 12346 QTcpSocket socket; - socket.connectToHost(QtNetworkSettings::serverName(), 1); + socket.connectToHost(QtNetworkSettings::serverName(), 12346); + + QTime timer; + timer.start(); socket.waitForConnected(10000); + QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong"); + QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!"); QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError, QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit()); -- cgit v0.12 From d47b7e6d0adcd675ba9da11818b3fa9acc3caff5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 6 Oct 2009 20:51:18 +0200 Subject: Autotest: add a few more tests, with IP address and actual hostname --- tests/auto/networkselftest/tst_networkselftest.cpp | 78 ++++++++++++++++++++-- 1 file changed, 74 insertions(+), 4 deletions(-) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index e927a7a..5a82f28 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -46,6 +46,10 @@ class tst_NetworkSelfTest: public QObject { Q_OBJECT + QHostAddress cachedIpAddress; +public: + QHostAddress serverIpAddress(); + private slots: void hostTest(); void dnsResolution_data(); @@ -303,6 +307,16 @@ static void netChat(int port, const QList &chat) } } +QHostAddress tst_NetworkSelfTest::serverIpAddress() +{ + if (cachedIpAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) { + // need resolving + QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::serverName()); + cachedIpAddress = resolved.addresses().first(); + } + return cachedIpAddress; +} + void tst_NetworkSelfTest::hostTest() { // this is a localhost self-test @@ -331,6 +345,9 @@ void tst_NetworkSelfTest::dnsResolution() QHostInfo resolved = QHostInfo::fromName(hostName); QVERIFY2(resolved.error() == QHostInfo::NoError, QString("Failed to resolve hostname %1: %2").arg(hostName, resolved.errorString()).toLocal8Bit()); + QVERIFY2(resolved.addresses().size() > 0, "Got 0 addresses for server IP"); + + cachedIpAddress = resolved.addresses().first(); } void tst_NetworkSelfTest::serverReachability() @@ -469,7 +486,18 @@ void tst_NetworkSelfTest::httpsServer() void tst_NetworkSelfTest::httpProxy() { netChat(3128, QList() - // proxy GET + // proxy GET by IP + << Chat::send("GET http://" + serverIpAddress().toString().toLatin1() + "/ HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Proxy-connection: close\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("200 ") + << Chat::DiscardUntilDisconnect + + // proxy GET by hostname + << Chat::Reconnect << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n" "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" "Proxy-connection: close\r\n" @@ -479,7 +507,17 @@ void tst_NetworkSelfTest::httpProxy() << Chat::expect("200 ") << Chat::DiscardUntilDisconnect - // proxy CONNECT + // proxy CONNECT by IP + << Chat::Reconnect + << Chat::send("CONNECT " + serverIpAddress().toString().toLatin1() + ":21 HTTP/1.0\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("200 ") + << Chat::discardUntil("\r\n\r\n") + << ftpChat() + + // proxy CONNECT by hostname << Chat::Reconnect << Chat::send("CONNECT " + QtNetworkSettings::serverName().toLatin1() + ":21 HTTP/1.0\r\n" "\r\n") @@ -487,7 +525,8 @@ void tst_NetworkSelfTest::httpProxy() << Chat::discardUntil(" ") << Chat::expect("200 ") << Chat::discardUntil("\r\n\r\n") - << ftpChat()); + << ftpChat() + ); } void tst_NetworkSelfTest::httpProxyBasicAuth() @@ -540,11 +579,22 @@ static const char handshakeAuthPassword[] = "\5\1\2\1\12qsockstest\10password"; static const char handshakeOkPasswdAuth[] = "\5\2\1\0"; static const char handshakeAuthNotOk[] = "\5\377"; static const char connect1[] = "\5\1\0\1\177\0\0\1\0\25"; // Connect IPv4 127.0.0.1 port 21 +static const char connect1a[] = "\5\1\0\1"; // just "Connect to IPv4" +static const char connect1b[] = "\0\25"; // just "port 21" static const char connect2[] = "\5\1\0\3\11localhost\0\25"; // Connect hostname localhost 21 +static const char connect2a[] = "\5\1\0\3"; // just "Connect to hostname" static const char connected[] = "\5\0\0"; +#define QBA(x) (QByteArray::fromRawData(x, -1 + sizeof(x))) + void tst_NetworkSelfTest::socks5Proxy() { + union { + char buf[4]; + quint32 data; + } ip4Address; + ip4Address.data = qToBigEndian(serverIpAddress().toIPv4Address()); + netChat(1080, QList() // IP address connection << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) @@ -555,7 +605,17 @@ void tst_NetworkSelfTest::socks5Proxy() << Chat::skipBytes(6) // the server's local address and port << ftpChat() - // hostname connection + // connect by IP + << Chat::Reconnect + << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) + << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) + << Chat::send(QBA(connect1a) + QByteArray::fromRawData(ip4Address.buf, 4) + QBA(connect1b)) + << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::expect("\1") // IPv4 address following + << Chat::skipBytes(6) // the server's local address and port + << ftpChat() + + // connect to "localhost" by hostname << Chat::Reconnect << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) @@ -564,6 +624,16 @@ void tst_NetworkSelfTest::socks5Proxy() << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() + + // connect to server by its official name + << Chat::Reconnect + << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth)) + << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth)) + << Chat::send(QBA(connect2a) + char(QtNetworkSettings::serverName().size()) + QtNetworkSettings::serverName().toLatin1() + QBA(connect1b)) + << Chat::expect(QByteArray(connected, -1 + sizeof connected)) + << Chat::expect("\1") // IPv4 address following + << Chat::skipBytes(6) // the server's local address and port + << ftpChat() ); } -- cgit v0.12 From 591f5353c88439594b9340226b4843d7ca2888ef Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 7 Oct 2009 11:48:08 +0200 Subject: Fix ASSERT caused by Plastique style when setting an application font with a pixel size Use QFontInfo to query the pointSize() instead of asking the font directly, fixing this assert: ASSERT failure in QFont::setPointSize: "point size must be greater than 0", file text/qfont.cpp, line 855 Task-number: QTBUG-3555 Reviewed-by: Simon Hausmann --- src/gui/styles/qplastiquestyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 349a60d..8e19022 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -3328,7 +3328,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // Draw the text centered QFont font = painter->font(); - font.setPointSize(font.pointSize() - 1); + font.setPointSize(QFontInfo(font).pointSize() - 1); painter->setFont(font); painter->setPen(dockWidget->palette.windowText().color()); painter->drawText(titleRect, -- cgit v0.12 From 1c5b84937a7dd993e188f2a6fbf4e28916f683c9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 7 Oct 2009 12:01:06 +0200 Subject: fix ts and qm targets under windows --- translations/translations.pri | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/translations/translations.pri b/translations/translations.pri index 0c5c1ee..0fb91e8 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -9,12 +9,9 @@ defineReplace(prependAll) { } defineReplace(fixPath) { -WIN { - return ($$replace($$1, /, \)) -} ELSE { + win32:1 ~= s|/|\\| return ($$1) } -} LUPDATE = $$fixPath($$QT_BUILD_TREE/bin/lupdate) -locations relative -no-ui-lines LRELEASE = $$fixPath($$QT_BUILD_TREE/bin/lrelease) -- cgit v0.12 From cc95666378ee0aef1cc6b02b544fdf52645f6d9b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 7 Oct 2009 15:52:59 +0200 Subject: ignore invalid WM_KEYDOWN messages on Windows For some strange reason, I get the following message if I press a non-numerical key on the SIP of a Samsung Omnia device, running Windows mobile 6.1: WM_KEYDOWN wParam == 0 lParam == 1 That message is invalid. We must ignore it. Reviewed-by: mauricek --- src/gui/kernel/qkeymapper_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qkeymapper_win.cpp b/src/gui/kernel/qkeymapper_win.cpp index 25b6dce..8138839 100644 --- a/src/gui/kernel/qkeymapper_win.cpp +++ b/src/gui/kernel/qkeymapper_win.cpp @@ -949,8 +949,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool if(msg.wParam == VK_PROCESSKEY) return true; - // Ignore invalid virtual keycode (see bug 127424) - if (msg.wParam == 0xFF) + // Ignore invalid virtual keycodes (see bugs 127424, QTBUG-3630) + if (msg.wParam == 0 || msg.wParam == 0xFF) return true; // Translate VK_* (native) -> Key_* (Qt) keys -- cgit v0.12 From aa863c61ec5e68ff73c02e25a2954cdba9c2ef15 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 3 Jul 2009 16:40:32 +0200 Subject: QHeaderView: fixed the sizeHint with hidden sections We used to check the 100 first sections and 100 last sections Now we make sure we check 100 visible sections Task-number: 255574 --- src/gui/itemviews/qheaderview.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index c5e6fed..b1306cc 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -526,20 +526,24 @@ QSize QHeaderView::sizeHint() const return d->cachedSizeHint; int width = 0; int height = 0; + d->executePostedLayout(); + // get size hint for the first n sections - int c = qMin(count(), 100); - for (int i = 0; i < c; ++i) { + int i = 0; + for (int checked = 0; checked < 100 && i < d->sectionCount; ++i) { if (isSectionHidden(i)) continue; + checked++; QSize hint = sectionSizeFromContents(i); width = qMax(hint.width(), width); height = qMax(hint.height(), height); } // get size hint for the last n sections - c = qMax(count() - 100, c); - for (int j = count() - 1; j >= c; --j) { + i = qMax(i, d->sectionCount - 100 ); + for (int j = d->sectionCount - 1, checked = 0; j > i && checked < 100; --j) { if (isSectionHidden(j)) continue; + checked++; QSize hint = sectionSizeFromContents(j); width = qMax(hint.width(), width); height = qMax(hint.height(), height); -- cgit v0.12