49 { |
49 { |
50 if(IPCSocket) { |
50 if(IPCSocket) { |
51 // connection should be already finished |
51 // connection should be already finished |
52 return; |
52 return; |
53 } |
53 } |
|
54 disconnect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
54 IPCSocket = IPCServer->nextPendingConnection(); |
55 IPCSocket = IPCServer->nextPendingConnection(); |
55 if(!IPCSocket) return; |
56 if(!IPCSocket) return; |
56 connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); |
57 connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); |
|
58 connect(IPCSocket, SIGNAL(disconnected()), IPCSocket, SLOT(deleteLater())); |
57 connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); |
59 connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); |
58 SendToClientFirst(); |
60 SendToClientFirst(); |
59 } |
61 } |
60 |
62 |
61 void TCPBase::RealStart() |
63 void TCPBase::RealStart() |
62 { |
64 { |
63 connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
65 connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
64 IPCSocket = 0; |
66 IPCSocket = 0; |
65 |
67 |
66 QProcess * process; |
68 QProcess * process; |
67 process = new QProcess; |
69 process = new QProcess; |
68 connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
70 connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
69 QStringList arguments=setArguments(); |
71 QStringList arguments=setArguments(); |
70 process->start(bindir->absolutePath() + "/hwengine", arguments); |
72 process->start(bindir->absolutePath() + "/hwengine", arguments); |
71 } |
73 } |
72 |
74 |
73 void TCPBase::ClientDisconnect() |
75 void TCPBase::ClientDisconnect() |
74 { |
76 { |
75 IPCSocket->close(); |
|
76 IPCSocket->deleteLater(); |
|
77 // IPCSocket = 0; // FIXME: breaks image receiving |
|
78 |
|
79 onClientDisconnect(); |
77 onClientDisconnect(); |
80 |
78 |
81 readbuffer.clear(); |
79 readbuffer.clear(); |
82 |
80 |
83 if(srvsList.size()==1) srvsList.pop_front(); |
81 if(srvsList.size()==1) srvsList.pop_front(); |
97 .arg(error) + bindir->absolutePath() + "/hwengine)"); |
95 .arg(error) + bindir->absolutePath() + "/hwengine)"); |
98 } |
96 } |
99 |
97 |
100 void TCPBase::tcpServerReady() |
98 void TCPBase::tcpServerReady() |
101 { |
99 { |
102 disconnect(srvsList.front(), SIGNAL(isReadyNow()), *(++srvsList.begin()), SLOT(tcpServerReady())); |
100 disconnect(srvsList.front(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); |
103 srvsList.pop_front(); |
101 srvsList.pop_front(); |
104 |
102 |
105 RealStart(); |
103 RealStart(); |
106 } |
104 } |
107 |
105 |