forked from qt-creator/qt-creator
Use QtcProcess directly, so external tools will start on windows too.
This commit is contained in:
@@ -42,7 +42,6 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcprocess.h>
|
|
||||||
|
|
||||||
#include <QtCore/QXmlStreamReader>
|
#include <QtCore/QXmlStreamReader>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
@@ -300,7 +299,7 @@ bool ExternalToolRunner::resolve()
|
|||||||
if (!m_tool)
|
if (!m_tool)
|
||||||
return false;
|
return false;
|
||||||
m_resolvedExecutable = QString::null;
|
m_resolvedExecutable = QString::null;
|
||||||
m_resolvedArguments.clear();
|
m_resolvedArguments = QString::null;
|
||||||
m_resolvedWorkingDirectory = QString::null;
|
m_resolvedWorkingDirectory = QString::null;
|
||||||
{ // executable
|
{ // executable
|
||||||
foreach (const QString &executable, m_tool->executables()) {
|
foreach (const QString &executable, m_tool->executables()) {
|
||||||
@@ -313,15 +312,8 @@ bool ExternalToolRunner::resolve()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
{ // arguments
|
{ // arguments
|
||||||
QString resolved = Utils::expandMacros(m_tool->arguments(),
|
m_resolvedArguments = Utils::expandMacros(m_tool->arguments(),
|
||||||
Core::VariableManager::instance()->macroExpander());
|
Core::VariableManager::instance()->macroExpander());
|
||||||
// handle quoting in the command line arguments etc
|
|
||||||
QString cmd;
|
|
||||||
Utils::QtcProcess::prepareCommand(m_resolvedExecutable, resolved,
|
|
||||||
&cmd, &m_resolvedArguments);
|
|
||||||
if (cmd.isEmpty())
|
|
||||||
return false;
|
|
||||||
m_resolvedExecutable = cmd;
|
|
||||||
}
|
}
|
||||||
{ // input
|
{ // input
|
||||||
m_resolvedInput = Utils::expandMacros(m_tool->input(),
|
m_resolvedInput = Utils::expandMacros(m_tool->input(),
|
||||||
@@ -353,7 +345,7 @@ void ExternalToolRunner::run()
|
|||||||
FileManager::instance()->expectFileChange(m_expectedFileName);
|
FileManager::instance()->expectFileChange(m_expectedFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_process = new QProcess;
|
m_process = new Utils::QtcProcess(this);
|
||||||
connect(m_process, SIGNAL(started()), this, SLOT(started()));
|
connect(m_process, SIGNAL(started()), this, SLOT(started()));
|
||||||
connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished(int,QProcess::ExitStatus)));
|
connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished(int,QProcess::ExitStatus)));
|
||||||
connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
|
connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
|
||||||
@@ -361,11 +353,14 @@ void ExternalToolRunner::run()
|
|||||||
connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));
|
connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));
|
||||||
if (!m_resolvedWorkingDirectory.isEmpty())
|
if (!m_resolvedWorkingDirectory.isEmpty())
|
||||||
m_process->setWorkingDirectory(m_resolvedWorkingDirectory);
|
m_process->setWorkingDirectory(m_resolvedWorkingDirectory);
|
||||||
|
m_process->setCommand(m_resolvedExecutable, m_resolvedArguments);
|
||||||
ICore::instance()->messageManager()->printToOutputPane(
|
ICore::instance()->messageManager()->printToOutputPane(
|
||||||
tr("Starting external tool '%1'").arg(m_resolvedExecutable), false);
|
tr("Starting external tool '%1'").arg(m_resolvedExecutable), false);
|
||||||
ICore::instance()->messageManager()->printToOutputPane(
|
if (!m_resolvedArguments.isEmpty()) {
|
||||||
tr("with arguments (%1)").arg(m_resolvedArguments.join(QLatin1String(", "))), false);
|
ICore::instance()->messageManager()->printToOutputPane(
|
||||||
m_process->start(m_resolvedExecutable, m_resolvedArguments, QIODevice::ReadWrite);
|
tr("with arguments '%1'").arg(m_resolvedArguments), false);
|
||||||
|
}
|
||||||
|
m_process->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalToolRunner::started()
|
void ExternalToolRunner::started()
|
||||||
@@ -389,7 +384,6 @@ void ExternalToolRunner::finished(int exitCode, QProcess::ExitStatus status)
|
|||||||
}
|
}
|
||||||
ICore::instance()->messageManager()->printToOutputPane(
|
ICore::instance()->messageManager()->printToOutputPane(
|
||||||
tr("'%1' finished").arg(m_resolvedExecutable), false);
|
tr("'%1' finished").arg(m_resolvedExecutable), false);
|
||||||
m_process->deleteLater();
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +394,6 @@ void ExternalToolRunner::error(QProcess::ProcessError error)
|
|||||||
FileManager::instance()->unexpectFileChange(m_expectedFileName);
|
FileManager::instance()->unexpectFileChange(m_expectedFileName);
|
||||||
}
|
}
|
||||||
// TODO inform about errors
|
// TODO inform about errors
|
||||||
m_process->deleteLater();
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
@@ -105,10 +107,10 @@ private:
|
|||||||
|
|
||||||
const ExternalTool *m_tool;
|
const ExternalTool *m_tool;
|
||||||
QString m_resolvedExecutable;
|
QString m_resolvedExecutable;
|
||||||
QStringList m_resolvedArguments;
|
QString m_resolvedArguments;
|
||||||
QString m_resolvedInput;
|
QString m_resolvedInput;
|
||||||
QString m_resolvedWorkingDirectory;
|
QString m_resolvedWorkingDirectory;
|
||||||
QProcess *m_process;
|
Utils::QtcProcess *m_process;
|
||||||
QTextCodec *m_outputCodec;
|
QTextCodec *m_outputCodec;
|
||||||
QTextCodec::ConverterState m_outputCodecState;
|
QTextCodec::ConverterState m_outputCodecState;
|
||||||
QTextCodec::ConverterState m_errorCodecState;
|
QTextCodec::ConverterState m_errorCodecState;
|
||||||
|
Reference in New Issue
Block a user