diff --git a/qtservice/src/qtservice_unix.cpp b/qtservice/src/qtservice_unix.cpp index 40d75c1..1e99889 100644 --- a/qtservice/src/qtservice_unix.cpp +++ b/qtservice/src/qtservice_unix.cpp @@ -281,7 +281,11 @@ public: QtServiceBase::ServiceFlags serviceFlags; protected: +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + void incomingConnection(qintptr socketDescriptor); +#else void incomingConnection(int socketDescriptor); +#endif private slots: void slotReady(); @@ -303,13 +307,26 @@ QtServiceSysPrivate::~QtServiceSysPrivate() delete[] ident; } +template +inline void incomingConnection(T socketDescriptor, QtServiceSysPrivate *service) +{ + QTcpSocket *s = new QTcpSocket(service); + s->setSocketDescriptor(socketDescriptor); + QObject::connect(s, SIGNAL(readyRead()), service, SLOT(slotReady())); + QObject::connect(s, SIGNAL(disconnected()), service, SLOT(slotClosed())); +} + +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +void QtServiceSysPrivate::incomingConnection(qintptr socketDescriptor) +{ + ::incomingConnection(socketDescriptor, this); +} +#else void QtServiceSysPrivate::incomingConnection(int socketDescriptor) { - QTcpSocket *s = new QTcpSocket(this); - s->setSocketDescriptor(socketDescriptor); - connect(s, SIGNAL(readyRead()), this, SLOT(slotReady())); - connect(s, SIGNAL(disconnected()), this, SLOT(slotClosed())); + ::incomingConnection(socketDescriptor, this); } +#endif void QtServiceSysPrivate::slotReady() {