forked from qt-creator/qt-creator
Utils: Move QProcess base to QtcProcessPrivate
Change-Id: I4c6811d42e051fadfcf32edb664ff3bc09e692e6 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -212,7 +212,7 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest)
|
|||||||
archive->m_process->setProcessChannelMode(QProcess::MergedChannels);
|
archive->m_process->setProcessChannelMode(QProcess::MergedChannels);
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
archive->m_process,
|
archive->m_process,
|
||||||
&QProcess::readyReadStandardOutput,
|
&QtcProcess::readyReadStandardOutput,
|
||||||
archive,
|
archive,
|
||||||
[archive]() {
|
[archive]() {
|
||||||
if (!archive->m_process)
|
if (!archive->m_process)
|
||||||
@@ -222,7 +222,7 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest)
|
|||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
archive->m_process,
|
archive->m_process,
|
||||||
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
&QtcProcess::finished,
|
||||||
archive,
|
archive,
|
||||||
[archive](int, QProcess::ExitStatus) {
|
[archive](int, QProcess::ExitStatus) {
|
||||||
if (!archive->m_process)
|
if (!archive->m_process)
|
||||||
@@ -236,7 +236,7 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest)
|
|||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
archive->m_process,
|
archive->m_process,
|
||||||
&QProcess::errorOccurred,
|
&QtcProcess::errorOccurred,
|
||||||
archive,
|
archive,
|
||||||
[archive](QProcess::ProcessError) {
|
[archive](QProcess::ProcessError) {
|
||||||
if (!archive->m_process)
|
if (!archive->m_process)
|
||||||
@@ -248,22 +248,18 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest)
|
|||||||
archive->deleteLater();
|
archive->deleteLater();
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
QTimer::singleShot(0, archive, [archive, tool, workingDirectory] {
|
QTimer::singleShot(0, archive, [archive, tool, workingDirectory] {
|
||||||
archive->outputReceived(
|
archive->outputReceived(
|
||||||
tr("Running %1\nin \"%2\".\n\n", "Running <cmd> in <workingdirectory>")
|
tr("Running %1\nin \"%2\".\n\n", "Running <cmd> in <workingdirectory>")
|
||||||
.arg(CommandLine(tool->executable, tool->arguments).toUserOutput(),
|
.arg(CommandLine(tool->executable, tool->arguments).toUserOutput(),
|
||||||
workingDirectory));
|
workingDirectory));
|
||||||
});
|
});
|
||||||
archive->m_process->setProgram(tool->executable);
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
CommandLine cmd = tool->nativeWindowsArguments
|
||||||
if (!tool->nativeWindowsArguments)
|
? CommandLine{FilePath::fromString(tool->executable), tool->arguments[0], CommandLine::Raw}
|
||||||
archive->m_process->setArguments(tool->arguments);
|
: CommandLine{tool->executable, tool->arguments};
|
||||||
else if (!tool->arguments.isEmpty())
|
archive->m_process->setCommand(cmd);
|
||||||
archive->m_process->setNativeArguments(tool->arguments.at(0));
|
|
||||||
#else
|
|
||||||
archive->m_process->setArguments(tool->arguments);
|
|
||||||
#endif
|
|
||||||
archive->m_process->setWorkingDirectory(workingDirectory);
|
archive->m_process->setWorkingDirectory(workingDirectory);
|
||||||
archive->m_process->setOpenMode(QProcess::ReadOnly);
|
archive->m_process->setOpenMode(QProcess::ReadOnly);
|
||||||
archive->m_process->start();
|
archive->m_process->start();
|
||||||
|
@@ -82,7 +82,7 @@ public:
|
|||||||
void clearForRun();
|
void clearForRun();
|
||||||
|
|
||||||
QString linesRead();
|
QString linesRead();
|
||||||
void append(const QByteArray &text, bool emitSignals);
|
void append(const QByteArray &text);
|
||||||
|
|
||||||
QByteArray rawData;
|
QByteArray rawData;
|
||||||
QString incompleteLineBuffer; // lines not yet signaled
|
QString incompleteLineBuffer; // lines not yet signaled
|
||||||
@@ -92,20 +92,88 @@ public:
|
|||||||
std::function<void(const QString &lines)> outputCallback;
|
std::function<void(const QString &lines)> outputCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ProcessHelper : public QProcess
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProcessHelper()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_UNIX)
|
||||||
|
setChildProcessModifier([this] { d->setupChildProcess_impl(); });
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
void setupChildProcess() override { setupChildProcess_impl(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void setupChildProcess_impl()
|
||||||
|
{
|
||||||
|
#if defined Q_OS_UNIX
|
||||||
|
// nice value range is -20 to +19 where -20 is highest, 0 default and +19 is lowest
|
||||||
|
if (m_lowPriority) {
|
||||||
|
errno = 0;
|
||||||
|
if (::nice(5) == -1 && errno != 0)
|
||||||
|
perror("Failed to set nice value");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable terminal by becoming a session leader.
|
||||||
|
if (m_disableUnixTerminal)
|
||||||
|
setsid();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
using QProcess::setErrorString;
|
||||||
|
|
||||||
|
bool m_lowPriority = false;
|
||||||
|
bool m_disableUnixTerminal = false;
|
||||||
|
};
|
||||||
|
|
||||||
class QtcProcessPrivate : public QObject
|
class QtcProcessPrivate : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit QtcProcessPrivate(QtcProcess *parent) : q(parent) {}
|
explicit QtcProcessPrivate(QtcProcess *parent)
|
||||||
|
: q(parent), m_process(new ProcessHelper)
|
||||||
|
{
|
||||||
|
connect(m_process, &QProcess::started,
|
||||||
|
q, &QtcProcess::started);
|
||||||
|
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||||
|
q, &QtcProcess::finished);
|
||||||
|
connect(m_process, &QProcess::errorOccurred,
|
||||||
|
q, &QtcProcess::errorOccurred);
|
||||||
|
connect(m_process, &QProcess::stateChanged,
|
||||||
|
q, &QtcProcess::stateChanged);
|
||||||
|
connect(m_process, &QProcess::readyReadStandardOutput,
|
||||||
|
this, &QtcProcessPrivate::handleReadyReadStandardOutput);
|
||||||
|
connect(m_process, &QProcess::readyReadStandardError,
|
||||||
|
this, &QtcProcessPrivate::handleReadyReadStandardError);
|
||||||
|
}
|
||||||
|
|
||||||
void setupChildProcess_impl();
|
~QtcProcessPrivate()
|
||||||
|
{
|
||||||
|
delete m_process;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleReadyReadStandardOutput()
|
||||||
|
{
|
||||||
|
m_stdOut.append(m_process->readAllStandardOutput());
|
||||||
|
m_hangTimerCount = 0;
|
||||||
|
emit q->readyReadStandardOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleReadyReadStandardError()
|
||||||
|
{
|
||||||
|
m_stdErr.append(m_process->readAllStandardError());
|
||||||
|
m_hangTimerCount = 0;
|
||||||
|
emit q->readyReadStandardOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
QtcProcess *q;
|
||||||
|
ProcessHelper *m_process;
|
||||||
CommandLine m_commandLine;
|
CommandLine m_commandLine;
|
||||||
Environment m_environment;
|
Environment m_environment;
|
||||||
QByteArray m_writeData;
|
QByteArray m_writeData;
|
||||||
bool m_haveEnv = false;
|
bool m_haveEnv = false;
|
||||||
bool m_useCtrlCStub = false;
|
bool m_useCtrlCStub = false;
|
||||||
bool m_lowPriority = false;
|
|
||||||
bool m_disableUnixTerminal = false;
|
|
||||||
|
|
||||||
QProcess::OpenMode m_openMode = QProcess::ReadWrite;
|
QProcess::OpenMode m_openMode = QProcess::ReadWrite;
|
||||||
|
|
||||||
@@ -117,7 +185,6 @@ public:
|
|||||||
|
|
||||||
QtcProcess::Result interpretExitCode(int exitCode);
|
QtcProcess::Result interpretExitCode(int exitCode);
|
||||||
|
|
||||||
QtcProcess *q;
|
|
||||||
QTextCodec *m_codec = QTextCodec::codecForLocale();
|
QTextCodec *m_codec = QTextCodec::codecForLocale();
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
QEventLoop m_eventLoop;
|
QEventLoop m_eventLoop;
|
||||||
@@ -170,16 +237,12 @@ QtcProcess::Result QtcProcessPrivate::interpretExitCode(int exitCode)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
QtcProcess::QtcProcess(QObject *parent)
|
QtcProcess::QtcProcess(QObject *parent)
|
||||||
: QProcess(parent), d(new QtcProcessPrivate(this))
|
: QObject(parent), d(new QtcProcessPrivate(this))
|
||||||
{
|
{
|
||||||
static int qProcessExitStatusMeta = qRegisterMetaType<QProcess::ExitStatus>();
|
static int qProcessExitStatusMeta = qRegisterMetaType<QProcess::ExitStatus>();
|
||||||
static int qProcessProcessErrorMeta = qRegisterMetaType<QProcess::ProcessError>();
|
static int qProcessProcessErrorMeta = qRegisterMetaType<QProcess::ProcessError>();
|
||||||
Q_UNUSED(qProcessExitStatusMeta)
|
Q_UNUSED(qProcessExitStatusMeta)
|
||||||
Q_UNUSED(qProcessProcessErrorMeta)
|
Q_UNUSED(qProcessProcessErrorMeta)
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_UNIX)
|
|
||||||
setChildProcessModifier([this] { d->setupChildProcess_impl(); });
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QtcProcess::~QtcProcess()
|
QtcProcess::~QtcProcess()
|
||||||
@@ -208,6 +271,16 @@ const CommandLine &QtcProcess::commandLine() const
|
|||||||
return d->m_commandLine;
|
return d->m_commandLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QtcProcess::workingDirectory() const
|
||||||
|
{
|
||||||
|
return d->m_process->workingDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtcProcess::setWorkingDirectory(const QString &dir)
|
||||||
|
{
|
||||||
|
d->m_process->setWorkingDirectory(dir);
|
||||||
|
}
|
||||||
|
|
||||||
void QtcProcess::setUseCtrlCStub(bool enabled)
|
void QtcProcess::setUseCtrlCStub(bool enabled)
|
||||||
{
|
{
|
||||||
// Do not use the stub in debug mode. Activating the stub will shut down
|
// Do not use the stub in debug mode. Activating the stub will shut down
|
||||||
@@ -244,7 +317,7 @@ void QtcProcess::start()
|
|||||||
qPrintable(d->m_commandLine.executable().toString()));
|
qPrintable(d->m_commandLine.executable().toString()));
|
||||||
env = d->m_environment;
|
env = d->m_environment;
|
||||||
|
|
||||||
QProcess::setProcessEnvironment(env.toProcessEnvironment());
|
d->m_process->setProcessEnvironment(env.toProcessEnvironment());
|
||||||
} else {
|
} else {
|
||||||
env = Environment::systemEnvironment();
|
env = Environment::systemEnvironment();
|
||||||
}
|
}
|
||||||
@@ -258,25 +331,26 @@ void QtcProcess::start()
|
|||||||
if (osType == OsTypeWindows) {
|
if (osType == OsTypeWindows) {
|
||||||
QString args;
|
QString args;
|
||||||
if (d->m_useCtrlCStub) {
|
if (d->m_useCtrlCStub) {
|
||||||
if (d->m_lowPriority)
|
if (d->m_process->m_lowPriority)
|
||||||
ProcessArgs::addArg(&args, "-nice");
|
ProcessArgs::addArg(&args, "-nice");
|
||||||
ProcessArgs::addArg(&args, QDir::toNativeSeparators(command));
|
ProcessArgs::addArg(&args, QDir::toNativeSeparators(command));
|
||||||
command = QCoreApplication::applicationDirPath()
|
command = QCoreApplication::applicationDirPath()
|
||||||
+ QLatin1String("/qtcreator_ctrlc_stub.exe");
|
+ QLatin1String("/qtcreator_ctrlc_stub.exe");
|
||||||
} else if (d->m_lowPriority) {
|
} else if (d->m_process->m_lowPriority) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
setCreateProcessArgumentsModifier([](CreateProcessArguments *args) {
|
d->m_process->setCreateProcessArgumentsModifier(
|
||||||
|
[](QProcess::CreateProcessArguments *args) {
|
||||||
args->flags |= BELOW_NORMAL_PRIORITY_CLASS;
|
args->flags |= BELOW_NORMAL_PRIORITY_CLASS;
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ProcessArgs::addArgs(&args, arguments.toWindowsArgs());
|
ProcessArgs::addArgs(&args, arguments.toWindowsArgs());
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
setNativeArguments(args);
|
d->m_process->setNativeArguments(args);
|
||||||
#endif
|
#endif
|
||||||
// Note: Arguments set with setNativeArgs will be appended to the ones
|
// Note: Arguments set with setNativeArgs will be appended to the ones
|
||||||
// passed with start() below.
|
// passed with start() below.
|
||||||
QProcess::start(command, QStringList(), d->m_openMode);
|
d->m_process->start(command, QStringList(), d->m_openMode);
|
||||||
} else {
|
} else {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
setErrorString(tr("Error in command line."));
|
setErrorString(tr("Error in command line."));
|
||||||
@@ -285,7 +359,7 @@ void QtcProcess::start()
|
|||||||
emit errorOccurred(QProcess::UnknownError);
|
emit errorOccurred(QProcess::UnknownError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QProcess::start(command, arguments.toUnixArgs(), d->m_openMode);
|
d->m_process->start(command, arguments.toUnixArgs(), d->m_openMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +395,7 @@ void QtcProcess::terminate()
|
|||||||
EnumWindows(sendShutDownMessageToAllWindowsOfProcess_enumWnd, processId());
|
EnumWindows(sendShutDownMessageToAllWindowsOfProcess_enumWnd, processId());
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
QProcess::terminate();
|
d->m_process->terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtcProcess::interrupt()
|
void QtcProcess::interrupt()
|
||||||
@@ -334,12 +408,12 @@ void QtcProcess::interrupt()
|
|||||||
|
|
||||||
void QtcProcess::setLowPriority()
|
void QtcProcess::setLowPriority()
|
||||||
{
|
{
|
||||||
d->m_lowPriority = true;
|
d->m_process->m_lowPriority = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtcProcess::setDisableUnixTerminal()
|
void QtcProcess::setDisableUnixTerminal()
|
||||||
{
|
{
|
||||||
d->m_disableUnixTerminal = true;
|
d->m_process->m_disableUnixTerminal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtcProcess::setRemoteProcessHooks(const DeviceProcessHooks &hooks)
|
void QtcProcess::setRemoteProcessHooks(const DeviceProcessHooks &hooks)
|
||||||
@@ -347,30 +421,7 @@ void QtcProcess::setRemoteProcessHooks(const DeviceProcessHooks &hooks)
|
|||||||
s_deviceHooks = hooks;
|
s_deviceHooks = hooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
void QtcProcess::setOpenMode(QIODevice::OpenMode mode)
|
||||||
void QtcProcess::setupChildProcess()
|
|
||||||
{
|
|
||||||
d->setupChildProcess_impl();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void QtcProcessPrivate::setupChildProcess_impl()
|
|
||||||
{
|
|
||||||
#if defined Q_OS_UNIX
|
|
||||||
// nice value range is -20 to +19 where -20 is highest, 0 default and +19 is lowest
|
|
||||||
if (m_lowPriority) {
|
|
||||||
errno = 0;
|
|
||||||
if (::nice(5) == -1 && errno != 0)
|
|
||||||
perror("Failed to set nice value");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable terminal by becoming a session leader.
|
|
||||||
if (m_disableUnixTerminal)
|
|
||||||
setsid();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtcProcess::setOpenMode(OpenMode mode)
|
|
||||||
{
|
{
|
||||||
d->m_openMode = mode;
|
d->m_openMode = mode;
|
||||||
}
|
}
|
||||||
@@ -429,7 +480,7 @@ bool QtcProcess::readDataFromProcess(int timeoutS,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTC_ASSERT(readChannel() == QProcess::StandardOutput, return false);
|
QTC_ASSERT(d->m_process->readChannel() == QProcess::StandardOutput, return false);
|
||||||
|
|
||||||
// Keep the process running until it has no longer has data
|
// Keep the process running until it has no longer has data
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
@@ -438,15 +489,15 @@ bool QtcProcess::readDataFromProcess(int timeoutS,
|
|||||||
finished = waitForFinished(timeoutS > 0 ? timeoutS * 1000 : -1)
|
finished = waitForFinished(timeoutS > 0 ? timeoutS * 1000 : -1)
|
||||||
|| state() == QProcess::NotRunning;
|
|| state() == QProcess::NotRunning;
|
||||||
// First check 'stdout'
|
// First check 'stdout'
|
||||||
if (bytesAvailable()) { // applies to readChannel() only
|
if (d->m_process->bytesAvailable()) { // applies to readChannel() only
|
||||||
hasData = true;
|
hasData = true;
|
||||||
const QByteArray newStdOut = readAllStandardOutput();
|
const QByteArray newStdOut = d->m_process->readAllStandardOutput();
|
||||||
if (stdOut)
|
if (stdOut)
|
||||||
stdOut->append(newStdOut);
|
stdOut->append(newStdOut);
|
||||||
}
|
}
|
||||||
// Check 'stderr' separately. This is a special handling
|
// Check 'stderr' separately. This is a special handling
|
||||||
// for 'git pull' and the like which prints its progress on stderr.
|
// for 'git pull' and the like which prints its progress on stderr.
|
||||||
const QByteArray newStdErr = readAllStandardError();
|
const QByteArray newStdErr = d->m_process->readAllStandardError();
|
||||||
if (!newStdErr.isEmpty()) {
|
if (!newStdErr.isEmpty()) {
|
||||||
hasData = true;
|
hasData = true;
|
||||||
if (stdErr)
|
if (stdErr)
|
||||||
@@ -454,7 +505,7 @@ bool QtcProcess::readDataFromProcess(int timeoutS,
|
|||||||
}
|
}
|
||||||
// Prompt user, pretend we have data if says 'No'.
|
// Prompt user, pretend we have data if says 'No'.
|
||||||
const bool hang = !hasData && !finished;
|
const bool hang = !hasData && !finished;
|
||||||
hasData = hang && showTimeOutMessageBox && !askToKill(program());
|
hasData = hang && showTimeOutMessageBox && !askToKill(d->m_process->program());
|
||||||
} while (hasData && !finished);
|
} while (hasData && !finished);
|
||||||
if (syncDebug)
|
if (syncDebug)
|
||||||
qDebug() << "<readDataFromProcess" << finished;
|
qDebug() << "<readDataFromProcess" << finished;
|
||||||
@@ -484,7 +535,7 @@ void QtcProcess::setResult(Result result)
|
|||||||
|
|
||||||
int QtcProcess::exitCode() const
|
int QtcProcess::exitCode() const
|
||||||
{
|
{
|
||||||
return d->m_isSynchronousProcess ? d->m_exitCode : QProcess::exitCode(); // FIXME: Unify.
|
return d->m_isSynchronousProcess ? d->m_exitCode : d->m_process->exitCode(); // FIXME: Unify.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -577,6 +628,115 @@ Environment QtcProcess::systemEnvironmentForBinary(const FilePath &filePath)
|
|||||||
return Environment::systemEnvironment();
|
return Environment::systemEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtcProcess::setProcessChannelMode(QProcess::ProcessChannelMode mode)
|
||||||
|
{
|
||||||
|
d->m_process->setProcessChannelMode(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess::ProcessError QtcProcess::error() const
|
||||||
|
{
|
||||||
|
return d->m_process->error();
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess::ProcessState QtcProcess::state() const
|
||||||
|
{
|
||||||
|
return d->m_process->state();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QtcProcess::errorString() const
|
||||||
|
{
|
||||||
|
return d->m_process->errorString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtcProcess::setErrorString(const QString &str)
|
||||||
|
{
|
||||||
|
d->m_process->setErrorString(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 QtcProcess::processId() const
|
||||||
|
{
|
||||||
|
return d->m_process->processId();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtcProcess::waitForStarted(int msecs)
|
||||||
|
{
|
||||||
|
return d->m_process->waitForStarted(msecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtcProcess::waitForReadyRead(int msecs)
|
||||||
|
{
|
||||||
|
return d->m_process->waitForReadyRead(msecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtcProcess::waitForFinished(int msecs)
|
||||||
|
{
|
||||||
|
return d->m_process->waitForFinished(msecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray QtcProcess::readAllStandardOutput()
|
||||||
|
{
|
||||||
|
QByteArray buf = d->m_stdOut.rawData;
|
||||||
|
d->m_stdOut.rawData.clear();
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray QtcProcess::readAllStandardError()
|
||||||
|
{
|
||||||
|
QByteArray buf = d->m_stdErr.rawData;
|
||||||
|
d->m_stdErr.rawData.clear();
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray QtcProcess::readAll()
|
||||||
|
{
|
||||||
|
return d->m_process->readAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray QtcProcess::readLine()
|
||||||
|
{
|
||||||
|
return d->m_process->readLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess::ExitStatus QtcProcess::exitStatus() const
|
||||||
|
{
|
||||||
|
return d->m_process->exitStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtcProcess::kill()
|
||||||
|
{
|
||||||
|
d->m_process->kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 QtcProcess::write(const QByteArray &input)
|
||||||
|
{
|
||||||
|
return d->m_process->write(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtcProcess::closeWriteChannel()
|
||||||
|
{
|
||||||
|
d->m_process->closeWriteChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtcProcess::close()
|
||||||
|
{
|
||||||
|
d->m_process->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtcProcess::setReadChannel(QProcess::ProcessChannel channel)
|
||||||
|
{
|
||||||
|
d->m_process->setReadChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtcProcess::canReadLine() const
|
||||||
|
{
|
||||||
|
return d->m_process->canReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtcProcess::atEnd() const
|
||||||
|
{
|
||||||
|
return d->m_process->atEnd();
|
||||||
|
}
|
||||||
|
|
||||||
QString QtcProcess::locateBinary(const QString &binary)
|
QString QtcProcess::locateBinary(const QString &binary)
|
||||||
{
|
{
|
||||||
const QByteArray path = qgetenv("PATH");
|
const QByteArray path = qgetenv("PATH");
|
||||||
@@ -631,6 +791,11 @@ QString QtcProcess::exitMessage()
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIODevice *QtcProcess::ioDevice()
|
||||||
|
{
|
||||||
|
return d->m_process;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray QtcProcess::allRawOutput() const
|
QByteArray QtcProcess::allRawOutput() const
|
||||||
{
|
{
|
||||||
if (!d->m_stdOut.rawData.isEmpty() && !d->m_stdErr.rawData.isEmpty()) {
|
if (!d->m_stdOut.rawData.isEmpty() && !d->m_stdErr.rawData.isEmpty()) {
|
||||||
@@ -718,13 +883,11 @@ QString ChannelBuffer::linesRead()
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelBuffer::append(const QByteArray &text, bool emitSignals)
|
void ChannelBuffer::append(const QByteArray &text)
|
||||||
{
|
{
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
return;
|
return;
|
||||||
rawData += text;
|
rawData += text;
|
||||||
if (!emitSignals)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Buffered. Emit complete lines?
|
// Buffered. Emit complete lines?
|
||||||
if (outputCallback) {
|
if (outputCallback) {
|
||||||
@@ -742,17 +905,9 @@ SynchronousProcess::SynchronousProcess()
|
|||||||
|
|
||||||
d->m_timer.setInterval(1000);
|
d->m_timer.setInterval(1000);
|
||||||
connect(&d->m_timer, &QTimer::timeout, d, &QtcProcessPrivate::slotTimeout);
|
connect(&d->m_timer, &QTimer::timeout, d, &QtcProcessPrivate::slotTimeout);
|
||||||
connect(this, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(d->m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||||
d, &QtcProcessPrivate::slotFinished);
|
d, &QtcProcessPrivate::slotFinished);
|
||||||
connect(this, &QProcess::errorOccurred, d, &QtcProcessPrivate::slotError);
|
connect(d->m_process, &QProcess::errorOccurred, d, &QtcProcessPrivate::slotError);
|
||||||
connect(this, &QProcess::readyReadStandardOutput, d, [this] {
|
|
||||||
d->m_hangTimerCount = 0;
|
|
||||||
d->m_stdOut.append(readAllStandardOutput(), true);
|
|
||||||
});
|
|
||||||
connect(this, &QProcess::readyReadStandardError, d, [this] {
|
|
||||||
d->m_hangTimerCount = 0;
|
|
||||||
d->m_stdErr.append(readAllStandardError(), true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SynchronousProcess::~SynchronousProcess()
|
SynchronousProcess::~SynchronousProcess()
|
||||||
@@ -818,8 +973,6 @@ void SynchronousProcess::runBlocking()
|
|||||||
|
|
||||||
d->m_result = QtcProcess::Finished;
|
d->m_result = QtcProcess::Finished;
|
||||||
d->m_exitCode = exitCode();
|
d->m_exitCode = exitCode();
|
||||||
d->m_stdOut.rawData += readAllStandardOutput();
|
|
||||||
d->m_stdErr.rawData += readAllStandardError();
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -833,7 +986,7 @@ void SynchronousProcess::runBlocking()
|
|||||||
|
|
||||||
if (d->m_processUserEvents) {
|
if (d->m_processUserEvents) {
|
||||||
if (!d->m_writeData.isEmpty()) {
|
if (!d->m_writeData.isEmpty()) {
|
||||||
connect(this, &QProcess::started, this, [this] {
|
connect(d->m_process, &QProcess::started, this, [this] {
|
||||||
write(d->m_writeData);
|
write(d->m_writeData);
|
||||||
closeWriteChannel();
|
closeWriteChannel();
|
||||||
});
|
});
|
||||||
@@ -851,8 +1004,8 @@ void SynchronousProcess::runBlocking()
|
|||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
#endif
|
#endif
|
||||||
d->m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
|
d->m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||||
d->m_stdOut.append(readAllStandardOutput(), false);
|
d->m_stdOut.append(d->m_process->readAllStandardOutput());
|
||||||
d->m_stdErr.append(readAllStandardError(), false);
|
d->m_stdErr.append(d->m_process->readAllStandardError());
|
||||||
|
|
||||||
d->m_timer.stop();
|
d->m_timer.stop();
|
||||||
#ifdef QT_GUI_LIB
|
#ifdef QT_GUI_LIB
|
||||||
@@ -887,8 +1040,8 @@ void SynchronousProcess::runBlocking()
|
|||||||
else
|
else
|
||||||
d->m_result = d->interpretExitCode(d->m_exitCode);
|
d->m_result = d->interpretExitCode(d->m_exitCode);
|
||||||
}
|
}
|
||||||
d->m_stdOut.append(readAllStandardOutput(), false);
|
d->m_stdOut.append(d->m_process->readAllStandardOutput());
|
||||||
d->m_stdErr.append(readAllStandardError(), false);
|
d->m_stdErr.append(d->m_process->readAllStandardError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ public:
|
|||||||
std::function<Environment(const FilePath &)> systemEnvironmentForBinary;
|
std::function<Environment(const FilePath &)> systemEnvironmentForBinary;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT QtcProcess : public QProcess
|
class QTCREATOR_UTILS_EXPORT QtcProcess : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -78,6 +78,9 @@ public:
|
|||||||
void setCommand(const CommandLine &cmdLine);
|
void setCommand(const CommandLine &cmdLine);
|
||||||
const CommandLine &commandLine() const;
|
const CommandLine &commandLine() const;
|
||||||
|
|
||||||
|
QString workingDirectory() const;
|
||||||
|
void setWorkingDirectory(const QString &dir);
|
||||||
|
|
||||||
void setUseCtrlCStub(bool enabled);
|
void setUseCtrlCStub(bool enabled);
|
||||||
void setLowPriority();
|
void setLowPriority();
|
||||||
void setDisableUnixTerminal();
|
void setDisableUnixTerminal();
|
||||||
@@ -103,7 +106,7 @@ public:
|
|||||||
|
|
||||||
static void setRemoteProcessHooks(const DeviceProcessHooks &hooks);
|
static void setRemoteProcessHooks(const DeviceProcessHooks &hooks);
|
||||||
|
|
||||||
void setOpenMode(OpenMode mode);
|
void setOpenMode(QIODevice::OpenMode mode);
|
||||||
|
|
||||||
bool stopProcess();
|
bool stopProcess();
|
||||||
bool readDataFromProcess(int timeoutS, QByteArray *stdOut, QByteArray *stdErr,
|
bool readDataFromProcess(int timeoutS, QByteArray *stdOut, QByteArray *stdErr,
|
||||||
@@ -134,10 +137,52 @@ public:
|
|||||||
|
|
||||||
static Environment systemEnvironmentForBinary(const FilePath &filePath);
|
static Environment systemEnvironmentForBinary(const FilePath &filePath);
|
||||||
|
|
||||||
|
// FIXME: Cut down the following bits inherited from QProcess and QIODevice.
|
||||||
|
|
||||||
|
void setProcessChannelMode(QProcess::ProcessChannelMode mode);
|
||||||
|
|
||||||
|
QProcess::ProcessError error() const;
|
||||||
|
QProcess::ProcessState state() const;
|
||||||
|
|
||||||
|
QString errorString() const;
|
||||||
|
void setErrorString(const QString &str);
|
||||||
|
|
||||||
|
qint64 processId() const;
|
||||||
|
|
||||||
|
bool waitForStarted(int msecs = 30000);
|
||||||
|
bool waitForReadyRead(int msecs = 30000);
|
||||||
|
bool waitForFinished(int msecs = 30000);
|
||||||
|
|
||||||
|
QByteArray readAllStandardOutput();
|
||||||
|
QByteArray readAllStandardError();
|
||||||
|
QByteArray readAll();
|
||||||
|
QByteArray readLine();
|
||||||
|
|
||||||
|
QProcess::ExitStatus exitStatus() const;
|
||||||
|
|
||||||
|
void kill();
|
||||||
|
|
||||||
|
qint64 write(const QByteArray &input);
|
||||||
|
void closeWriteChannel();
|
||||||
|
void close();
|
||||||
|
void setReadChannel(QProcess::ProcessChannel channel);
|
||||||
|
bool canReadLine() const;
|
||||||
|
bool atEnd() const;
|
||||||
|
|
||||||
|
QIODevice *ioDevice(); // FIXME: Remove.
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void started();
|
||||||
|
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
|
void errorOccurred(QProcess::ProcessError error);
|
||||||
|
void stateChanged(QProcess::ProcessState state);
|
||||||
|
|
||||||
|
void readyReadStandardOutput();
|
||||||
|
void readyReadStandardError();
|
||||||
|
void readyRead();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
void setupChildProcess() override;
|
|
||||||
#endif
|
|
||||||
friend class SynchronousProcess;
|
friend class SynchronousProcess;
|
||||||
friend QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const QtcProcess &r);
|
friend QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const QtcProcess &r);
|
||||||
|
|
||||||
|
@@ -1086,7 +1086,7 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdFutureInterface &fi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_licenseTextCache.clear();
|
m_licenseTextCache.clear();
|
||||||
result.success = licenseCommand.exitStatus() == QtcProcess::NormalExit;
|
result.success = licenseCommand.exitStatus() == QProcess::NormalExit;
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
result.stdError = QCoreApplication::translate("Android::Internal::AndroidSdkManager",
|
result.stdError = QCoreApplication::translate("Android::Internal::AndroidSdkManager",
|
||||||
"License command failed.\n\n");
|
"License command failed.\n\n");
|
||||||
|
@@ -730,8 +730,7 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
|
|||||||
openButton->deleteLater();
|
openButton->deleteLater();
|
||||||
};
|
};
|
||||||
|
|
||||||
connect(gitCloner,
|
connect(gitCloner, &QtcProcess::finished,
|
||||||
QOverload<int, QtcProcess::ExitStatus>::of(&QtcProcess::finished),
|
|
||||||
m_ui.openSslPathChooser,
|
m_ui.openSslPathChooser,
|
||||||
[=](int exitCode, QProcess::ExitStatus exitStatus) {
|
[=](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||||
openSslProgressDialog->close();
|
openSslProgressDialog->close();
|
||||||
@@ -739,7 +738,7 @@ void AndroidSettingsWidget::downloadOpenSslRepo(const bool silent)
|
|||||||
m_ui.openSslPathChooser->triggerChanged(); // After cloning, the path exists
|
m_ui.openSslPathChooser->triggerChanged(); // After cloning, the path exists
|
||||||
|
|
||||||
if (!openSslProgressDialog->wasCanceled()
|
if (!openSslProgressDialog->wasCanceled()
|
||||||
|| (exitStatus == QtcProcess::NormalExit && exitCode != 0)) {
|
|| (exitStatus == QProcess::NormalExit && exitCode != 0)) {
|
||||||
failDialog();
|
failDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -380,31 +380,22 @@ UvscServerProviderRunner::UvscServerProviderRunner(ProjectExplorer::RunControl *
|
|||||||
{
|
{
|
||||||
setId("BareMetalUvscServer");
|
setId("BareMetalUvscServer");
|
||||||
|
|
||||||
const QString program = runnable.executable.toString();
|
m_process.setCommand(runnable.commandLine());
|
||||||
const QStringList args = runnable.commandLineArguments.split(' ');
|
|
||||||
m_process.setProgram(program);
|
|
||||||
m_process.setArguments(args);
|
|
||||||
|
|
||||||
connect(&m_process, &QtcProcess::started, this, [this]() {
|
connect(&m_process, &QtcProcess::started, this, [this] {
|
||||||
ProcessHandle pid(m_process.processId());
|
ProcessHandle pid(m_process.processId());
|
||||||
this->runControl()->setApplicationProcessHandle(pid);
|
this->runControl()->setApplicationProcessHandle(pid);
|
||||||
reportStarted();
|
reportStarted();
|
||||||
});
|
});
|
||||||
connect(&m_process,
|
connect(&m_process, &QtcProcess::finished, this, [this] {
|
||||||
QOverload<int, QProcess::ExitStatus>::of(&QtcProcess::finished),
|
appendMessage(m_process.exitMessage(), NormalMessageFormat);
|
||||||
this,
|
|
||||||
[this](int exitCode, QProcess::ExitStatus status) {
|
|
||||||
const QString msg = (status == QProcess::CrashExit)
|
|
||||||
? RunControl::tr("%1 crashed.")
|
|
||||||
: RunControl::tr("%2 exited with code %1").arg(exitCode);
|
|
||||||
appendMessage(msg.arg(m_process.program()), Utils::NormalMessageFormat);
|
|
||||||
reportStopped();
|
reportStopped();
|
||||||
});
|
});
|
||||||
connect(&m_process, &QtcProcess::errorOccurred, this, [this] (QProcess::ProcessError error) {
|
connect(&m_process, &QtcProcess::errorOccurred, this, [this] (QProcess::ProcessError error) {
|
||||||
if (error == QProcess::Timedout)
|
if (error == QProcess::Timedout)
|
||||||
return; // No actual change on the process side.
|
return; // No actual change on the process side.
|
||||||
const QString msg = userMessageForProcessError(
|
const QString msg = userMessageForProcessError(
|
||||||
error, FilePath::fromString(m_process.program()));
|
error, m_process.commandLine().executable());
|
||||||
appendMessage(msg, Utils::NormalMessageFormat);
|
appendMessage(msg, Utils::NormalMessageFormat);
|
||||||
reportStopped();
|
reportStopped();
|
||||||
});
|
});
|
||||||
@@ -412,8 +403,8 @@ UvscServerProviderRunner::UvscServerProviderRunner(ProjectExplorer::RunControl *
|
|||||||
|
|
||||||
void UvscServerProviderRunner::start()
|
void UvscServerProviderRunner::start()
|
||||||
{
|
{
|
||||||
const QString msg = RunControl::tr("Starting %1 %2...")
|
const QString msg = RunControl::tr("Starting %1 ...")
|
||||||
.arg(m_process.program()).arg(m_process.arguments().join(' '));
|
.arg(m_process.commandLine().toUserOutput());
|
||||||
appendMessage(msg, Utils::NormalMessageFormat);
|
appendMessage(msg, Utils::NormalMessageFormat);
|
||||||
|
|
||||||
m_process.start();
|
m_process.start();
|
||||||
|
@@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#include <projectexplorer/runcontrol.h> // for RunWorker
|
#include <projectexplorer/runcontrol.h> // for RunWorker
|
||||||
|
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
namespace Utils { class PathChooser; }
|
namespace Utils { class PathChooser; }
|
||||||
|
|
||||||
namespace BareMetal {
|
namespace BareMetal {
|
||||||
@@ -149,7 +151,7 @@ private:
|
|||||||
void start() final;
|
void start() final;
|
||||||
void stop() final;
|
void stop() final;
|
||||||
|
|
||||||
QProcess m_process;
|
Utils::QtcProcess m_process;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -83,13 +83,11 @@ void ClangToolRunner::init(const QString &outputDirPath, const Environment &envi
|
|||||||
m_outputDirPath = outputDirPath;
|
m_outputDirPath = outputDirPath;
|
||||||
QTC_CHECK(!m_outputDirPath.isEmpty());
|
QTC_CHECK(!m_outputDirPath.isEmpty());
|
||||||
|
|
||||||
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
|
||||||
m_process->setEnvironment(environment);
|
m_process->setEnvironment(environment);
|
||||||
m_process->setWorkingDirectory(m_outputDirPath); // Current clang-cl puts log file into working dir.
|
m_process->setWorkingDirectory(m_outputDirPath); // Current clang-cl puts log file into working dir.
|
||||||
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(m_process, &QtcProcess::finished, this, &ClangToolRunner::onProcessFinished);
|
||||||
this, &ClangToolRunner::onProcessFinished);
|
connect(m_process, &QtcProcess::errorOccurred, this, &ClangToolRunner::onProcessError);
|
||||||
connect(m_process, &QProcess::errorOccurred, this, &ClangToolRunner::onProcessError);
|
connect(m_process, &QtcProcess::readyRead, this, &ClangToolRunner::onProcessOutput);
|
||||||
connect(m_process, &QProcess::readyRead, this, &ClangToolRunner::onProcessOutput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ClangToolRunner::mainToolArguments() const
|
QStringList ClangToolRunner::mainToolArguments() const
|
||||||
|
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -104,11 +106,11 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
process->setWorkingDirectory(workDirectory.toString());
|
process->setWorkingDirectory(workDirectory.toString());
|
||||||
process->setEnvironment(parameters.environment);
|
process->setEnvironment(parameters.environment);
|
||||||
|
|
||||||
connect(process.get(), &QProcess::readyReadStandardOutput,
|
connect(process.get(), &QtcProcess::readyReadStandardOutput,
|
||||||
this, &CMakeProcess::processStandardOutput);
|
this, &CMakeProcess::processStandardOutput);
|
||||||
connect(process.get(), &QProcess::readyReadStandardError,
|
connect(process.get(), &QtcProcess::readyReadStandardError,
|
||||||
this, &CMakeProcess::processStandardError);
|
this, &CMakeProcess::processStandardError);
|
||||||
connect(process.get(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(process.get(), &QtcProcess::finished,
|
||||||
this, &CMakeProcess::handleProcessFinished);
|
this, &CMakeProcess::handleProcessFinished);
|
||||||
|
|
||||||
Utils::CommandLine commandLine(cmake->cmakeExecutable(), QStringList({"-S", srcDir, QString("-B"), workDirectory.toString()}) + arguments);
|
Utils::CommandLine commandLine(cmake->cmakeExecutable(), QStringList({"-S", srcDir, QString("-B"), workDirectory.toString()}) + arguments);
|
||||||
|
@@ -653,13 +653,12 @@ void ExternalToolRunner::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_process = new QtcProcess(this);
|
m_process = new QtcProcess(this);
|
||||||
connect(m_process, &QProcess::started, this, &ExternalToolRunner::started);
|
connect(m_process, &QtcProcess::started, this, &ExternalToolRunner::started);
|
||||||
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(m_process, &QtcProcess::finished, this, &ExternalToolRunner::finished);
|
||||||
this, &ExternalToolRunner::finished);
|
connect(m_process, &QtcProcess::errorOccurred, this, &ExternalToolRunner::error);
|
||||||
connect(m_process, &QProcess::errorOccurred, this, &ExternalToolRunner::error);
|
connect(m_process, &QtcProcess::readyReadStandardOutput,
|
||||||
connect(m_process, &QProcess::readyReadStandardOutput,
|
|
||||||
this, &ExternalToolRunner::readStandardOutput);
|
this, &ExternalToolRunner::readStandardOutput);
|
||||||
connect(m_process, &QProcess::readyReadStandardError,
|
connect(m_process, &QtcProcess::readyReadStandardError,
|
||||||
this, &ExternalToolRunner::readStandardError);
|
this, &ExternalToolRunner::readStandardError);
|
||||||
if (!m_resolvedWorkingDirectory.isEmpty())
|
if (!m_resolvedWorkingDirectory.isEmpty())
|
||||||
m_process->setWorkingDirectory(m_resolvedWorkingDirectory);
|
m_process->setWorkingDirectory(m_resolvedWorkingDirectory);
|
||||||
|
@@ -34,6 +34,8 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
ExecuteFilter::ExecuteFilter()
|
ExecuteFilter::ExecuteFilter()
|
||||||
{
|
{
|
||||||
setId("Execute custom commands");
|
setId("Execute custom commands");
|
||||||
@@ -47,10 +49,9 @@ ExecuteFilter::ExecuteFilter()
|
|||||||
|
|
||||||
m_process = new Utils::QtcProcess(this);
|
m_process = new Utils::QtcProcess(this);
|
||||||
m_process->setEnvironment(Utils::Environment::systemEnvironment());
|
m_process->setEnvironment(Utils::Environment::systemEnvironment());
|
||||||
connect(m_process, QOverload<int ,QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(m_process, &QtcProcess::finished, this, &ExecuteFilter::finished);
|
||||||
this, &ExecuteFilter::finished);
|
connect(m_process, &QtcProcess::readyReadStandardOutput, this, &ExecuteFilter::readStandardOutput);
|
||||||
connect(m_process, &QProcess::readyReadStandardOutput, this, &ExecuteFilter::readStandardOutput);
|
connect(m_process, &QtcProcess::readyReadStandardError, this, &ExecuteFilter::readStandardError);
|
||||||
connect(m_process, &QProcess::readyReadStandardError, this, &ExecuteFilter::readStandardError);
|
|
||||||
|
|
||||||
m_runTimer.setSingleShot(true);
|
m_runTimer.setSingleShot(true);
|
||||||
connect(&m_runTimer, &QTimer::timeout, this, &ExecuteFilter::runHeadCommand);
|
connect(&m_runTimer, &QTimer::timeout, this, &ExecuteFilter::runHeadCommand);
|
||||||
|
@@ -92,16 +92,14 @@ SpotlightIterator::SpotlightIterator(const QStringList &command)
|
|||||||
m_process->setCommand({Environment::systemEnvironment().searchInPath(command.first()),
|
m_process->setCommand({Environment::systemEnvironment().searchInPath(command.first()),
|
||||||
command.mid(1)});
|
command.mid(1)});
|
||||||
m_process->setEnvironment(Utils::Environment::systemEnvironment());
|
m_process->setEnvironment(Utils::Environment::systemEnvironment());
|
||||||
QObject::connect(m_process.get(),
|
QObject::connect(m_process.get(), &QtcProcess::finished, [this] { scheduleKillProcess(); });
|
||||||
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
QObject::connect(m_process.get(), &QtcProcess::errorOccurred, [this, command] {
|
||||||
[this] { scheduleKillProcess(); });
|
|
||||||
QObject::connect(m_process.get(), &QProcess::errorOccurred, [this, command] {
|
|
||||||
MessageManager::writeFlashing(
|
MessageManager::writeFlashing(
|
||||||
SpotlightLocatorFilter::tr("Locator: Error occurred when running \"%1\".")
|
SpotlightLocatorFilter::tr("Locator: Error occurred when running \"%1\".")
|
||||||
.arg(command.first()));
|
.arg(command.first()));
|
||||||
scheduleKillProcess();
|
scheduleKillProcess();
|
||||||
});
|
});
|
||||||
QObject::connect(m_process.get(), &QProcess::readyReadStandardOutput, [this] {
|
QObject::connect(m_process.get(), &QtcProcess::readyReadStandardOutput, [this] {
|
||||||
QString output = QString::fromUtf8(m_process->readAllStandardOutput());
|
QString output = QString::fromUtf8(m_process->readAllStandardOutput());
|
||||||
output.replace("\r\n", "\n");
|
output.replace("\r\n", "\n");
|
||||||
const QStringList items = output.split('\n');
|
const QStringList items = output.split('\n');
|
||||||
|
@@ -112,8 +112,11 @@ static bool runPatchHelper(const QByteArray &input, const QString &workingDirect
|
|||||||
.arg(patch, patchProcess.errorString()));
|
.arg(patch, patchProcess.errorString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
patchProcess.write(input);
|
patchProcess.write(input);
|
||||||
patchProcess.closeWriteChannel();
|
patchProcess.closeWriteChannel();
|
||||||
|
|
||||||
QByteArray stdOut;
|
QByteArray stdOut;
|
||||||
QByteArray stdErr;
|
QByteArray stdErr;
|
||||||
if (!patchProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
if (!patchProcess.readDataFromProcess(30, &stdOut, &stdErr, true)) {
|
||||||
|
@@ -49,13 +49,13 @@ CppcheckRunner::CppcheckRunner(CppcheckTool &tool) :
|
|||||||
m_maxArgumentsLength = std::max(argMax.toInt(), m_maxArgumentsLength);
|
m_maxArgumentsLength = std::max(argMax.toInt(), m_maxArgumentsLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_process, &QProcess::readyReadStandardOutput,
|
connect(m_process, &QtcProcess::readyReadStandardOutput,
|
||||||
this, &CppcheckRunner::readOutput);
|
this, &CppcheckRunner::readOutput);
|
||||||
connect(m_process, &QProcess::readyReadStandardOutput,
|
connect(m_process, &QtcProcess::readyReadStandardOutput,
|
||||||
this, &CppcheckRunner::readError);
|
this, &CppcheckRunner::readError);
|
||||||
connect(m_process, &QProcess::started,
|
connect(m_process, &QtcProcess::started,
|
||||||
this, &CppcheckRunner::handleStarted);
|
this, &CppcheckRunner::handleStarted);
|
||||||
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(m_process, &QtcProcess::finished,
|
||||||
this, &CppcheckRunner::handleFinished);
|
this, &CppcheckRunner::handleFinished);
|
||||||
|
|
||||||
m_queueTimer.setSingleShot(true);
|
m_queueTimer.setSingleShot(true);
|
||||||
@@ -128,8 +128,7 @@ const Utils::FilePaths &CppcheckRunner::currentFiles() const
|
|||||||
|
|
||||||
QString CppcheckRunner::currentCommand() const
|
QString CppcheckRunner::currentCommand() const
|
||||||
{
|
{
|
||||||
return m_process->program() + ' ' +
|
return m_process->commandLine().toUserOutput();
|
||||||
m_process->arguments().join(' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppcheckRunner::checkQueued()
|
void CppcheckRunner::checkQueued()
|
||||||
|
@@ -205,12 +205,11 @@ CdbEngine::CdbEngine() :
|
|||||||
DebuggerSettings *s = debuggerSettings();
|
DebuggerSettings *s = debuggerSettings();
|
||||||
connect(s->createFullBacktrace.action(), &QAction::triggered,
|
connect(s->createFullBacktrace.action(), &QAction::triggered,
|
||||||
this, &CdbEngine::createFullBacktrace);
|
this, &CdbEngine::createFullBacktrace);
|
||||||
connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_process, &QtcProcess::finished, this, &CdbEngine::processFinished);
|
||||||
this, &CdbEngine::processFinished);
|
connect(&m_process, &QtcProcess::errorOccurred, this, &CdbEngine::processError);
|
||||||
connect(&m_process, &QProcess::errorOccurred, this, &CdbEngine::processError);
|
connect(&m_process, &QtcProcess::readyReadStandardOutput,
|
||||||
connect(&m_process, &QProcess::readyReadStandardOutput,
|
|
||||||
this, &CdbEngine::readyReadStandardOut);
|
this, &CdbEngine::readyReadStandardOut);
|
||||||
connect(&m_process, &QProcess::readyReadStandardError,
|
connect(&m_process, &QtcProcess::readyReadStandardError,
|
||||||
this, &CdbEngine::readyReadStandardOut);
|
this, &CdbEngine::readyReadStandardOut);
|
||||||
connect(&s->useDebuggingHelpers, &BaseAspect::changed,
|
connect(&s->useDebuggingHelpers, &BaseAspect::changed,
|
||||||
this, &CdbEngine::updateLocals);
|
this, &CdbEngine::updateLocals);
|
||||||
|
@@ -103,13 +103,13 @@ public:
|
|||||||
LocalProcessRunner(DebuggerRunTool *runTool, const CommandLine &command)
|
LocalProcessRunner(DebuggerRunTool *runTool, const CommandLine &command)
|
||||||
: RunWorker(runTool->runControl()), m_runTool(runTool), m_command(command)
|
: RunWorker(runTool->runControl()), m_runTool(runTool), m_command(command)
|
||||||
{
|
{
|
||||||
connect(&m_proc, &QProcess::errorOccurred,
|
connect(&m_proc, &QtcProcess::errorOccurred,
|
||||||
this, &LocalProcessRunner::handleError);
|
this, &LocalProcessRunner::handleError);
|
||||||
connect(&m_proc, &QProcess::readyReadStandardOutput,
|
connect(&m_proc, &QtcProcess::readyReadStandardOutput,
|
||||||
this, &LocalProcessRunner::handleStandardOutput);
|
this, &LocalProcessRunner::handleStandardOutput);
|
||||||
connect(&m_proc, &QProcess::readyReadStandardError,
|
connect(&m_proc, &QtcProcess::readyReadStandardError,
|
||||||
this, &LocalProcessRunner::handleStandardError);
|
this, &LocalProcessRunner::handleStandardError);
|
||||||
connect(&m_proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_proc, &QtcProcess::finished,
|
||||||
this, &LocalProcessRunner::handleFinished);
|
this, &LocalProcessRunner::handleFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -166,9 +166,9 @@ GdbEngine::GdbEngine()
|
|||||||
connect(&s.useDynamicType, &BaseAspect::changed,
|
connect(&s.useDynamicType, &BaseAspect::changed,
|
||||||
this, &GdbEngine::reloadLocals);
|
this, &GdbEngine::reloadLocals);
|
||||||
|
|
||||||
connect(&m_gdbProc, &QProcess::errorOccurred,
|
connect(&m_gdbProc, &QtcProcess::errorOccurred,
|
||||||
this, &GdbEngine::handleGdbError);
|
this, &GdbEngine::handleGdbError);
|
||||||
connect(&m_gdbProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_gdbProc, &QtcProcess::finished,
|
||||||
this, &GdbEngine::handleGdbFinished);
|
this, &GdbEngine::handleGdbFinished);
|
||||||
connect(&m_gdbProc, &QtcProcess::readyReadStandardOutput,
|
connect(&m_gdbProc, &QtcProcess::readyReadStandardOutput,
|
||||||
this, &GdbEngine::readGdbStandardOutput);
|
this, &GdbEngine::readGdbStandardOutput);
|
||||||
|
@@ -98,13 +98,13 @@ LldbEngine::LldbEngine()
|
|||||||
connect(&ds.intelFlavor, &BaseAspect::changed,
|
connect(&ds.intelFlavor, &BaseAspect::changed,
|
||||||
this, &LldbEngine::updateAll);
|
this, &LldbEngine::updateAll);
|
||||||
|
|
||||||
connect(&m_lldbProc, &QProcess::errorOccurred,
|
connect(&m_lldbProc, &QtcProcess::errorOccurred,
|
||||||
this, &LldbEngine::handleLldbError);
|
this, &LldbEngine::handleLldbError);
|
||||||
connect(&m_lldbProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_lldbProc, &QtcProcess::finished,
|
||||||
this, &LldbEngine::handleLldbFinished);
|
this, &LldbEngine::handleLldbFinished);
|
||||||
connect(&m_lldbProc, &QProcess::readyReadStandardOutput,
|
connect(&m_lldbProc, &QtcProcess::readyReadStandardOutput,
|
||||||
this, &LldbEngine::readLldbStandardOutput);
|
this, &LldbEngine::readLldbStandardOutput);
|
||||||
connect(&m_lldbProc, &QProcess::readyReadStandardError,
|
connect(&m_lldbProc, &QtcProcess::readyReadStandardError,
|
||||||
this, &LldbEngine::readLldbStandardError);
|
this, &LldbEngine::readLldbStandardError);
|
||||||
|
|
||||||
connect(this, &LldbEngine::outputReady,
|
connect(this, &LldbEngine::outputReady,
|
||||||
|
@@ -129,14 +129,13 @@ void DockerDeviceProcess::start(const Runnable &runnable)
|
|||||||
m_process.setCommand(runnable.commandLine());
|
m_process.setCommand(runnable.commandLine());
|
||||||
m_process.setEnvironment(runnable.environment);
|
m_process.setEnvironment(runnable.environment);
|
||||||
m_process.setWorkingDirectory(runnable.workingDirectory);
|
m_process.setWorkingDirectory(runnable.workingDirectory);
|
||||||
connect(&m_process, &QProcess::errorOccurred, this, &DeviceProcess::error);
|
connect(&m_process, &QtcProcess::errorOccurred, this, &DeviceProcess::error);
|
||||||
connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_process, &QtcProcess::finished, this, &DeviceProcess::finished);
|
||||||
this, &DeviceProcess::finished);
|
connect(&m_process, &QtcProcess::readyReadStandardOutput,
|
||||||
connect(&m_process, &QProcess::readyReadStandardOutput,
|
|
||||||
this, &DeviceProcess::readyReadStandardOutput);
|
this, &DeviceProcess::readyReadStandardOutput);
|
||||||
connect(&m_process, &QProcess::readyReadStandardError,
|
connect(&m_process, &QtcProcess::readyReadStandardError,
|
||||||
this, &DeviceProcess::readyReadStandardError);
|
this, &DeviceProcess::readyReadStandardError);
|
||||||
connect(&m_process, &QProcess::started, this, &DeviceProcess::started);
|
connect(&m_process, &QtcProcess::started, this, &DeviceProcess::started);
|
||||||
dockerDevice->runProcess(m_process);
|
dockerDevice->runProcess(m_process);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,8 +83,7 @@ void DockerSettings::updateImageList()
|
|||||||
QtcProcess process;
|
QtcProcess process;
|
||||||
process.setCommand({"docker", {"search", imageListFilter.value()}});
|
process.setCommand({"docker", {"search", imageListFilter.value()}});
|
||||||
|
|
||||||
const auto finished = QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished);
|
connect(&process, &QtcProcess::finished, this, [&process, this] {
|
||||||
connect(&process, finished, this, [&process, this] {
|
|
||||||
const QString data = QString::fromUtf8(process.readAll());
|
const QString data = QString::fromUtf8(process.readAll());
|
||||||
imageList.setValue(data);
|
imageList.setValue(data);
|
||||||
});
|
});
|
||||||
|
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
enum { debug = 0 };
|
enum { debug = 0 };
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
using namespace VcsBase;
|
using namespace VcsBase;
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit {
|
||||||
@@ -283,17 +284,16 @@ QueryContext::QueryContext(const QString &query,
|
|||||||
+ "&o=CURRENT_REVISION&o=DETAILED_LABELS&o=DETAILED_ACCOUNTS";
|
+ "&o=CURRENT_REVISION&o=DETAILED_LABELS&o=DETAILED_ACCOUNTS";
|
||||||
m_arguments = server.curlArguments() << url;
|
m_arguments = server.curlArguments() << url;
|
||||||
}
|
}
|
||||||
connect(&m_process, &QProcess::readyReadStandardError, this, [this] {
|
connect(&m_process, &QtcProcess::readyReadStandardError, this, [this] {
|
||||||
const QString text = QString::fromLocal8Bit(m_process.readAllStandardError());
|
const QString text = QString::fromLocal8Bit(m_process.readAllStandardError());
|
||||||
VcsOutputWindow::appendError(text);
|
VcsOutputWindow::appendError(text);
|
||||||
m_error.append(text);
|
m_error.append(text);
|
||||||
});
|
});
|
||||||
connect(&m_process, &QProcess::readyReadStandardOutput, this, [this] {
|
connect(&m_process, &QtcProcess::readyReadStandardOutput, this, [this] {
|
||||||
m_output.append(m_process.readAllStandardOutput());
|
m_output.append(m_process.readAllStandardOutput());
|
||||||
});
|
});
|
||||||
connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_process, &QtcProcess::finished, this, &QueryContext::processFinished);
|
||||||
this, &QueryContext::processFinished);
|
connect(&m_process, &QtcProcess::errorOccurred, this, &QueryContext::processError);
|
||||||
connect(&m_process, &QProcess::errorOccurred, this, &QueryContext::processError);
|
|
||||||
connect(&m_watcher, &QFutureWatcherBase::canceled, this, &QueryContext::terminate);
|
connect(&m_watcher, &QFutureWatcherBase::canceled, this, &QueryContext::terminate);
|
||||||
m_watcher.setFuture(m_progress.future());
|
m_watcher.setFuture(m_progress.future());
|
||||||
m_process.setEnvironment(Git::Internal::GitClient::instance()->processEnvironment());
|
m_process.setEnvironment(Git::Internal::GitClient::instance()->processEnvironment());
|
||||||
@@ -383,8 +383,7 @@ void QueryContext::timeout()
|
|||||||
arg(timeOutMS / 1000), QMessageBox::NoButton, parent);
|
arg(timeOutMS / 1000), QMessageBox::NoButton, parent);
|
||||||
QPushButton *terminateButton = box.addButton(tr("Terminate"), QMessageBox::YesRole);
|
QPushButton *terminateButton = box.addButton(tr("Terminate"), QMessageBox::YesRole);
|
||||||
box.addButton(tr("Keep Running"), QMessageBox::NoRole);
|
box.addButton(tr("Keep Running"), QMessageBox::NoRole);
|
||||||
connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_process, &QtcProcess::finished, &box, &QDialog::reject);
|
||||||
&box, &QDialog::reject);
|
|
||||||
box.exec();
|
box.exec();
|
||||||
if (m_process.state() != QProcess::Running)
|
if (m_process.state() != QProcess::Running)
|
||||||
return;
|
return;
|
||||||
|
@@ -140,12 +140,11 @@ FetchContext::FetchContext(const QSharedPointer<GerritChange> &change,
|
|||||||
, m_server(server)
|
, m_server(server)
|
||||||
, m_state(FetchState)
|
, m_state(FetchState)
|
||||||
{
|
{
|
||||||
connect(&m_process, &QProcess::errorOccurred, this, &FetchContext::processError);
|
connect(&m_process, &QtcProcess::errorOccurred, this, &FetchContext::processError);
|
||||||
connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_process, &QtcProcess::finished, this, &FetchContext::processFinished);
|
||||||
this, &FetchContext::processFinished);
|
connect(&m_process, &QtcProcess::readyReadStandardError,
|
||||||
connect(&m_process, &QProcess::readyReadStandardError,
|
|
||||||
this, &FetchContext::processReadyReadStandardError);
|
this, &FetchContext::processReadyReadStandardError);
|
||||||
connect(&m_process, &QProcess::readyReadStandardOutput,
|
connect(&m_process, &QtcProcess::readyReadStandardOutput,
|
||||||
this, &FetchContext::processReadyReadStandardOutput);
|
this, &FetchContext::processReadyReadStandardOutput);
|
||||||
connect(&m_watcher, &QFutureWatcher<void>::canceled, this, &FetchContext::terminate);
|
connect(&m_watcher, &QFutureWatcher<void>::canceled, this, &FetchContext::terminate);
|
||||||
m_watcher.setFuture(m_progress.future());
|
m_watcher.setFuture(m_progress.future());
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
using namespace LanguageServerProtocol;
|
using namespace LanguageServerProtocol;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
static Q_LOGGING_CATEGORY(LOGLSPCLIENTV, "qtc.languageclient.messages", QtWarningMsg);
|
static Q_LOGGING_CATEGORY(LOGLSPCLIENTV, "qtc.languageclient.messages", QtWarningMsg);
|
||||||
|
|
||||||
@@ -88,11 +89,11 @@ void BaseClientInterface::parseData(const QByteArray &data)
|
|||||||
|
|
||||||
StdIOClientInterface::StdIOClientInterface()
|
StdIOClientInterface::StdIOClientInterface()
|
||||||
{
|
{
|
||||||
connect(&m_process, &QProcess::readyReadStandardError,
|
connect(&m_process, &QtcProcess::readyReadStandardError,
|
||||||
this, &StdIOClientInterface::readError);
|
this, &StdIOClientInterface::readError);
|
||||||
connect(&m_process, &QProcess::readyReadStandardOutput,
|
connect(&m_process, &QtcProcess::readyReadStandardOutput,
|
||||||
this, &StdIOClientInterface::readOutput);
|
this, &StdIOClientInterface::readOutput);
|
||||||
connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_process, &QtcProcess::finished,
|
||||||
this, &StdIOClientInterface::onProcessFinished);
|
this, &StdIOClientInterface::onProcessFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +125,8 @@ void StdIOClientInterface::setWorkingDirectory(const QString &workingDirectory)
|
|||||||
void StdIOClientInterface::sendData(const QByteArray &data)
|
void StdIOClientInterface::sendData(const QByteArray &data)
|
||||||
{
|
{
|
||||||
if (m_process.state() != QProcess::Running) {
|
if (m_process.state() != QProcess::Running) {
|
||||||
emit error(tr("Cannot send data to unstarted server %1").arg(m_process.program()));
|
emit error(tr("Cannot send data to unstarted server %1")
|
||||||
|
.arg(m_process.commandLine().toUserOutput()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qCDebug(LOGLSPCLIENTV) << "StdIOClient send data:";
|
qCDebug(LOGLSPCLIENTV) << "StdIOClient send data:";
|
||||||
|
@@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace MesonProjectManager {
|
namespace MesonProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -164,19 +166,16 @@ void MesonProcess::setupProcess(const Command &command,
|
|||||||
if (m_process)
|
if (m_process)
|
||||||
disconnect(m_process.get());
|
disconnect(m_process.get());
|
||||||
m_process = std::make_unique<Utils::QtcProcess>();
|
m_process = std::make_unique<Utils::QtcProcess>();
|
||||||
connect(m_process.get(),
|
connect(m_process.get(), &QtcProcess::finished, this, &MesonProcess::handleProcessFinished);
|
||||||
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(m_process.get(), &QtcProcess::errorOccurred, this, &MesonProcess::handleProcessError);
|
||||||
this,
|
|
||||||
&MesonProcess::handleProcessFinished);
|
|
||||||
connect(m_process.get(), &QProcess::errorOccurred, this, &MesonProcess::handleProcessError);
|
|
||||||
if (!captureStdo) {
|
if (!captureStdo) {
|
||||||
connect(m_process.get(),
|
connect(m_process.get(),
|
||||||
&QProcess::readyReadStandardOutput,
|
&QtcProcess::readyReadStandardOutput,
|
||||||
this,
|
this,
|
||||||
&MesonProcess::processStandardOutput);
|
&MesonProcess::processStandardOutput);
|
||||||
|
|
||||||
connect(m_process.get(),
|
connect(m_process.get(),
|
||||||
&QProcess::readyReadStandardError,
|
&QtcProcess::readyReadStandardError,
|
||||||
this,
|
this,
|
||||||
&MesonProcess::processStandardError);
|
&MesonProcess::processStandardError);
|
||||||
}
|
}
|
||||||
|
@@ -34,14 +34,15 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Perforce {
|
namespace Perforce {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
PerforceChecker::PerforceChecker(QObject *parent) : QObject(parent)
|
PerforceChecker::PerforceChecker(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
connect(&m_process, &QProcess::errorOccurred, this, &PerforceChecker::slotError);
|
connect(&m_process, &QtcProcess::errorOccurred, this, &PerforceChecker::slotError);
|
||||||
connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_process, &QtcProcess::finished, this, &PerforceChecker::slotFinished);
|
||||||
this, &PerforceChecker::slotFinished);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PerforceChecker::~PerforceChecker()
|
PerforceChecker::~PerforceChecker()
|
||||||
|
@@ -99,7 +99,7 @@ class AbstractProcessStep::Private
|
|||||||
public:
|
public:
|
||||||
Private(AbstractProcessStep *q) : q(q) {}
|
Private(AbstractProcessStep *q) : q(q) {}
|
||||||
|
|
||||||
void cleanUp(QProcess *process);
|
void cleanUp(QtcProcess *process);
|
||||||
|
|
||||||
AbstractProcessStep *q;
|
AbstractProcessStep *q;
|
||||||
std::unique_ptr<QtcProcess> m_process;
|
std::unique_ptr<QtcProcess> m_process;
|
||||||
@@ -232,11 +232,11 @@ void AbstractProcessStep::doRun()
|
|||||||
if (d->m_lowPriority && ProjectExplorerPlugin::projectExplorerSettings().lowBuildPriority)
|
if (d->m_lowPriority && ProjectExplorerPlugin::projectExplorerSettings().lowBuildPriority)
|
||||||
d->m_process->setLowPriority();
|
d->m_process->setLowPriority();
|
||||||
|
|
||||||
connect(d->m_process.get(), &QProcess::readyReadStandardOutput,
|
connect(d->m_process.get(), &QtcProcess::readyReadStandardOutput,
|
||||||
this, &AbstractProcessStep::processReadyReadStdOutput);
|
this, &AbstractProcessStep::processReadyReadStdOutput);
|
||||||
connect(d->m_process.get(), &QProcess::readyReadStandardError,
|
connect(d->m_process.get(), &QtcProcess::readyReadStandardError,
|
||||||
this, &AbstractProcessStep::processReadyReadStdError);
|
this, &AbstractProcessStep::processReadyReadStdError);
|
||||||
connect(d->m_process.get(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(d->m_process.get(), &QtcProcess::finished,
|
||||||
this, &AbstractProcessStep::slotProcessFinished);
|
this, &AbstractProcessStep::slotProcessFinished);
|
||||||
|
|
||||||
d->m_process->start();
|
d->m_process->start();
|
||||||
@@ -282,7 +282,7 @@ void AbstractProcessStep::setupProcessParameters(ProcessParameters *params) cons
|
|||||||
params->setCommandLine(d->m_commandLineProvider());
|
params->setCommandLine(d->m_commandLineProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractProcessStep::Private::cleanUp(QProcess *process)
|
void AbstractProcessStep::Private::cleanUp(QtcProcess *process)
|
||||||
{
|
{
|
||||||
// The process has finished, leftover data is read in processFinished
|
// The process has finished, leftover data is read in processFinished
|
||||||
q->processFinished(process->exitCode(), process->exitStatus());
|
q->processFinished(process->exitCode(), process->exitStatus());
|
||||||
@@ -400,9 +400,9 @@ void AbstractProcessStep::finish(bool success)
|
|||||||
|
|
||||||
void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
|
void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
|
||||||
{
|
{
|
||||||
QProcess *process = d->m_process.get();
|
QtcProcess *process = d->m_process.get();
|
||||||
if (!process) // Happens when the process was canceled and handed over to the Reaper.
|
if (!process) // Happens when the process was canceled and handed over to the Reaper.
|
||||||
process = qobject_cast<QProcess *>(sender()); // The process was canceled!
|
process = qobject_cast<QtcProcess *>(sender()); // The process was canceled!
|
||||||
if (process) {
|
if (process) {
|
||||||
stdError(d->stderrStream->toUnicode(process->readAllStandardError()));
|
stdError(d->stderrStream->toUnicode(process->readAllStandardError()));
|
||||||
stdOutput(d->stdoutStream->toUnicode(process->readAllStandardOutput()));
|
stdOutput(d->stdoutStream->toUnicode(process->readAllStandardOutput()));
|
||||||
|
@@ -131,18 +131,18 @@ ApplicationLauncherPrivate::ApplicationLauncherPrivate(ApplicationLauncher *pare
|
|||||||
m_guiProcess.setProcessChannelMode(QProcess::MergedChannels);
|
m_guiProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
} else {
|
} else {
|
||||||
m_guiProcess.setProcessChannelMode(QProcess::SeparateChannels);
|
m_guiProcess.setProcessChannelMode(QProcess::SeparateChannels);
|
||||||
connect(&m_guiProcess, &QProcess::readyReadStandardError,
|
connect(&m_guiProcess, &QtcProcess::readyReadStandardError,
|
||||||
this, &ApplicationLauncherPrivate::readLocalStandardError);
|
this, &ApplicationLauncherPrivate::readLocalStandardError);
|
||||||
}
|
}
|
||||||
connect(&m_guiProcess, &QProcess::readyReadStandardOutput,
|
connect(&m_guiProcess, &QtcProcess::readyReadStandardOutput,
|
||||||
this, &ApplicationLauncherPrivate::readLocalStandardOutput);
|
this, &ApplicationLauncherPrivate::readLocalStandardOutput);
|
||||||
connect(&m_guiProcess, &QProcess::errorOccurred,
|
connect(&m_guiProcess, &QtcProcess::errorOccurred,
|
||||||
this, &ApplicationLauncherPrivate::localGuiProcessError);
|
this, &ApplicationLauncherPrivate::localGuiProcessError);
|
||||||
connect(&m_guiProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(&m_guiProcess, &QtcProcess::finished,
|
||||||
this, &ApplicationLauncherPrivate::localProcessDone);
|
this, &ApplicationLauncherPrivate::localProcessDone);
|
||||||
connect(&m_guiProcess, &QProcess::started,
|
connect(&m_guiProcess, &QtcProcess::started,
|
||||||
this, &ApplicationLauncherPrivate::handleProcessStarted);
|
this, &ApplicationLauncherPrivate::handleProcessStarted);
|
||||||
connect(&m_guiProcess, &QProcess::errorOccurred,
|
connect(&m_guiProcess, &QtcProcess::errorOccurred,
|
||||||
q, &ApplicationLauncher::error);
|
q, &ApplicationLauncher::error);
|
||||||
|
|
||||||
m_consoleProcess.setSettings(Core::ICore::settings());
|
m_consoleProcess.setSettings(Core::ICore::settings());
|
||||||
|
@@ -251,15 +251,15 @@ public:
|
|||||||
{
|
{
|
||||||
Core::ProgressManager::addTask(m_future.future(), "Install PyLS", installPylsTaskId);
|
Core::ProgressManager::addTask(m_future.future(), "Install PyLS", installPylsTaskId);
|
||||||
connect(&m_process,
|
connect(&m_process,
|
||||||
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
&QtcProcess::finished,
|
||||||
this,
|
this,
|
||||||
&PythonLSInstallHelper::installFinished);
|
&PythonLSInstallHelper::installFinished);
|
||||||
connect(&m_process,
|
connect(&m_process,
|
||||||
&QProcess::readyReadStandardError,
|
&QtcProcess::readyReadStandardError,
|
||||||
this,
|
this,
|
||||||
&PythonLSInstallHelper::errorAvailable);
|
&PythonLSInstallHelper::errorAvailable);
|
||||||
connect(&m_process,
|
connect(&m_process,
|
||||||
&QProcess::readyReadStandardOutput,
|
&QtcProcess::readyReadStandardOutput,
|
||||||
this,
|
this,
|
||||||
&PythonLSInstallHelper::outputAvailable);
|
&PythonLSInstallHelper::outputAvailable);
|
||||||
|
|
||||||
@@ -276,8 +276,8 @@ public:
|
|||||||
m_process.start();
|
m_process.start();
|
||||||
|
|
||||||
Core::MessageManager::writeDisrupting(
|
Core::MessageManager::writeDisrupting(
|
||||||
tr("Running \"%1 %2\" to install Python language server")
|
tr("Running \"%1\" to install Python language server")
|
||||||
.arg(m_process.program(), m_process.arguments().join(' ')));
|
.arg(m_process.commandLine().toUserOutput()));
|
||||||
|
|
||||||
m_killTimer.setSingleShot(true);
|
m_killTimer.setSingleShot(true);
|
||||||
m_killTimer.start(5 /*minutes*/ * 60 * 1000);
|
m_killTimer.start(5 /*minutes*/ * 60 * 1000);
|
||||||
|
@@ -127,7 +127,7 @@ EnvironmentItems QnxUtils::qnxEnvironmentFromEnvFile(const QString &fileName)
|
|||||||
return items;
|
return items;
|
||||||
|
|
||||||
// parsing process output
|
// parsing process output
|
||||||
QTextStream str(&process);
|
QTextStream str(process.ioDevice());
|
||||||
while (!str.atEnd()) {
|
while (!str.atEnd()) {
|
||||||
QString line = str.readLine();
|
QString line = str.readLine();
|
||||||
int equalIndex = line.indexOf(QLatin1Char('='));
|
int equalIndex = line.indexOf(QLatin1Char('='));
|
||||||
|
@@ -145,9 +145,8 @@ void WinRtDeviceFactory::autoDetect()
|
|||||||
if (!m_process) {
|
if (!m_process) {
|
||||||
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Creating process";
|
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Creating process";
|
||||||
m_process = new Utils::QtcProcess(this);
|
m_process = new Utils::QtcProcess(this);
|
||||||
connect(m_process, &QProcess::errorOccurred, this, &WinRtDeviceFactory::onProcessError);
|
connect(m_process, &QtcProcess::errorOccurred, this, &WinRtDeviceFactory::onProcessError);
|
||||||
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(m_process, &QtcProcess::finished, this, &WinRtDeviceFactory::onProcessFinished);
|
||||||
this, &WinRtDeviceFactory::onProcessFinished);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CommandLine cmd{runnerFilePath, {"--list-devices"}};
|
const CommandLine cmd{runnerFilePath, {"--list-devices"}};
|
||||||
|
@@ -211,12 +211,11 @@ void WinRtRunnerHelper::startWinRtRunner(const RunConf &conf)
|
|||||||
appendMessage(cmdLine.toUserOutput(), NormalMessageFormat);
|
appendMessage(cmdLine.toUserOutput(), NormalMessageFormat);
|
||||||
|
|
||||||
if (connectProcess) {
|
if (connectProcess) {
|
||||||
connect(process, &QProcess::started, this, &WinRtRunnerHelper::started);
|
connect(process, &QtcProcess::started, this, &WinRtRunnerHelper::started);
|
||||||
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(process, &QtcProcess::finished, this, &WinRtRunnerHelper::onProcessFinished);
|
||||||
this, &WinRtRunnerHelper::onProcessFinished);
|
connect(process, &QtcProcess::errorOccurred, this, &WinRtRunnerHelper::onProcessError);
|
||||||
connect(process, &QProcess::errorOccurred, this, &WinRtRunnerHelper::onProcessError);
|
connect(process, &QtcProcess::readyReadStandardOutput, this, &WinRtRunnerHelper::onProcessReadyReadStdOut);
|
||||||
connect(process, &QProcess::readyReadStandardOutput, this, &WinRtRunnerHelper::onProcessReadyReadStdOut);
|
connect(process, &QtcProcess::readyReadStandardError, this, &WinRtRunnerHelper::onProcessReadyReadStdErr);
|
||||||
connect(process, &QProcess::readyReadStandardError, this, &WinRtRunnerHelper::onProcessReadyReadStdErr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process->setUseCtrlCStub(true);
|
process->setUseCtrlCStub(true);
|
||||||
|
Reference in New Issue
Block a user