forked from qt-creator/qt-creator
Fix broken env reader, it did not reread on device changes.
Reviewed-by: ck
This commit is contained in:
@@ -47,7 +47,10 @@ MaemoDeviceEnvReader::MaemoDeviceEnvReader(QObject *parent, MaemoRunConfiguratio
|
|||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_stop(false)
|
, m_stop(false)
|
||||||
, m_devConfig(config->deviceConfig())
|
, m_devConfig(config->deviceConfig())
|
||||||
|
, m_runConfig(config)
|
||||||
{
|
{
|
||||||
|
connect(config, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
|
||||||
|
this, SLOT(handleCurrentDeviceConfigChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaemoDeviceEnvReader::~MaemoDeviceEnvReader()
|
MaemoDeviceEnvReader::~MaemoDeviceEnvReader()
|
||||||
@@ -59,11 +62,11 @@ void MaemoDeviceEnvReader::start()
|
|||||||
m_stop = false;
|
m_stop = false;
|
||||||
if (m_connection)
|
if (m_connection)
|
||||||
disconnect(m_connection.data(), 0, this, 0);
|
disconnect(m_connection.data(), 0, this, 0);
|
||||||
|
|
||||||
const bool reuse = m_connection
|
const bool reuse = m_connection
|
||||||
&& m_connection->state() == Core::SshConnection::Connected
|
&& m_connection->state() == Core::SshConnection::Connected
|
||||||
&& m_connection->connectionParameters() == m_devConfig.server;
|
&& m_connection->connectionParameters() == m_devConfig.server;
|
||||||
|
|
||||||
if (!reuse)
|
if (!reuse)
|
||||||
m_connection = Core::SshConnection::create();
|
m_connection = Core::SshConnection::create();
|
||||||
|
|
||||||
@@ -71,7 +74,7 @@ void MaemoDeviceEnvReader::start()
|
|||||||
SLOT(executeRemoteCall()));
|
SLOT(executeRemoteCall()));
|
||||||
connect(m_connection.data(), SIGNAL(error(SshError)), this,
|
connect(m_connection.data(), SIGNAL(error(SshError)), this,
|
||||||
SLOT(handleConnectionFailure()));
|
SLOT(handleConnectionFailure()));
|
||||||
|
|
||||||
if (reuse)
|
if (reuse)
|
||||||
executeRemoteCall();
|
executeRemoteCall();
|
||||||
else
|
else
|
||||||
@@ -89,20 +92,13 @@ void MaemoDeviceEnvReader::stop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoDeviceEnvReader::setEnvironment()
|
|
||||||
{
|
|
||||||
if (m_remoteOutput.isEmpty())
|
|
||||||
return;
|
|
||||||
m_env = Utils::Environment(m_remoteOutput.split(QLatin1Char('\n'),
|
|
||||||
QString::SkipEmptyParts));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoDeviceEnvReader::executeRemoteCall()
|
void MaemoDeviceEnvReader::executeRemoteCall()
|
||||||
{
|
{
|
||||||
if (m_stop)
|
if (m_stop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QByteArray remoteCall = MaemoGlobal::remoteSourceProfilesCommand().toUtf8() + "; env";
|
const QByteArray remoteCall = MaemoGlobal::remoteSourceProfilesCommand()
|
||||||
|
.toUtf8() + "; env";
|
||||||
m_remoteProcess = m_connection->createRemoteProcess(remoteCall);
|
m_remoteProcess = m_connection->createRemoteProcess(remoteCall);
|
||||||
|
|
||||||
connect(m_remoteProcess.data(), SIGNAL(closed(int)), this,
|
connect(m_remoteProcess.data(), SIGNAL(closed(int)), this,
|
||||||
@@ -123,6 +119,14 @@ void MaemoDeviceEnvReader::handleConnectionFailure()
|
|||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaemoDeviceEnvReader::handleCurrentDeviceConfigChanged()
|
||||||
|
{
|
||||||
|
m_devConfig = m_runConfig->deviceConfig();
|
||||||
|
|
||||||
|
m_env.clear();
|
||||||
|
emit finished();
|
||||||
|
}
|
||||||
|
|
||||||
void MaemoDeviceEnvReader::remoteProcessFinished(int exitCode)
|
void MaemoDeviceEnvReader::remoteProcessFinished(int exitCode)
|
||||||
{
|
{
|
||||||
Q_ASSERT(exitCode == Core::SshRemoteProcess::FailedToStart
|
Q_ASSERT(exitCode == Core::SshRemoteProcess::FailedToStart
|
||||||
@@ -132,8 +136,12 @@ void MaemoDeviceEnvReader::remoteProcessFinished(int exitCode)
|
|||||||
if (m_stop)
|
if (m_stop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_env.clear();
|
||||||
if (exitCode == Core::SshRemoteProcess::ExitedNormally) {
|
if (exitCode == Core::SshRemoteProcess::ExitedNormally) {
|
||||||
setEnvironment();
|
if (!m_remoteOutput.isEmpty()) {
|
||||||
|
m_env = Utils::Environment(m_remoteOutput.split(QLatin1Char('\n'),
|
||||||
|
QString::SkipEmptyParts));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
emit error(tr("Error running remote process: %1")
|
emit error(tr("Error running remote process: %1")
|
||||||
.arg(m_remoteProcess->errorString()));
|
.arg(m_remoteProcess->errorString()));
|
||||||
|
|||||||
@@ -67,12 +67,10 @@ signals:
|
|||||||
void finished();
|
void finished();
|
||||||
void error(const QString &error);
|
void error(const QString &error);
|
||||||
|
|
||||||
private:
|
|
||||||
void setEnvironment();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void executeRemoteCall();
|
void executeRemoteCall();
|
||||||
void handleConnectionFailure();
|
void handleConnectionFailure();
|
||||||
|
void handleCurrentDeviceConfigChanged();
|
||||||
|
|
||||||
void remoteProcessFinished(int exitCode);
|
void remoteProcessFinished(int exitCode);
|
||||||
void remoteOutput(const QByteArray &data);
|
void remoteOutput(const QByteArray &data);
|
||||||
@@ -83,6 +81,7 @@ private:
|
|||||||
QString m_remoteOutput;
|
QString m_remoteOutput;
|
||||||
Utils::Environment m_env;
|
Utils::Environment m_env;
|
||||||
MaemoDeviceConfig m_devConfig;
|
MaemoDeviceConfig m_devConfig;
|
||||||
|
MaemoRunConfiguration *m_runConfig;
|
||||||
QSharedPointer<Core::SshConnection> m_connection;
|
QSharedPointer<Core::SshConnection> m_connection;
|
||||||
QSharedPointer<Core::SshRemoteProcess> m_remoteProcess;
|
QSharedPointer<Core::SshRemoteProcess> m_remoteProcess;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user