Files
qt-creator/src/libs/utils/terminalprocess_p.h
Jarek Kobus 936c44f367 Introduce ProcessResultData
It should be useful when reimplementing ProcessInterface.
It replaces 4 virtual methods with just 1.

Task-number: QTCREATORBUG-27358
Change-Id: I2dafbfbc25f8f016ff2aa19c1a176335a4a7498c
Reviewed-by: hjk <hjk@qt.io>
2022-04-11 06:51:51 +00:00

97 lines
3.2 KiB
C++

/****************************************************************************
**
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "processenums.h"
#include "processinterface.h"
#include "qtcassert.h"
#include <QProcess>
namespace Utils {
class CommandLine;
class Environment;
class FilePath;
namespace Internal {
class TerminalImpl final : public ProcessInterface
{
public:
TerminalImpl();
~TerminalImpl() final;
QByteArray readAllStandardOutput() final { QTC_CHECK(false); return {}; }
QByteArray readAllStandardError() final { QTC_CHECK(false); return {}; }
qint64 write(const QByteArray &) final { QTC_CHECK(false); return -1; }
void terminate() final { stopProcess(); }
void kill() final { stopProcess(); }
void close() final { stopProcess(); }
// intentionally no-op without an assert
bool waitForStarted(int) final { return false; }
bool waitForReadyRead(int) final { QTC_CHECK(false); return false; }
// intentionally no-op without an assert
bool waitForFinished(int) final { return false; }
void start() final;
QProcess::ProcessState state() const final;
qint64 processId() const final;
ProcessResultData resultData() const final;
void kickoffProcess() final; // only debugger terminal, only non-windows
void interrupt() final; // only debugger terminal, only non-windows
qint64 applicationMainThreadID() const final; // only debugger terminal, only windows (-1 otherwise)
private:
// OK, however, impl looks a bit different (!= NotRunning vs == Running).
// Most probably changing it into (== Running) should be OK.
bool isRunning() const;
void stopProcess();
void stubConnectionAvailable();
void readStubOutput();
void stubExited();
void cleanupAfterStartFailure(const QString &errorMessage);
void finish(int exitCode, QProcess::ExitStatus exitStatus);
void killProcess();
void killStub();
void emitError(QProcess::ProcessError err, const QString &errorString);
QString stubServerListen();
void stubServerShutdown();
void cleanupStub();
void cleanupInferior();
class TerminalProcessPrivate *d;
};
} // Internal
} // Utils