Commit 4b17c2e0e6013f3c83d6a392190fc7a3100acf75
- Diff rendering mode:
- inline
- side by side
hooq/MainWindow.cpp
(9 / 1)
|   | |||
| 397 | 397 | m_interpreter, | |
| 398 | 398 | SLOT(run(QTcpSocket*)) | |
| 399 | 399 | ); | |
| 400 | m_hooqPlayer->start(applicationPath(), m_arguments, m_hooqPlayInjector); | ||
| 400 | |||
| 401 | try | ||
| 402 | { | ||
| 403 | m_hooqPlayer->start(applicationPath(), m_arguments, m_hooqPlayInjector); | ||
| 404 | } | ||
| 405 | catch(Hooq::RemoteConnectionException e) | ||
| 406 | { | ||
| 407 | QMessageBox::critical(this, tr("Could not attach to process"), tr("Failed to open a socket: %1 (error number %2)").arg(e.errorString()).arg(static_cast<int>(e.serverError()))); | ||
| 408 | } | ||
| 401 | 409 | } | |
| 402 | 410 | ||
| 403 | 411 | void MainWindow::logException(const QString& exception, const QStringList& backtrace) |
|   | |||
| 31 | 31 | namespace Hooq | |
| 32 | 32 | { | |
| 33 | 33 | ||
| 34 | RemoteConnectionException::RemoteConnectionException(QAbstractSocket::SocketError serverError, const QString& errorString) | ||
| 35 | : m_serverError(serverError) | ||
| 36 | , m_errorString(errorString) | ||
| 37 | { | ||
| 38 | } | ||
| 39 | |||
| 40 | QAbstractSocket::SocketError RemoteConnectionException::serverError() const | ||
| 41 | { | ||
| 42 | return m_serverError; | ||
| 43 | } | ||
| 44 | |||
| 45 | QString RemoteConnectionException::errorString() const | ||
| 46 | { | ||
| 47 | return m_errorString; | ||
| 48 | } | ||
| 49 | |||
| 34 | 50 | RemoteConnection::RemoteConnection(QObject* parent) | |
| 35 | 51 | : QObject(parent) | |
| 36 | 52 | , m_localServer(0) | |
| … | … | ||
| 64 | 64 | SLOT(acceptConnection()) | |
| 65 | 65 | ); | |
| 66 | 66 | ||
| 67 | m_localServer->listen(QHostAddress::LocalHost, Communication::serverPort()); | ||
| 67 | if(!m_localServer->listen(QHostAddress::LocalHost, Communication::serverPort())) | ||
| 68 | { | ||
| 69 | throw RemoteConnectionException(m_localServer->serverError(), m_localServer->errorString()); | ||
| 70 | } | ||
| 68 | 71 | ||
| 69 | 72 | injector->startAndAttach(application, arguments); | |
| 70 | 73 | } |
hooqInjector/RemoteConnection.h
(12 / 0)
|   | |||
| 21 | 21 | ||
| 22 | 22 | #include "InjectorImport.h" | |
| 23 | 23 | ||
| 24 | #include <QAbstractSocket> | ||
| 24 | 25 | #include <QObject> | |
| 25 | 26 | ||
| 26 | 27 | class QTcpServer; | |
| … | … | ||
| 30 | 30 | namespace Hooq | |
| 31 | 31 | { | |
| 32 | 32 | class Injector; | |
| 33 | |||
| 34 | class HOOQ_INJECTOR_EXPORT RemoteConnectionException | ||
| 35 | { | ||
| 36 | public: | ||
| 37 | RemoteConnectionException(QAbstractSocket::SocketError serverError, const QString& errorString); | ||
| 38 | QAbstractSocket::SocketError serverError() const; | ||
| 39 | QString errorString() const; | ||
| 40 | private: | ||
| 41 | QAbstractSocket::SocketError m_serverError; | ||
| 42 | QString m_errorString; | ||
| 43 | }; | ||
| 33 | 44 | ||
| 34 | 45 | class HOOQ_INJECTOR_EXPORT RemoteConnection : public QObject | |
| 35 | 46 | { |

