diff options
author | Shane Kearns <shane.kearns@sosco.com> | 2009-10-26 14:43:55 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@sosco.com> | 2009-10-26 14:43:55 (GMT) |
commit | 32815bd71b08f1a8bbec04e60a973a1fa2d9febe (patch) | |
tree | ae78d56d15e1ea4e36c5464cb6a5cd74e4287b68 | |
parent | f3854db64bcaa0f26faf5ff1414d3b9ccfc00e35 (diff) | |
download | Qt-32815bd71b08f1a8bbec04e60a973a1fa2d9febe.zip Qt-32815bd71b08f1a8bbec04e60a973a1fa2d9febe.tar.gz Qt-32815bd71b08f1a8bbec04e60a973a1fa2d9febe.tar.bz2 |
Make network self test fail instead of crashing in case of DNS error
Reviewed-by: Liang QI
Reviewed-by: Aleksandar Sasha Babic
-rw-r--r-- | tests/auto/networkselftest/tst_networkselftest.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index d58402b..a09d998 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -333,6 +333,11 @@ QHostAddress tst_NetworkSelfTest::serverIpAddress() if (cachedIpAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) { // need resolving QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::serverName()); + if(resolved.error() != QHostInfo::NoError || + !resolved.addresses().isEmpty()) { + qWarning("QHostInfo::fromName failed (%d).", resolved.error()); + return QHostAddress(QHostAddress::Null); + } cachedIpAddress = resolved.addresses().first(); } return cachedIpAddress; |