QTfrontend/net/tcpBase.cpp
changeset 9800 169fbb968bb3
parent 9212 1d4e1469940b
child 9998 736015b847e3
--- a/QTfrontend/net/tcpBase.cpp	Sun Dec 15 14:05:42 2013 -0500
+++ b/QTfrontend/net/tcpBase.cpp	Wed Dec 18 01:05:15 2013 +0400
@@ -80,6 +80,7 @@
     QObject(parent),
     m_hasStarted(false),
     m_isDemoMode(demoMode),
+    m_connected(false),
     IPCSocket(0)
 {
     if(!IPCServer)
@@ -103,12 +104,23 @@
         // connection should be already finished
         return;
     }
+
     disconnect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
     IPCSocket = IPCServer->nextPendingConnection();
+
     if(!IPCSocket) return;
+
+    m_connected = true;
+
     connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect()));
     connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
     SendToClientFirst();
+
+    if(simultaneousRun())
+    {
+        srvsList.removeOne(this);
+        emit isReadyNow();
+    }
 }
 
 void TCPBase::RealStart()
@@ -149,7 +161,8 @@
     disconnect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
     onClientDisconnect();
 
-    emit isReadyNow();
+    if(!simultaneousRun())
+        emit isReadyNow();
     IPCSocket->deleteLater();
 
     deleteLater();
@@ -188,6 +201,7 @@
         TCPBase * last = srvsList.last();
         if(couldCancelPreviousRequest
             && last->couldBeRemoved()
+            && (last->isConnected() || !last->hasStarted())
             && (last->parent() == parent()))
         {
             srvsList.removeLast();
@@ -195,7 +209,7 @@
             Start(couldCancelPreviousRequest);
         } else
         {
-            connect(srvsList.last(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
+            connect(last, SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
             srvsList.push_back(this);
         }
     }
@@ -246,3 +260,18 @@
 {
     return false;
 }
+
+bool TCPBase::isConnected()
+{
+    return m_connected;
+}
+
+bool TCPBase::simultaneousRun()
+{
+    return false;
+}
+
+bool TCPBase::hasStarted()
+{
+    return m_hasStarted;
+}