22 |
35 |
23 IPCSocket->close(); |
36 IPCSocket->close(); |
24 IPCSocket->deleteLater(); |
37 IPCSocket->deleteLater(); |
25 IPCSocket = 0; |
38 IPCSocket = 0; |
26 IPCServer->close(); |
39 IPCServer->close(); |
27 deleteLater(); |
40 //deleteLater(); |
28 |
41 |
|
42 |
|
43 tcpSrvMut.lock(); |
|
44 if(isBusy) --isBusy; |
|
45 //if(!isBusy) srvsList.pop_front();//lastStarted=0; |
|
46 tcpSrvMut.unlock(); |
|
47 qDebug() << "image emitted with seed " << QString(m_seed.c_str()); |
29 emit ImageReceived(im); |
48 emit ImageReceived(im); |
|
49 readbuffer.clear(); |
|
50 emit isReadyNow(); |
30 } |
51 } |
31 |
52 |
32 void HWMap::ClientRead() |
53 void HWMap::ClientRead() |
33 { |
54 { |
34 readbuffer.append(IPCSocket->readAll()); |
55 readbuffer.append(IPCSocket->readAll()); |
64 QMessageBox::critical(0, tr("Error"), |
85 QMessageBox::critical(0, tr("Error"), |
65 tr("Unable to run engine: %1 (") |
86 tr("Unable to run engine: %1 (") |
66 .arg(error) + bindir->absolutePath() + "/hwengine)"); |
87 .arg(error) + bindir->absolutePath() + "/hwengine)"); |
67 } |
88 } |
68 |
89 |
|
90 void HWMap::tcpServerReady() |
|
91 { |
|
92 qDebug() << "received signal, i am " << this << ";"; |
|
93 qDebug() << srvsList.front() << " disconnected from " << *(++srvsList.begin()); |
|
94 tcpSrvMut.lock(); |
|
95 disconnect(srvsList.front(), SIGNAL(isReadyNow()), *(++srvsList.begin()), SLOT(tcpServerReady())); |
|
96 srvsList.pop_front(); |
|
97 tcpSrvMut.unlock(); |
|
98 |
|
99 RealStart(); |
|
100 } |
|
101 |
69 void HWMap::Start() |
102 void HWMap::Start() |
|
103 { |
|
104 tcpSrvMut.lock(); |
|
105 if(!isBusy) { |
|
106 qDebug() << "notBusy, i am " << this; |
|
107 ++isBusy; |
|
108 srvsList.push_back(this); |
|
109 tcpSrvMut.unlock(); |
|
110 } else { |
|
111 qDebug() << "Busy, connected " << srvsList.back() << " to " << this; |
|
112 connect(srvsList.back(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); |
|
113 srvsList.push_back(this); |
|
114 //deleteLater(); |
|
115 tcpSrvMut.unlock(); |
|
116 return; |
|
117 } |
|
118 |
|
119 RealStart(); |
|
120 } |
|
121 |
|
122 void HWMap::RealStart() |
70 { |
123 { |
71 IPCServer = new QTcpServer(this); |
124 IPCServer = new QTcpServer(this); |
72 connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
125 connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); |
73 IPCServer->setMaxPendingConnections(1); |
126 IPCServer->setMaxPendingConnections(1); |
74 IPCSocket = 0; |
127 IPCSocket = 0; |