Restore almost old TCPBase behaviour
authorStepan777 <stepik-777@mail.ru>
Tue, 26 Jun 2012 02:14:35 +0400
changeset 7289 835bb2852579
parent 7286 068adc6948e3
child 7294 135e4fb3b095
Restore almost old TCPBase behaviour (it was only necessary to move emiting of isReadyNow() from ClientDisconnect() to NewConnection()). Also ensure deletion of IPCSocket.
QTfrontend/net/tcpBase.cpp
QTfrontend/net/tcpBase.h
--- a/QTfrontend/net/tcpBase.cpp	Sun Jun 24 21:33:45 2012 +0400
+++ b/QTfrontend/net/tcpBase.cpp	Tue Jun 26 02:14:35 2012 +0400
@@ -26,16 +26,18 @@
 
 #include "hwconsts.h"
 
-//QList<TCPBase*> srvsList;
-//QPointer<QTcpServer> TCPBase::IPCServer(0);
+QList<TCPBase*> srvsList;
+QPointer<QTcpServer> TCPBase::IPCServer(0);
 
 TCPBase::~TCPBase()
 {
+    if (IPCSocket)
+        IPCSocket->deleteLater();
 }
 
 TCPBase::TCPBase(bool demoMode) :
     m_isDemoMode(demoMode),
-    IPCSocket(0), IPCServer(0)
+    IPCSocket(0)
 {
     if(!IPCServer)
     {
@@ -65,9 +67,12 @@
     connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect()));
     connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
     SendToClientFirst();
+
+    if(srvsList.size()==1) srvsList.pop_front();
+    emit isReadyNow();
 }
 
-void TCPBase::/*Real*/Start()
+void TCPBase::RealStart()
 {
     connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
     IPCSocket = 0;
@@ -109,13 +114,13 @@
                           .arg(error) + bindir->absolutePath() + "/hwengine)");
 }
 
-/*
 void TCPBase::tcpServerReady()
 {
     disconnect(srvsList.takeFirst(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
 
     RealStart();
 }
+
 void TCPBase::Start()
 {
     if(srvsList.isEmpty())
@@ -130,7 +135,7 @@
     }
 
     RealStart();
-}*/
+}
 
 void TCPBase::onClientRead()
 {
--- a/QTfrontend/net/tcpBase.h	Sun Jun 24 21:33:45 2012 +0400
+++ b/QTfrontend/net/tcpBase.h	Tue Jun 26 02:14:35 2012 +0400
@@ -62,11 +62,11 @@
         virtual void onClientDisconnect();
         virtual void SendToClientFirst();
 
-      //  void RealStart();
     private:
-        /*static*/ QPointer<QTcpServer> IPCServer;
+        static QPointer<QTcpServer> IPCServer;
 
         bool m_isDemoMode;
+        void RealStart();
         QPointer<QTcpSocket> IPCSocket;
 
     private slots:
@@ -75,7 +75,7 @@
         void ClientRead();
         void StartProcessError(QProcess::ProcessError error);
 
-      //  void tcpServerReady();
+        void tcpServerReady();
 };
 
 #endif // _TCPBASE_INCLUDED