170 connect(instance, SIGNAL(finished()), instance, SLOT(deleteLater())); |
170 connect(instance, SIGNAL(finished()), instance, SLOT(deleteLater())); |
171 connect(instance, SIGNAL(finished()), thread, SLOT(deleteLater())); |
171 connect(instance, SIGNAL(finished()), thread, SLOT(deleteLater())); |
172 thread->start(); |
172 thread->start(); |
173 #else |
173 #else |
174 process = new QProcess(this); |
174 process = new QProcess(this); |
175 connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); |
175 connect(process, SIGNAL(error(QProcess::ProcessError)), |
|
176 this, SLOT(StartProcessError(QProcess::ProcessError))); |
|
177 connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), |
|
178 this, SLOT(onEngineDeath(int, QProcess::ExitStatus))); |
176 QStringList arguments = getArguments(); |
179 QStringList arguments = getArguments(); |
177 |
180 |
178 #ifdef QT_DEBUG |
181 #ifdef QT_DEBUG |
179 // redirect everything written on stdout/stderr |
182 // redirect everything written on stdout/stderr |
180 process->setProcessChannelMode(QProcess::ForwardedChannels); |
183 process->setProcessChannelMode(QProcess::ForwardedChannels); |
213 |
218 |
214 void TCPBase::StartProcessError(QProcess::ProcessError error) |
219 void TCPBase::StartProcessError(QProcess::ProcessError error) |
215 { |
220 { |
216 MessageDialog::ShowFatalMessage(tr("Unable to run engine at %1\nError code: %2").arg(bindir->absolutePath() + "/hwengine").arg(error)); |
221 MessageDialog::ShowFatalMessage(tr("Unable to run engine at %1\nError code: %2").arg(bindir->absolutePath() + "/hwengine").arg(error)); |
217 ClientDisconnect(); |
222 ClientDisconnect(); |
|
223 } |
|
224 |
|
225 void TCPBase::onEngineDeath(int exitCode, QProcess::ExitStatus exitStatus) |
|
226 { |
|
227 Q_UNUSED(exitStatus); |
|
228 |
|
229 ClientDisconnect(); |
|
230 |
|
231 // 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 |
|
233 if ((exitCode != 0) && (exitCode != 2)) |
|
234 { |
|
235 // inform user that something bad happened |
|
236 MessageDialog::ShowFatalMessage( |
|
237 tr("The game engine died unexpectedly!") |
|
238 + QString("\n(exit code %1)").arg(exitCode) |
|
239 + "\n\n " + tr("We are very sorry for the inconvenience :(") + "\n\n" + |
|
240 tr("If this keeps happening, please click the '%1' button in the main menu!") |
|
241 .arg("Feedback")); |
|
242 |
|
243 } |
|
244 |
|
245 // cleanup up |
|
246 if (IPCSocket) |
|
247 { |
|
248 IPCSocket->close(); |
|
249 IPCSocket->deleteLater(); |
|
250 } |
|
251 |
|
252 // plot suicide |
|
253 deleteLater(); |
218 } |
254 } |
219 |
255 |
220 void TCPBase::tcpServerReady() |
256 void TCPBase::tcpServerReady() |
221 { |
257 { |
222 disconnect(srvsList.first(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); |
258 disconnect(srvsList.first(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); |