forked from qt-creator/qt-creator
Utils: Modernize ShellCommand and SynchronousProcess
* Reorder members to avoid padding * Use C++11 member initialization Change-Id: Ib04c2d59dfcf54f5df7afddc6e21197f1095e829 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
39a38d5679
commit
f07a309129
@@ -85,34 +85,25 @@ public:
|
|||||||
const QString m_defaultWorkingDirectory;
|
const QString m_defaultWorkingDirectory;
|
||||||
const QProcessEnvironment m_environment;
|
const QProcessEnvironment m_environment;
|
||||||
QVariant m_cookie;
|
QVariant m_cookie;
|
||||||
int m_defaultTimeoutS;
|
QTextCodec *m_codec = nullptr;
|
||||||
unsigned m_flags;
|
ProgressParser *m_progressParser = nullptr;
|
||||||
QTextCodec *m_codec;
|
|
||||||
ProgressParser *m_progressParser;
|
|
||||||
bool m_progressiveOutput;
|
|
||||||
bool m_hadOutput;
|
|
||||||
bool m_aborted;
|
|
||||||
QFutureWatcher<void> m_watcher;
|
QFutureWatcher<void> m_watcher;
|
||||||
|
|
||||||
QList<Job> m_jobs;
|
QList<Job> m_jobs;
|
||||||
|
|
||||||
bool m_lastExecSuccess;
|
unsigned m_flags = 0;
|
||||||
int m_lastExecExitCode;
|
int m_defaultTimeoutS = 10;
|
||||||
|
int m_lastExecExitCode = -1;
|
||||||
|
|
||||||
|
bool m_lastExecSuccess = false;
|
||||||
|
bool m_progressiveOutput = false;
|
||||||
|
bool m_hadOutput = false;
|
||||||
|
bool m_aborted = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
ShellCommandPrivate::ShellCommandPrivate(const QString &defaultWorkingDirectory,
|
ShellCommandPrivate::ShellCommandPrivate(const QString &defaultWorkingDirectory,
|
||||||
const QProcessEnvironment &environment) :
|
const QProcessEnvironment &environment) :
|
||||||
m_defaultWorkingDirectory(defaultWorkingDirectory),
|
m_defaultWorkingDirectory(defaultWorkingDirectory),
|
||||||
m_environment(environment),
|
m_environment(environment)
|
||||||
m_defaultTimeoutS(10),
|
|
||||||
m_flags(0),
|
|
||||||
m_codec(0),
|
|
||||||
m_progressParser(0),
|
|
||||||
m_progressiveOutput(false),
|
|
||||||
m_hadOutput(false),
|
|
||||||
m_aborted(false),
|
|
||||||
m_lastExecSuccess(false),
|
|
||||||
m_lastExecExitCode(-1)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
ShellCommandPrivate::~ShellCommandPrivate()
|
ShellCommandPrivate::~ShellCommandPrivate()
|
||||||
|
|||||||
@@ -153,24 +153,16 @@ SynchronousProcessResponse::Result ExitCodeInterpreter::interpretExitCode(int co
|
|||||||
|
|
||||||
// Data for one channel buffer (stderr/stdout)
|
// Data for one channel buffer (stderr/stdout)
|
||||||
struct ChannelBuffer {
|
struct ChannelBuffer {
|
||||||
ChannelBuffer();
|
|
||||||
void clearForRun();
|
void clearForRun();
|
||||||
QString linesRead();
|
QString linesRead();
|
||||||
|
|
||||||
QString data;
|
QString data;
|
||||||
bool firstData;
|
int bufferPos = 0;
|
||||||
bool bufferedSignalsEnabled;
|
bool firstData = true;
|
||||||
bool firstBuffer;
|
bool bufferedSignalsEnabled = false;
|
||||||
int bufferPos;
|
bool firstBuffer = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
ChannelBuffer::ChannelBuffer() :
|
|
||||||
firstData(true),
|
|
||||||
bufferedSignalsEnabled(false),
|
|
||||||
firstBuffer(true),
|
|
||||||
bufferPos(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChannelBuffer::clearForRun()
|
void ChannelBuffer::clearForRun()
|
||||||
{
|
{
|
||||||
@@ -200,32 +192,26 @@ struct SynchronousProcessPrivate {
|
|||||||
void clearForRun();
|
void clearForRun();
|
||||||
|
|
||||||
QTextCodec *m_codec;
|
QTextCodec *m_codec;
|
||||||
ExitCodeInterpreter *m_exitCodeInterpreter;
|
ExitCodeInterpreter *m_exitCodeInterpreter = nullptr;
|
||||||
QTextCodec::ConverterState m_stdOutState;
|
QTextCodec::ConverterState m_stdOutState;
|
||||||
QTextCodec::ConverterState m_stdErrState;
|
QTextCodec::ConverterState m_stdErrState;
|
||||||
TerminalControllingProcess m_process;
|
TerminalControllingProcess m_process;
|
||||||
QTimer m_timer;
|
QTimer m_timer;
|
||||||
QEventLoop m_eventLoop;
|
QEventLoop m_eventLoop;
|
||||||
SynchronousProcessResponse m_result;
|
SynchronousProcessResponse m_result;
|
||||||
int m_hangTimerCount;
|
|
||||||
int m_maxHangTimerCount;
|
|
||||||
bool m_startFailure;
|
|
||||||
bool m_timeOutMessageBoxEnabled;
|
|
||||||
bool m_waitingForUser;
|
|
||||||
QString m_binary;
|
QString m_binary;
|
||||||
|
|
||||||
ChannelBuffer m_stdOut;
|
ChannelBuffer m_stdOut;
|
||||||
ChannelBuffer m_stdErr;
|
ChannelBuffer m_stdErr;
|
||||||
|
|
||||||
|
int m_hangTimerCount = 0;
|
||||||
|
int m_maxHangTimerCount = defaultMaxHangTimerCount;
|
||||||
|
bool m_startFailure = false;
|
||||||
|
bool m_timeOutMessageBoxEnabled = false;
|
||||||
|
bool m_waitingForUser = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
SynchronousProcessPrivate::SynchronousProcessPrivate() :
|
SynchronousProcessPrivate::SynchronousProcessPrivate() :
|
||||||
m_codec(QTextCodec::codecForLocale()),
|
m_codec(QTextCodec::codecForLocale())
|
||||||
m_exitCodeInterpreter(0),
|
|
||||||
m_hangTimerCount(0),
|
|
||||||
m_maxHangTimerCount(defaultMaxHangTimerCount),
|
|
||||||
m_startFailure(false),
|
|
||||||
m_timeOutMessageBoxEnabled(false),
|
|
||||||
m_waitingForUser(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user