Octave Interface: Tentative Fix of lockup of Resinsight

Added a timer to call back if a signal from the socket has to be
ignored.
This way we should not loose signals and state.
Needs to be experienced over some time to be verified.
This commit is contained in:
Jacob Støren
2013-10-08 14:21:18 +02:00
parent d5fe84bfbb
commit 606a14f9f7
2 changed files with 22 additions and 1 deletions

View File

@@ -18,6 +18,7 @@
#include "RiaStdInclude.h"
#include "RiaSocketServer.h"
#include "RiaSocketCommand.h"
#include "RiaSocketTools.h"
#include <QtGui>
#include <QtNetwork>
@@ -68,6 +69,10 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
m_tcpServer = new QTcpServer(this);
m_nextPendingConnectionTimer = new QTimer(this);
m_nextPendingConnectionTimer->setInterval(100);
m_nextPendingConnectionTimer->setSingleShot(true);
if (!m_tcpServer->listen(QHostAddress::LocalHost, 40001))
{
m_errorMessageDialog->showMessage("Octave communication disabled :\n"
@@ -81,6 +86,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent)
return;
}
connect(m_nextPendingConnectionTimer, SIGNAL(timeout()), this, SLOT(handleNextPendingConnection()));
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewClientConnection()));
}
@@ -110,6 +116,8 @@ void RiaSocketServer::slotNewClientConnection()
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
{
//PMonLog("Starting Timer");
m_nextPendingConnectionTimer->start(); // Reset and start again
return;
}
@@ -312,9 +320,18 @@ void RiaSocketServer::handleNextPendingConnection()
{
if (m_currentClient && (m_currentClient->state() == QAbstractSocket::ConnectedState) )
{
//PMonLog("Starting Timer");
m_nextPendingConnectionTimer->start(); // Reset and start again
return;
}
// Stop timer
if (m_nextPendingConnectionTimer->isActive())
{
//PMonLog("Stopping Timer");
m_nextPendingConnectionTimer->stop();
}
terminateCurrentConnection();
QTcpSocket* clientToHandle = m_tcpServer->nextPendingConnection();