summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-04-08 14:14:16 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-08-13 16:34:51 +0000
commit01d0b1d6e3fe76d1cd09eeb6474c69e712f37b16 (patch)
treee6b489dd67209f2235bc077b52657a84a06cbfec /src/network/socket/qnativesocketengine.cpp
parent2366ca059e6c4b8ae93a125eb8df8f660275d527 (diff)
Merge the multiple implementations of getting the local hostname
This commit moves the functionality from QtNetwork's QHostInfo to QtCore. Note that due to Windows ws2_32.dll's quirky behavior of requiring WSAStartup before calling gethostname, this change required moving the initialization to QtCore too. On Linux systems, gethostname() gets the name from uname(), so we bypass the middle man and save one memcpy. Change-Id: I27eaacb532114dd188c4ffff13d32655a6301346 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com> Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/socket/qnativesocketengine.cpp')
-rw-r--r--src/network/socket/qnativesocketengine.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index 33bf3af0b5..22151b8e56 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -152,10 +152,6 @@ QT_BEGIN_NAMESPACE
/*! \internal
Constructs the private class and initializes all data members.
-
- On Windows, WSAStartup is called "recursively" for every
- concurrent QNativeSocketEngine. This is safe, because WSAStartup and
- WSACleanup are reference counted.
*/
QNativeSocketEnginePrivate::QNativeSocketEnginePrivate() :
socketDescriptor(-1),
@@ -163,6 +159,9 @@ QNativeSocketEnginePrivate::QNativeSocketEnginePrivate() :
writeNotifier(0),
exceptNotifier(0)
{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ QSysInfo::machineHostName(); // this initializes ws2_32.dll
+#endif
}
/*! \internal