From 84c93bbbe5c8a2ff4c18aaa431aa73776cadd8e2 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 18 Aug 2013 07:40:34 +0000 Subject: [PATCH] fix for the "Multiple socket notifiers for same socket" error if threaded socket is used --- src/socket.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/socket.cpp b/src/socket.cpp index b95acd35..fdd90e08 100755 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -70,8 +70,19 @@ void CSocket::Init ( const quint16 iPortNumber ) } // connect the "activated" signal +#ifdef ENABLE_RECEIVE_SOCKET_IN_SEPARATE_THREAD + // We have to use a blocked queued connection since in case we use a + // separate socket thread, the "readyRead" signal would occur and our + // "OnDataReceived" function would be run in another thread. This could + // lead to a situation that a new "readRead" occurs while the processing + // of the previous signal was not finished -> the error: "Multiple + // socket notifiers for same socket" may occur. + QObject::connect ( &SocketDevice, SIGNAL ( readyRead() ), + this, SLOT ( OnDataReceived() ), Qt::BlockingQueuedConnection ); +#else QObject::connect ( &SocketDevice, SIGNAL ( readyRead() ), this, SLOT ( OnDataReceived() ) ); +#endif } void CSocket::SendPacket ( const CVector& vecbySendBuf,