From 84ca3a7c7b5a025703a8490f2f355fa04eab417a Mon Sep 17 00:00:00 2001 From: Jeff Zignego Date: Tue, 8 Mar 2022 12:52:19 -0600 Subject: [PATCH] src/socketpair.cpp: remove dataCheck timer Now that the race conditions in starting the signal handling are resolved, we can get rid of the dataCheck timer, and just use the readyRead signal from the serverConnection socket. --- src/socketpair.cpp | 8 +------- src/socketpair.h | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/socketpair.cpp b/src/socketpair.cpp index e95054e..dfd624c 100644 --- a/src/socketpair.cpp +++ b/src/socketpair.cpp @@ -6,13 +6,10 @@ SocketPair::SocketPair(QObject *parent) : QObject(parent) { - dataCheck = new QTimer(); - dataCheck->setInterval(100); } bool SocketPair::create() { - connect(dataCheck, SIGNAL(timeout()), this, SLOT(readServerData())); connect(&server, SIGNAL(newConnection()), this, SLOT(newConnection()), Qt::QueuedConnection); connect(&server, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(logServerError(QAbstractSocket::SocketError))); @@ -55,9 +52,7 @@ void SocketPair::newConnection() serverConnection->setSocketOption( QAbstractSocket::KeepAliveOption, 1 ); serverConnection->setReadBufferSize( 1 ); - dataCheck->start(); - -// connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readServerData())); + connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readServerData())); server.close(); emit clientConnected(); } @@ -72,7 +67,6 @@ void SocketPair::readServerData() void SocketPair::close() { - dataCheck->stop(); clientConnection.close(); if (serverConnection) { serverConnection->close(); diff --git a/src/socketpair.h b/src/socketpair.h index ef58a5a..3484f0e 100644 --- a/src/socketpair.h +++ b/src/socketpair.h @@ -30,7 +30,6 @@ public slots: void readServerData(); private: - QTimer *dataCheck; QTcpSocket *serverConnection; QTcpSocket clientConnection; QTcpServer server;