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