diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-12-09 08:40:37 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-12-09 09:35:46 +0000 |
commit | 713cc6f3a88a91fc8e4488ae6f54b6fbac98551b (patch) | |
tree | ee496573be247ff22b4065f7ac8ff79276b8b1a9 /src | |
parent | 7c401397a4ce6c00652306204c9f8477040a5400 (diff) |
qnativesocketengine_win.cpp: Fix comparison of OS version
Rewrite code to assume Windows 7 as minimum supported version
and check using the operators of QOperatingSystemVersion.
Amends change e26c59e564023b89336d97f7a838cacd7c9cb9e3.
Change-Id: I47cdd4f53ef55441ac7c1f6b1c15f8d4983d70b1
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 0b068a61da..80147b47ba 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -52,7 +52,6 @@ #include <qdatetime.h> #include <qnetworkinterface.h> #include <qoperatingsystemversion.h> -#include <qversionnumber.h> //#define QNATIVESOCKETENGINE_DEBUG #if defined(QNATIVESOCKETENGINE_DEBUG) @@ -336,9 +335,6 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc return false; } - const QVersionNumber osVersion = QOperatingSystemVersion::current().toVersionNumber(); - const QVersionNumber windows7Version = QVersionNumber(6, 1); - //Windows XP and 2003 support IPv6 but not dual stack sockets int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol || (socketProtocol == QAbstractSocket::AnyIPProtocol)) ? AF_INET6 : AF_INET; @@ -353,14 +349,11 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc #define WSA_FLAG_NO_HANDLE_INHERIT 0x80 #endif - SOCKET socket = INVALID_SOCKET; - // Windows 7 or later, try the new API - if (osVersion >= windows7Version) - socket = ::WSASocket(protocol, type, 0, NULL, 0, WSA_FLAG_NO_HANDLE_INHERIT | WSA_FLAG_OVERLAPPED); + SOCKET socket = ::WSASocket(protocol, type, 0, NULL, 0, WSA_FLAG_NO_HANDLE_INHERIT | WSA_FLAG_OVERLAPPED); // previous call fails if the windows 7 service pack 1 or hot fix isn't installed. - // Try the old API if the new one failed on Windows 7, or always on earlier versions - if (socket == INVALID_SOCKET && osVersion <= windows7Version) { + // Try the old API if the new one failed on Windows 7 + if (socket == INVALID_SOCKET && QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8) { socket = ::WSASocket(protocol, type, 0, NULL, 0, WSA_FLAG_OVERLAPPED); #ifdef HANDLE_FLAG_INHERIT if (socket != INVALID_SOCKET) { |