forked from qt-creator/qt-creator
Qnx: Check device connection when debugging
Move the device connection verification code from BlackBerryRunControl class into BlackBerryApplicaitonRunner class. This will setup a device connection if the device is not connected when starting debugger. Task-number: QTCREATORBUG-10309 Change-Id: I57db0e60039bb05f8467e925e71cf710a0712791 Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com> Reviewed-by: Tobias Nätterlund <tobias.naetterlund@kdab.com>
This commit is contained in:
committed by
Mehdi Fekari
parent
0b8f3c3e9d
commit
01c8e98d0b
@@ -32,6 +32,7 @@
|
||||
#include "blackberryapplicationrunner.h"
|
||||
|
||||
#include "blackberrydeployconfiguration.h"
|
||||
#include "blackberrydeviceconnectionmanager.h"
|
||||
#include "blackberryrunconfiguration.h"
|
||||
#include "blackberrylogprocessrunner.h"
|
||||
#include "qnxconstants.h"
|
||||
@@ -94,28 +95,17 @@ BlackBerryApplicationRunner::BlackBerryApplicationRunner(bool debugMode, BlackBe
|
||||
|
||||
void BlackBerryApplicationRunner::start()
|
||||
{
|
||||
QStringList args;
|
||||
args << QLatin1String("-launchApp");
|
||||
if (m_debugMode)
|
||||
args << QLatin1String("-debugNative");
|
||||
args << QLatin1String("-device") << m_sshParams.host;
|
||||
if (!m_sshParams.password.isEmpty())
|
||||
args << QLatin1String("-password") << m_sshParams.password;
|
||||
args << QDir::toNativeSeparators(m_barPackage);
|
||||
|
||||
if (!m_launchProcess) {
|
||||
m_launchProcess = new QProcess(this);
|
||||
connect(m_launchProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));
|
||||
connect(m_launchProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput()));
|
||||
connect(m_launchProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
|
||||
this, SLOT(startFinished(int,QProcess::ExitStatus)));
|
||||
|
||||
m_launchProcess->setEnvironment(m_environment.toStringList());
|
||||
if (!BlackBerryDeviceConnectionManager::instance()->isConnected(m_device->id())) {
|
||||
connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceConnected()),
|
||||
this, SLOT(launchApplication()));
|
||||
connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceDisconnected(Core::Id)),
|
||||
this, SLOT(disconnectFromDeviceSignals(Core::Id)));
|
||||
connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id,QString)),
|
||||
this, SLOT(displayConnectionOutput(Core::Id,QString)));
|
||||
BlackBerryDeviceConnectionManager::instance()->connectDevice(m_device->id());
|
||||
} else {
|
||||
launchApplication();
|
||||
}
|
||||
|
||||
m_launchProcess->start(m_deployCmd, args);
|
||||
m_runningStateTimer->start();
|
||||
m_running = true;
|
||||
}
|
||||
|
||||
void BlackBerryApplicationRunner::startLogProcessRunner()
|
||||
@@ -130,6 +120,17 @@ void BlackBerryApplicationRunner::startLogProcessRunner()
|
||||
m_logProcessRunner->start();
|
||||
}
|
||||
|
||||
void BlackBerryApplicationRunner::displayConnectionOutput(Core::Id deviceId, const QString &msg)
|
||||
{
|
||||
if (deviceId != m_device->id())
|
||||
return;
|
||||
|
||||
if (msg.contains(QLatin1String("Info:")))
|
||||
emit output(msg, Utils::StdOutFormat);
|
||||
else if (msg.contains(QLatin1String("Error:")))
|
||||
emit output(msg, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void BlackBerryApplicationRunner::startFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
if (exitCode == 0 && exitStatus == QProcess::NormalExit && m_pid > -1) {
|
||||
@@ -214,6 +215,18 @@ void BlackBerryApplicationRunner::readStandardError()
|
||||
}
|
||||
}
|
||||
|
||||
void BlackBerryApplicationRunner::disconnectFromDeviceSignals(Core::Id deviceId)
|
||||
{
|
||||
if (m_device->id() == deviceId) {
|
||||
disconnect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceConnected()),
|
||||
this, SLOT(launchApplication()));
|
||||
disconnect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceDisconnected(Core::Id)),
|
||||
this, SLOT(disconnectFromDeviceSignals(Core::Id)));
|
||||
disconnect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id,QString)),
|
||||
this, SLOT(displayConnectionOutput(Core::Id,QString)));
|
||||
}
|
||||
}
|
||||
|
||||
void BlackBerryApplicationRunner::setPid(qint64 pid)
|
||||
{
|
||||
m_pid = pid;
|
||||
@@ -224,6 +237,37 @@ void BlackBerryApplicationRunner::setApplicationId(const QString &applicationId)
|
||||
m_appId = applicationId;
|
||||
}
|
||||
|
||||
void BlackBerryApplicationRunner::launchApplication()
|
||||
{
|
||||
// If original device connection fails before launching, this method maybe triggered
|
||||
// if any other device is connected(?)
|
||||
if (!BlackBerryDeviceConnectionManager::instance()->isConnected(m_device->id()))
|
||||
return;
|
||||
|
||||
QStringList args;
|
||||
args << QLatin1String("-launchApp");
|
||||
if (m_debugMode)
|
||||
args << QLatin1String("-debugNative");
|
||||
args << QLatin1String("-device") << m_sshParams.host;
|
||||
if (!m_sshParams.password.isEmpty())
|
||||
args << QLatin1String("-password") << m_sshParams.password;
|
||||
args << QDir::toNativeSeparators(m_barPackage);
|
||||
|
||||
if (!m_launchProcess) {
|
||||
m_launchProcess = new QProcess(this);
|
||||
connect(m_launchProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));
|
||||
connect(m_launchProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput()));
|
||||
connect(m_launchProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
|
||||
this, SLOT(startFinished(int,QProcess::ExitStatus)));
|
||||
|
||||
m_launchProcess->setEnvironment(m_environment.toStringList());
|
||||
}
|
||||
|
||||
m_launchProcess->start(m_deployCmd, args);
|
||||
m_runningStateTimer->start();
|
||||
m_running = true;
|
||||
}
|
||||
|
||||
void BlackBerryApplicationRunner::startRunningStateTimer()
|
||||
{
|
||||
if (m_running)
|
||||
|
||||
@@ -82,6 +82,7 @@ private slots:
|
||||
void readStandardOutput();
|
||||
void readStandardError();
|
||||
|
||||
void disconnectFromDeviceSignals(Core::Id deviceId);
|
||||
void startRunningStateTimer();
|
||||
void determineRunningState();
|
||||
void readRunningStateStandardOutput();
|
||||
@@ -89,8 +90,11 @@ private slots:
|
||||
void setPid(qint64 pid);
|
||||
void setApplicationId(const QString &applicationId);
|
||||
|
||||
void launchApplication();
|
||||
void startLogProcessRunner();
|
||||
|
||||
void displayConnectionOutput(Core::Id deviceId, const QString &output);
|
||||
|
||||
private:
|
||||
void reset();
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ BlackBerryDebugSupport::BlackBerryDebugSupport(BlackBerryRunConfiguration *runCo
|
||||
this, SLOT(handleDebuggerStateChanged(Debugger::DebuggerState)));
|
||||
|
||||
connect(m_runner, SIGNAL(started()), this, SLOT(handleStarted()));
|
||||
connect(m_runner, SIGNAL(started()), m_runner, SLOT(checkSlog2Info()));
|
||||
connect(m_runner, SIGNAL(startFailed(QString)), this, SLOT(handleStartFailed(QString)));
|
||||
connect(m_runner, SIGNAL(started()), m_runner, SLOT(checkSlog2Info()));
|
||||
connect(m_runner, SIGNAL(output(QString,Utils::OutputFormat)),
|
||||
this, SLOT(handleApplicationOutput(QString,Utils::OutputFormat)));
|
||||
|
||||
|
||||
@@ -278,9 +278,11 @@ void BlackBerryDeviceConnectionManager::handleDeviceDisconnected()
|
||||
QTC_ASSERT(connection, return);
|
||||
|
||||
QList<Core::Id> disconnectedDevices = m_connections.values(connection);
|
||||
foreach (Core::Id id, disconnectedDevices)
|
||||
foreach (Core::Id id, disconnectedDevices) {
|
||||
ProjectExplorer::DeviceManager::instance()->setDeviceState(id,
|
||||
ProjectExplorer::IDevice::DeviceDisconnected);
|
||||
emit deviceDisconnected(id);
|
||||
}
|
||||
}
|
||||
|
||||
void BlackBerryDeviceConnectionManager::handleDeviceAboutToConnect()
|
||||
|
||||
@@ -69,6 +69,7 @@ signals:
|
||||
void connectionOutput(Core::Id deviceId, const QString &output);
|
||||
void deviceAboutToConnect(Core::Id deviceId);
|
||||
void deviceConnected();
|
||||
void deviceDisconnected(Core::Id deviceId);
|
||||
|
||||
public slots:
|
||||
void connectDevice(Core::Id deviceId);
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include "blackberryrunconfiguration.h"
|
||||
#include "blackberrydeviceconnectionmanager.h"
|
||||
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QTimer>
|
||||
|
||||
@@ -45,7 +43,6 @@ using namespace Qnx::Internal;
|
||||
BlackBerryRunControl::BlackBerryRunControl(BlackBerryRunConfiguration *runConfiguration)
|
||||
: ProjectExplorer::RunControl(runConfiguration, ProjectExplorer::NormalRunMode)
|
||||
{
|
||||
m_device = BlackBerryDeviceConfiguration::device(runConfiguration->target()->kit());
|
||||
m_runner = new BlackBerryApplicationRunner(false, runConfiguration, this);
|
||||
|
||||
connect(m_runner, SIGNAL(started()), this, SIGNAL(started()));
|
||||
@@ -57,7 +54,7 @@ BlackBerryRunControl::BlackBerryRunControl(BlackBerryRunConfiguration *runConfig
|
||||
|
||||
void BlackBerryRunControl::start()
|
||||
{
|
||||
checkDeviceConnection();
|
||||
m_runner->start();
|
||||
}
|
||||
|
||||
ProjectExplorer::RunControl::StopResult BlackBerryRunControl::stop()
|
||||
@@ -79,32 +76,3 @@ void BlackBerryRunControl::handleStartFailed(const QString &message)
|
||||
{
|
||||
appendMessage(message, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void BlackBerryRunControl::handleDeviceConnected()
|
||||
{
|
||||
m_runner->start();
|
||||
}
|
||||
|
||||
void BlackBerryRunControl::displayConnectionOutput(Core::Id deviceId, const QString &output)
|
||||
{
|
||||
if (deviceId != m_device->id())
|
||||
return;
|
||||
|
||||
if (output.contains(QLatin1String("Info:")))
|
||||
appendMessage(output, Utils::StdOutFormat);
|
||||
else if (output.contains(QLatin1String("Error:")))
|
||||
appendMessage(output, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void BlackBerryRunControl::checkDeviceConnection()
|
||||
{
|
||||
if (!BlackBerryDeviceConnectionManager::instance()->isConnected(m_device->id())) {
|
||||
connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceConnected()),
|
||||
this, SLOT(handleDeviceConnected()));
|
||||
connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id,QString)),
|
||||
this, SLOT(displayConnectionOutput(Core::Id,QString)));
|
||||
BlackBerryDeviceConnectionManager::instance()->connectDevice(m_device->id());
|
||||
} else {
|
||||
m_runner->start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#ifndef QNX_INTERNAL_BLACKBERRYRUNCONTROL_H
|
||||
#define QNX_INTERNAL_BLACKBERRYRUNCONTROL_H
|
||||
|
||||
#include "blackberrydeviceconfiguration.h"
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
@@ -60,13 +58,9 @@ public:
|
||||
|
||||
private slots:
|
||||
void handleStartFailed(const QString &message);
|
||||
void handleDeviceConnected();
|
||||
void displayConnectionOutput(Core::Id deviceId, const QString &output);
|
||||
void checkDeviceConnection();
|
||||
|
||||
private:
|
||||
BlackBerryApplicationRunner *m_runner;
|
||||
BlackBerryDeviceConfiguration::ConstPtr m_device;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user