QProcess: refine 'Channel' structure

- exclude unused notifier pointer on Windows;
- use default initialization for members;
- avoid bit fields in declarations as there are extra
  padding bytes anyway.

Change-Id: I2e03c4c269c885c90c0a6d18b8a935885f4b3feb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
Alex Trotsenko 2021-06-02 16:03:31 +03:00
parent 2b52452843
commit 01639b7cc2
2 changed files with 12 additions and 19 deletions

View File

@ -391,6 +391,8 @@ void QProcessPrivate::Channel::clear()
process->stdoutChannel.type = Normal;
process->stdoutChannel.process = nullptr;
break;
default:
break;
}
type = Normal;

View File

@ -231,23 +231,13 @@ public:
Q_DECLARE_PUBLIC(QProcess)
struct Channel {
enum ProcessChannelType {
enum ProcessChannelType : char {
Normal = 0,
PipeSource = 1,
PipeSink = 2,
Redirect = 3
// if you add "= 4" here, increase the number of bits below
};
Channel() : process(nullptr), notifier(nullptr), type(Normal), closed(false), append(false)
{
pipe[0] = INVALID_Q_PIPE;
pipe[1] = INVALID_Q_PIPE;
#ifdef Q_OS_WIN
reader = 0;
#endif
}
void clear();
Channel &operator=(const QString &fileName)
@ -273,19 +263,20 @@ public:
}
QString file;
QProcessPrivate *process;
QSocketNotifier *notifier;
#ifdef Q_OS_WIN
QProcessPrivate *process = nullptr;
#ifdef Q_OS_UNIX
QSocketNotifier *notifier = nullptr;
#else
union {
QWindowsPipeReader *reader;
QWindowsPipeReader *reader = nullptr;
QWindowsPipeWriter *writer;
};
#endif
Q_PIPE pipe[2];
Q_PIPE pipe[2] = {INVALID_Q_PIPE, INVALID_Q_PIPE};
unsigned type : 2;
bool closed : 1;
bool append : 1;
ProcessChannelType type = Normal;
bool closed = false;
bool append = false;
};
QProcessPrivate();