QmlProfiler: Listen on QHostAddress::Any in QmlProfilerToolTest

The attach dialog retrieves the host address to connect to from the
device's toolControlChannel(). All of the toolControlChannel()
implementations currently specify "localhost" as host address.
"localhost" means IPv6 on macOS and IPv4 everywhere else. Unfortunately
there is no shortcut for listening on a dual-stack local address in
QTcpServer and urlFromLocalHostAndFreePort() will try both v4 and v6,
returning whatever works. There is a shortcut for listening on a
dual-stack "any" address, though. As this is only the test, we can live
with exposing a TCP server to the internet for a short time.

Change-Id: I4114f03668e608f80353d21a59edf67db4b7f738
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Ulf Hermann
2018-08-30 10:59:05 +02:00
parent 09b611acde
commit 0b706608fc

View File

@@ -57,7 +57,7 @@ void QmlProfilerToolTest::testAttachToWaitingApplication()
QUrl serverUrl = Utils::urlFromLocalHostAndFreePort();
QVERIFY(serverUrl.port() >= 0);
QVERIFY(serverUrl.port() <= std::numeric_limits<quint16>::max());
server.listen(QHostAddress(serverUrl.host()), static_cast<quint16>(serverUrl.port()));
server.listen(QHostAddress::Any, static_cast<quint16>(serverUrl.port()));
QScopedPointer<QTcpSocket> connection;
connect(&server, &QTcpServer::newConnection, this, [&]() {