From 361051345047a76da15ddc3de71a21b672944837 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Mon, 13 Apr 2015 20:21:16 +0300 Subject: [PATCH] QAbstractSocket: virtualize options setting Some kinds of socket options can be applied only to newly created descriptors. However, a current QAbstractSocket implementation proceeds to actions immediately after the socket layer initialization. This disallows a socket tuning in further inheritance. Add a private virtual configureCreatedSocket() method that gives an ability to set the socket options before binding or connecting. Change-Id: I2d858a400cd46ae7fe5bf0b8900220f6121d0132 Reviewed-by: Richard J. Moore --- src/network/socket/qabstractsocket.cpp | 8 ++++++++ src/network/socket/qabstractsocket_p.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index baecf27162..67dea74436 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -650,6 +650,8 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc return false; } + configureCreatedSocket(); + if (threadData->hasEventDispatcher()) socketEngine->setReceiver(this); @@ -660,6 +662,12 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc return true; } +/*! \internal +*/ +void QAbstractSocketPrivate::configureCreatedSocket() +{ +} + /*! \internal Slot connected to the read socket notifier. This slot is called diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h index 63440b6416..1c04277f49 100644 --- a/src/network/socket/qabstractsocket_p.h +++ b/src/network/socket/qabstractsocket_p.h @@ -130,6 +130,7 @@ public: bool flush(); bool initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol); + virtual void configureCreatedSocket(); void startConnectingByName(const QString &host); void fetchConnectionParameters(); void setupSocketNotifiers();