summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_win.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-11-25 10:35:24 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-11-25 16:30:06 +0000
commite26c59e564023b89336d97f7a838cacd7c9cb9e3 (patch)
tree7f86090786bd7e171004bcf82ea6c332f2dc1d62 /src/network/socket/qnativesocketengine_win.cpp
parent26e2c6b74f84508a4aa1f3d769ebcb086cccfab5 (diff)
qnativesocketengine_win.cpp: Use QOperatingSystemVersion to detect OS
Fix warning: socket\qnativesocketengine_win.cpp: In member function 'bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType, QAbstractSocket::NetworkLayerProtocol&)': socket\qnativesocketengine_win.cpp:337:26: warning: 'WinVersion' is deprecated: Use QOperatingSystemVersion [-Wdeprecated-declarations] QSysInfo::WinVersion osver = QSysInfo::windowsVersion(); ^ In file included from ..\..\include/QtCore/qsysinfo.h:1:0, from ..\..\include\QtCore/../../src/corelib/global/qglobal.h:1150, from ..\..\include\QtCore/qglobal.h:1, from ..\corelib\global\qt_pch.h:56: enum QT_DEPRECATED_X("Use QOperatingSystemVersion") WinVersion { Change-Id: I9b060d886af3b627ac4b6eeb3321629734cc1e46 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/socket/qnativesocketengine_win.cpp')
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index 5a9641a9fe..0b068a61da 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -51,6 +51,8 @@
#include <qdebug.h>
#include <qdatetime.h>
#include <qnetworkinterface.h>
+#include <qoperatingsystemversion.h>
+#include <qversionnumber.h>
//#define QNATIVESOCKETENGINE_DEBUG
#if defined(QNATIVESOCKETENGINE_DEBUG)
@@ -334,11 +336,12 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
return false;
}
- QSysInfo::WinVersion osver = QSysInfo::windowsVersion();
+ 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 && osver >= QSysInfo::WV_6_0)) ? AF_INET6 : AF_INET;
+ || (socketProtocol == QAbstractSocket::AnyIPProtocol)) ? AF_INET6 : AF_INET;
int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
// MSDN KB179942 states that on winnt 4 WSA_FLAG_OVERLAPPED is needed if socket is to be non blocking
@@ -352,12 +355,12 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
SOCKET socket = INVALID_SOCKET;
// Windows 7 or later, try the new API
- if ((osver & QSysInfo::WV_NT_based) >= QSysInfo::WV_6_1)
+ if (osVersion >= windows7Version)
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 && ((osver & QSysInfo::WV_NT_based) <= QSysInfo::WV_6_1)) {
+ if (socket == INVALID_SOCKET && osVersion <= windows7Version) {
socket = ::WSASocket(protocol, type, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
#ifdef HANDLE_FLAG_INHERIT
if (socket != INVALID_SOCKET) {