forked from qt-creator/qt-creator
IosTool: Use Qt5-style connects
Change-Id: I5035b450c1f2c3498f356fc82bef8ea54bcfd61b Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
7c48f9c567
commit
86882018dd
@@ -692,7 +692,7 @@ void IosDeviceManagerPrivate::deviceWithId(QString deviceId, int timeout,
|
|||||||
pendingLookup->userData = userData;
|
pendingLookup->userData = userData;
|
||||||
pendingLookup->timer.setSingleShot(true);
|
pendingLookup->timer.setSingleShot(true);
|
||||||
pendingLookup->timer.setInterval(timeout);
|
pendingLookup->timer.setInterval(timeout);
|
||||||
QObject::connect(&(pendingLookup->timer), SIGNAL(timeout()), q, SLOT(checkPendingLookups()));
|
QObject::connect(&(pendingLookup->timer), &QTimer::timeout, q, &IosDeviceManager::checkPendingLookups);
|
||||||
m_pendingLookups.insertMulti(deviceId, pendingLookup);
|
m_pendingLookups.insertMulti(deviceId, pendingLookup);
|
||||||
pendingLookup->timer.start();
|
pendingLookup->timer.start();
|
||||||
}
|
}
|
||||||
|
@@ -85,12 +85,11 @@ signals:
|
|||||||
void deviceInfo(const QString &deviceId, const Ios::IosDeviceManager::Dict &info);
|
void deviceInfo(const QString &deviceId, const Ios::IosDeviceManager::Dict &info);
|
||||||
void appOutput(const QString &output);
|
void appOutput(const QString &output);
|
||||||
void errorMsg(const QString &msg);
|
void errorMsg(const QString &msg);
|
||||||
private slots:
|
|
||||||
void checkPendingLookups();
|
|
||||||
private:
|
private:
|
||||||
friend class Internal::IosDeviceManagerPrivate;
|
friend class Internal::IosDeviceManagerPrivate;
|
||||||
friend class Internal::DevInfoSession;
|
friend class Internal::DevInfoSession;
|
||||||
IosDeviceManager(QObject *parent = 0);
|
IosDeviceManager(QObject *parent = 0);
|
||||||
|
void checkPendingLookups();
|
||||||
Internal::IosDeviceManagerPrivate *d;
|
Internal::IosDeviceManagerPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -71,7 +71,7 @@ public:
|
|||||||
~Relayer();
|
~Relayer();
|
||||||
void setClientSocket(QTcpSocket *clientSocket);
|
void setClientSocket(QTcpSocket *clientSocket);
|
||||||
bool startRelay(int serverFileDescriptor);
|
bool startRelay(int serverFileDescriptor);
|
||||||
public slots:
|
|
||||||
void handleSocketHasData(int socket);
|
void handleSocketHasData(int socket);
|
||||||
void handleClientHasData();
|
void handleClientHasData();
|
||||||
void handleClientHasError(QAbstractSocket::SocketError error);
|
void handleClientHasError(QAbstractSocket::SocketError error);
|
||||||
@@ -90,7 +90,6 @@ public:
|
|||||||
static const int reconnectMsecDelay = 500;
|
static const int reconnectMsecDelay = 500;
|
||||||
static const int maxReconnectAttempts = 2*60*5; // 5 min
|
static const int maxReconnectAttempts = 2*60*5; // 5 min
|
||||||
RemotePortRelayer(GenericRelayServer *parent, QTcpSocket *clientSocket);
|
RemotePortRelayer(GenericRelayServer *parent, QTcpSocket *clientSocket);
|
||||||
public slots:
|
|
||||||
void tryRemoteConnect();
|
void tryRemoteConnect();
|
||||||
signals:
|
signals:
|
||||||
void didConnect(GenericRelayServer *serv);
|
void didConnect(GenericRelayServer *serv);
|
||||||
@@ -108,7 +107,7 @@ public:
|
|||||||
void stopServer();
|
void stopServer();
|
||||||
quint16 serverPort();
|
quint16 serverPort();
|
||||||
IosTool *iosTool();
|
IosTool *iosTool();
|
||||||
public slots:
|
|
||||||
void handleNewRelayConnection();
|
void handleNewRelayConnection();
|
||||||
void removeRelayConnection(Relayer *relayer);
|
void removeRelayConnection(Relayer *relayer);
|
||||||
protected:
|
protected:
|
||||||
@@ -148,7 +147,6 @@ class GdbRunner: public QObject
|
|||||||
public:
|
public:
|
||||||
GdbRunner(IosTool *iosTool, int gdbFd);
|
GdbRunner(IosTool *iosTool, int gdbFd);
|
||||||
void stop(int phase);
|
void stop(int phase);
|
||||||
public slots:
|
|
||||||
void run();
|
void run();
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
@@ -171,10 +169,9 @@ public:
|
|||||||
void writeTextInElement(const QString &output);
|
void writeTextInElement(const QString &output);
|
||||||
void stopRelayServers(int errorCode = 0);
|
void stopRelayServers(int errorCode = 0);
|
||||||
void writeMaybeBin(const QString &extraMsg, const char *msg, quintptr len);
|
void writeMaybeBin(const QString &extraMsg, const char *msg, quintptr len);
|
||||||
public slots:
|
|
||||||
void errorMsg(const QString &msg);
|
void errorMsg(const QString &msg);
|
||||||
void stopGdbRunner();
|
void stopGdbRunner();
|
||||||
private slots:
|
private:
|
||||||
void stopGdbRunner2();
|
void stopGdbRunner2();
|
||||||
void isTransferringApp(const QString &bundlePath, const QString &deviceId, int progress,
|
void isTransferringApp(const QString &bundlePath, const QString &deviceId, int progress,
|
||||||
const QString &info);
|
const QString &info);
|
||||||
@@ -185,7 +182,6 @@ private slots:
|
|||||||
Ios::DeviceSession *deviceSession);
|
Ios::DeviceSession *deviceSession);
|
||||||
void deviceInfo(const QString &deviceId, const Ios::IosDeviceManager::Dict &info);
|
void deviceInfo(const QString &deviceId, const Ios::IosDeviceManager::Dict &info);
|
||||||
void appOutput(const QString &output);
|
void appOutput(const QString &output);
|
||||||
private:
|
|
||||||
void readStdin();
|
void readStdin();
|
||||||
|
|
||||||
QMutex m_xmlMutex;
|
QMutex m_xmlMutex;
|
||||||
@@ -229,8 +225,9 @@ void Relayer::setClientSocket(QTcpSocket *clientSocket)
|
|||||||
QTC_CHECK(!m_clientSocket);
|
QTC_CHECK(!m_clientSocket);
|
||||||
m_clientSocket = clientSocket;
|
m_clientSocket = clientSocket;
|
||||||
if (m_clientSocket) {
|
if (m_clientSocket) {
|
||||||
connect(m_clientSocket, SIGNAL(error(QAbstractSocket::SocketError)),
|
connect(m_clientSocket,
|
||||||
SLOT(handleClientHasError(QAbstractSocket::SocketError)));
|
static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
|
||||||
|
this, &Relayer::handleClientHasError);
|
||||||
connect(m_clientSocket, &QAbstractSocket::disconnected,
|
connect(m_clientSocket, &QAbstractSocket::disconnected,
|
||||||
this, [this](){server()->removeRelayConnection(this);});
|
this, [this](){server()->removeRelayConnection(this);});
|
||||||
}
|
}
|
||||||
@@ -243,9 +240,9 @@ bool Relayer::startRelay(int serverFileDescriptor)
|
|||||||
if (!m_clientSocket || m_serverFileDescriptor <= 0)
|
if (!m_clientSocket || m_serverFileDescriptor <= 0)
|
||||||
return false;
|
return false;
|
||||||
fcntl(serverFileDescriptor,F_SETFL, fcntl(serverFileDescriptor, F_GETFL) | O_NONBLOCK);
|
fcntl(serverFileDescriptor,F_SETFL, fcntl(serverFileDescriptor, F_GETFL) | O_NONBLOCK);
|
||||||
connect(m_clientSocket, SIGNAL(readyRead()), SLOT(handleClientHasData()));
|
connect(m_clientSocket, &QIODevice::readyRead, this, &Relayer::handleClientHasData);
|
||||||
m_serverNotifier = new QSocketNotifier(m_serverFileDescriptor, QSocketNotifier::Read, this);
|
m_serverNotifier = new QSocketNotifier(m_serverFileDescriptor, QSocketNotifier::Read, this);
|
||||||
connect(m_serverNotifier, SIGNAL(activated(int)), SLOT(handleSocketHasData(int)));
|
connect(m_serverNotifier, &QSocketNotifier::activated, this, &Relayer::handleSocketHasData);
|
||||||
// no way to check if an error did happen?
|
// no way to check if an error did happen?
|
||||||
if (m_clientSocket->bytesAvailable() > 0)
|
if (m_clientSocket->bytesAvailable() > 0)
|
||||||
handleClientHasData();
|
handleClientHasData();
|
||||||
@@ -372,8 +369,7 @@ RemotePortRelayer::RemotePortRelayer(GenericRelayServer *parent, QTcpSocket *cli
|
|||||||
{
|
{
|
||||||
m_remoteConnectTimer.setSingleShot(true);
|
m_remoteConnectTimer.setSingleShot(true);
|
||||||
m_remoteConnectTimer.setInterval(reconnectMsecDelay);
|
m_remoteConnectTimer.setInterval(reconnectMsecDelay);
|
||||||
connect(&m_remoteConnectTimer, SIGNAL(timeout()),
|
connect(&m_remoteConnectTimer, &QTimer::timeout, this, &RemotePortRelayer::tryRemoteConnect);
|
||||||
SLOT(tryRemoteConnect()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePortRelayer::tryRemoteConnect()
|
void RemotePortRelayer::tryRemoteConnect()
|
||||||
@@ -412,7 +408,7 @@ bool RelayServer::startServer(int port, bool ipv6)
|
|||||||
{
|
{
|
||||||
QTC_CHECK(!m_server.isListening());
|
QTC_CHECK(!m_server.isListening());
|
||||||
m_server.setMaxPendingConnections(1);
|
m_server.setMaxPendingConnections(1);
|
||||||
connect(&m_server, SIGNAL(newConnection()), SLOT(handleNewRelayConnection()));
|
connect(&m_server, &QTcpServer::newConnection, this, &RelayServer::handleNewRelayConnection);
|
||||||
quint16 portValue = static_cast<quint16>(port);
|
quint16 portValue = static_cast<quint16>(port);
|
||||||
if (port < 0 || port > 0xFFFF)
|
if (port < 0 || port > 0xFFFF)
|
||||||
return false;
|
return false;
|
||||||
@@ -593,16 +589,12 @@ void IosTool::run(const QStringList &args)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
outFile.flush();
|
outFile.flush();
|
||||||
connect(manager,SIGNAL(isTransferringApp(QString,QString,int,QString)),
|
connect(manager,&Ios::IosDeviceManager::isTransferringApp, this, &IosTool::isTransferringApp);
|
||||||
SLOT(isTransferringApp(QString,QString,int,QString)));
|
connect(manager,&Ios::IosDeviceManager::didTransferApp, this, &IosTool::didTransferApp);
|
||||||
connect(manager,SIGNAL(didTransferApp(QString,QString,Ios::IosDeviceManager::OpStatus)),
|
connect(manager,&Ios::IosDeviceManager::didStartApp, this, &IosTool::didStartApp);
|
||||||
SLOT(didTransferApp(QString,QString,Ios::IosDeviceManager::OpStatus)));
|
connect(manager,&Ios::IosDeviceManager::deviceInfo, this, &IosTool::deviceInfo);
|
||||||
connect(manager,SIGNAL(didStartApp(QString,QString,Ios::IosDeviceManager::OpStatus,int,Ios::DeviceSession*)),
|
connect(manager,&Ios::IosDeviceManager::appOutput, this, &IosTool::appOutput);
|
||||||
SLOT(didStartApp(QString,QString,Ios::IosDeviceManager::OpStatus,int,Ios::DeviceSession*)));
|
connect(manager,&Ios::IosDeviceManager::errorMsg, this, &IosTool::errorMsg);
|
||||||
connect(manager,SIGNAL(deviceInfo(QString,Ios::IosDeviceManager::Dict)),
|
|
||||||
SLOT(deviceInfo(QString,Ios::IosDeviceManager::Dict)));
|
|
||||||
connect(manager,SIGNAL(appOutput(QString)), SLOT(appOutput(QString)));
|
|
||||||
connect(manager,SIGNAL(errorMsg(QString)), SLOT(errorMsg(QString)));
|
|
||||||
manager->watchDevices();
|
manager->watchDevices();
|
||||||
QRegExp qmlPortRe=QRegExp(QLatin1String("-qmljsdebugger=port:([0-9]+)"));
|
QRegExp qmlPortRe=QRegExp(QLatin1String("-qmljsdebugger=port:([0-9]+)"));
|
||||||
foreach (const QString &arg, extraArgs) {
|
foreach (const QString &arg, extraArgs) {
|
||||||
@@ -755,9 +747,10 @@ void IosTool::didStartApp(const QString &bundlePath, const QString &deviceId,
|
|||||||
// all output moves to the new thread (other option would be to signal it back)
|
// all output moves to the new thread (other option would be to signal it back)
|
||||||
QThread *gdbProcessThread = new QThread();
|
QThread *gdbProcessThread = new QThread();
|
||||||
gdbRunner->moveToThread(gdbProcessThread);
|
gdbRunner->moveToThread(gdbProcessThread);
|
||||||
QObject::connect(gdbProcessThread, SIGNAL(started()), gdbRunner, SLOT(run()));
|
QObject::connect(gdbProcessThread, &QThread::started, gdbRunner, &GdbRunner::run);
|
||||||
QObject::connect(gdbRunner, SIGNAL(finished()), gdbProcessThread, SLOT(quit()));
|
QObject::connect(gdbRunner, &GdbRunner::finished, gdbProcessThread, &QThread::quit);
|
||||||
QObject::connect(gdbProcessThread, SIGNAL(finished()), gdbProcessThread, SLOT(deleteLater()));
|
QObject::connect(gdbProcessThread, &QThread::finished,
|
||||||
|
gdbProcessThread, &QObject::deleteLater);
|
||||||
gdbProcessThread->start();
|
gdbProcessThread->start();
|
||||||
|
|
||||||
new std::thread([this]() -> void { readStdin();});
|
new std::thread([this]() -> void { readStdin();});
|
||||||
@@ -878,7 +871,7 @@ void IosTool::stopGdbRunner()
|
|||||||
{
|
{
|
||||||
if (gdbRunner) {
|
if (gdbRunner) {
|
||||||
gdbRunner->stop(0);
|
gdbRunner->stop(0);
|
||||||
QTimer::singleShot(100, this, SLOT(stopGdbRunner2()));
|
QTimer::singleShot(100, this, &IosTool::stopGdbRunner2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user