QTfrontend/net/tcpBase.cpp
changeset 12824 c75781937859
parent 11046 47a8c19ecb60
child 12855 1b2b84315d27
child 12874 7caa4ec513bd
equal deleted inserted replaced
12823:e2e372449c19 12824:c75781937859
   188     m_hasStarted = true;
   188     m_hasStarted = true;
   189 }
   189 }
   190 
   190 
   191 void TCPBase::ClientDisconnect()
   191 void TCPBase::ClientDisconnect()
   192 {
   192 {
   193     disconnect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
       
   194     onClientDisconnect();
   193     onClientDisconnect();
   195 
   194 
   196     if(!simultaneousRun())
   195     if(!simultaneousRun())
   197     {
   196     {
   198 #ifdef HWLIBRARY
   197 #ifdef HWLIBRARY
   200         thread->wait();
   199         thread->wait();
   201 #endif
   200 #endif
   202         emit isReadyNow();
   201         emit isReadyNow();
   203     }
   202     }
   204 
   203 
   205     IPCSocket->deleteLater();
   204     if(IPCSocket) {
   206     IPCSocket = NULL;
   205       disconnect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
       
   206       IPCSocket->deleteLater();
       
   207       IPCSocket = NULL;
       
   208     }
   207 
   209 
   208     deleteLater();
   210     deleteLater();
   209 }
   211 }
   210 
   212 
   211 void TCPBase::ClientRead()
   213 void TCPBase::ClientRead()
   224 
   226 
   225 void TCPBase::onEngineDeath(int exitCode, QProcess::ExitStatus exitStatus)
   227 void TCPBase::onEngineDeath(int exitCode, QProcess::ExitStatus exitStatus)
   226 {
   228 {
   227     Q_UNUSED(exitStatus);
   229     Q_UNUSED(exitStatus);
   228 
   230 
   229     ClientDisconnect();
   231     if(!m_connected)
       
   232       ClientDisconnect();
   230 
   233 
   231     // show error message if there was an error that was not an engine's
   234     // show error message if there was an error that was not an engine's
   232     // fatal error - because that one already sent a info via IPC
   235     // fatal error - because that one already sent a info via IPC
   233     if ((exitCode != 0) && (exitCode != 2))
   236     if ((exitCode != 0) && (exitCode != 2))
   234     {
   237     {
   240             "If this keeps happening, please click the '%2' button in the main menu!")
   243             "If this keeps happening, please click the '%2' button in the main menu!")
   241             .arg(exitCode)
   244             .arg(exitCode)
   242             .arg("Feedback"));
   245             .arg("Feedback"));
   243 
   246 
   244     }
   247     }
   245 
       
   246     // cleanup up
       
   247     if (IPCSocket)
       
   248     {
       
   249         IPCSocket->close();
       
   250         IPCSocket->deleteLater();
       
   251     }
       
   252 
       
   253     // plot suicide
       
   254     deleteLater();
       
   255 }
   248 }
   256 
   249 
   257 void TCPBase::tcpServerReady()
   250 void TCPBase::tcpServerReady()
   258 {
   251 {
   259     disconnect(srvsList.first(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
   252     disconnect(srvsList.first(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));