diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2023-03-16 20:53:37 -0700 |
|---|---|---|
| committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-05-15 00:12:39 +0200 |
| commit | 2b98dd7645544c27ed0a363810eb784aa53d293f (patch) | |
| tree | 33dad52daed0dd2509d4bd3b69e42e4d567bdf15 /src/corelib/io/qprocess.cpp | |
| parent | 7dba2c87619d558a61a30eb30cc1d9c3fe6df94c (diff) | |
QProcessPrivate: repack and reorganize the members
Reduce the number of #ifdef blocks and use quint8 for the enums that
don't need more than 8 bits anyway (none of them do). Plus move the
std::function callback to an indirect block, as most users of QProcess
won't set them and this type is 4 pointers with libstdc++ and libc++.
After this, QProcessPrivate on 64-bit Unix is 688 bytes, of which:
- 392 bytes from QIODevicePrivate
- 295 bytes of own data
- 3x56 bytes per Channel (which have 5 bytes of tail padding each)
- 1 byte of tail padding and no middle padding
Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d188a0821d060
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
| -rw-r--r-- | src/corelib/io/qprocess.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 116bb78b8aa..41a7fffd8bd 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -922,7 +922,7 @@ void QProcessPrivate::setErrorAndEmit(QProcess::ProcessError error, const QStrin Q_Q(QProcess); Q_ASSERT(error != QProcess::UnknownError); setError(error, description); - emit q->errorOccurred(processError); + emit q->errorOccurred(QProcess::ProcessError(processError)); } /*! @@ -1154,7 +1154,7 @@ void QProcessPrivate::processFinished() //emit q->standardOutputClosed(); //emit q->standardErrorClosed(); - emit q->finished(exitCode, exitStatus); + emit q->finished(exitCode, QProcess::ExitStatus(exitStatus)); #if defined QPROCESS_DEBUG qDebug("QProcessPrivate::processFinished(): process is dead"); @@ -1239,7 +1239,7 @@ QProcess::~QProcess() QProcess::ProcessChannelMode QProcess::processChannelMode() const { Q_D(const QProcess); - return d->processChannelMode; + return ProcessChannelMode(d->processChannelMode); } /*! @@ -1269,7 +1269,7 @@ void QProcess::setProcessChannelMode(ProcessChannelMode mode) QProcess::InputChannelMode QProcess::inputChannelMode() const { Q_D(const QProcess); - return d->inputChannelMode; + return InputChannelMode(d->inputChannelMode); } /*! @@ -1558,7 +1558,7 @@ void QProcess::setCreateProcessArgumentsModifier(CreateProcessArgumentModifier m std::function<void(void)> QProcess::childProcessModifier() const { Q_D(const QProcess); - return d->childProcessModifier; + return d->unixExtras ? d->unixExtras->childProcessModifier : std::function<void(void)>(); } /*! @@ -1602,7 +1602,9 @@ std::function<void(void)> QProcess::childProcessModifier() const void QProcess::setChildProcessModifier(const std::function<void(void)> &modifier) { Q_D(QProcess); - d->childProcessModifier = modifier; + if (!d->unixExtras) + d->unixExtras.reset(new QProcessPrivate::UnixExtras); + d->unixExtras->childProcessModifier = modifier; } #endif @@ -1693,7 +1695,7 @@ qint64 QProcess::bytesToWrite() const QProcess::ProcessError QProcess::error() const { Q_D(const QProcess); - return d->processError; + return ProcessError(d->processError); } /*! @@ -1704,7 +1706,7 @@ QProcess::ProcessError QProcess::error() const QProcess::ProcessState QProcess::state() const { Q_D(const QProcess); - return d->processState; + return ProcessState(d->processState); } /*! @@ -2373,7 +2375,7 @@ int QProcess::exitCode() const QProcess::ExitStatus QProcess::exitStatus() const { Q_D(const QProcess); - return d->exitStatus; + return ExitStatus(d->exitStatus); } /*! |
