From b2dd6e8b0b86446cb4d3f32403b029ee2496cc11 Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Thu, 22 May 2014 11:41:31 +0200 Subject: Fix segfault. Drop nullpointer polls since SslSocket is now const. [id == _VNCCLIENT] Logical reduction. Cleanup header. --- src/server/net/client.cpp | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'src/server/net/client.cpp') diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 3859f06..67b25b2 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -56,12 +56,8 @@ Client::Client(QSslSocket* socket) : _socket(socket) /******************************************************************************/ Client::~Client() { - if (_socket != NULL) - { - qCritical("**** SOCKET DELETE IN DESTRUCTOR"); - _socket->deleteLater(); - } - qDebug("*** Client %s destroyed.", qPrintable(_socket->peerAddress().toString())); + qDebug() << "*** Client" << _host << " destroyed."; + _socket->deleteLater(); } /******************************************************************************/ @@ -90,7 +86,7 @@ void Client::timerEvent(QTimerEvent* event) /******************************************************************************/ void Client::sendMessage(NetworkMessage& message) { - if (_socket == NULL || _socket->state() != QAbstractSocket::ConnectedState) + if (_socket->state() != QAbstractSocket::ConnectedState) return; message.writeMessage(_socket); if (!message.writeComplete()) @@ -102,7 +98,7 @@ void Client::sendMessage(NetworkMessage& message) /******************************************************************************/ void Client::requestThumb(const int width, const int height) { - if (_socket == NULL || _socket->state() != QAbstractSocket::ConnectedState) + if (_socket->state() != QAbstractSocket::ConnectedState) { qDebug("requestThumb called in bad state"); return; @@ -118,13 +114,12 @@ void Client::requestThumb(const int width, const int height) void Client::onDataArrival() { // - if (_socket == NULL || _socket->state() != QAbstractSocket::ConnectedState) + if (_socket->state() != QAbstractSocket::ConnectedState) { qDebug("dataArrival called in bad state"); return; } - //qDebug() << _socket->bytesAvailable() << " bytes to read"; bool ret; while (_socket->bytesAvailable()) { @@ -138,8 +133,6 @@ void Client::onDataArrival() { this->handleMsg(); _fromClient.reset(); - if (_socket == NULL) - return; } } } @@ -198,26 +191,25 @@ void Client::handleMsg() { // Client tells us that it started or stopped displaying a remote screen via VNC _activeVncClient = (_fromClient.getFieldString("ENABLED").toInt() != 0); - const int other = (int)_fromClient.getFieldString("CLIENTID").toInt(); + const int projectionSource = (int)_fromClient.getFieldString("CLIENTID").toInt(); - const int last = _activeVncClient ? _currentProjectionSource : other; - - if (!_activeVncClient) + if (_activeVncClient) { - if (other == _desiredProjectionSource) + qDebug() << "Client " << _name << " started its VNC client (watching " << projectionSource << ")"; + if (projectionSource == _desiredProjectionSource) _desiredProjectionSource = 0; - _currentProjectionSource = 0; - qDebug() << "Client " << _name << " stopped its VNC client (watched " << last << ")"; + emit vncClientStateChange(this, _currentProjectionSource); + _currentProjectionSource = projectionSource; } else { - if (other == _desiredProjectionSource) + qDebug() << "Client " << _name << " stopped its VNC client (watched " << projectionSource << ")"; + if (projectionSource == _desiredProjectionSource) _desiredProjectionSource = 0; - _currentProjectionSource = other; - qDebug() << "Client " << _name << " started its VNC client (watching " << other << ")"; + emit vncClientStateChange(this, _currentProjectionSource); + _currentProjectionSource = 0; } - emit vncClientStateChange(this, last); } return; } @@ -339,7 +331,6 @@ void Client::disconnect() qDebug("*** Client %s disconnected.", qPrintable(_socket->peerAddress().toString())); _socket->blockSignals(true); _socket->abort(); - _socket->deleteLater(); this->deleteLater(); emit disconnected(); } -- cgit v1.2.3-55-g7522