From 013b6cf0f15b2e770a0e51be745e4484e89ea926 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 2 Oct 2020 09:53:12 +0200 Subject: QProcessPrivate: Use member initialization Change-Id: I9fb8120a68daaa41c153010a52f7a3e99087153b Reviewed-by: Volker Hilsheimer Reviewed-by: Thiago Macieira --- src/corelib/io/qprocess.cpp | 21 --------------------- src/corelib/io/qprocess_p.h | 36 ++++++++++++++++++------------------ 2 files changed, 18 insertions(+), 39 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 8b35836584..a7be5f2708 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -828,27 +828,6 @@ QProcessPrivate::QProcessPrivate() { readBufferChunkSize = QRINGBUFFER_CHUNKSIZE; writeBufferChunkSize = QRINGBUFFER_CHUNKSIZE; - processChannelMode = QProcess::SeparateChannels; - inputChannelMode = QProcess::ManagedInputChannel; - processError = QProcess::UnknownError; - processState = QProcess::NotRunning; - pid = 0; - sequenceNumber = 0; - exitCode = 0; - exitStatus = QProcess::NormalExit; - startupSocketNotifier = nullptr; - deathNotifier = nullptr; - childStartedPipe[0] = INVALID_Q_PIPE; - childStartedPipe[1] = INVALID_Q_PIPE; - forkfd = -1; - crashed = false; - dying = false; - emittedReadyRead = false; - emittedBytesWritten = false; -#ifdef Q_OS_WIN - stdinWriteTrigger = 0; - processFinishedNotifier = 0; -#endif // Q_OS_WIN } /*! diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 7cb70cc95c..dec2ea0703 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -297,17 +297,17 @@ public: bool _q_startupNotification(); bool _q_processDied(); - QProcess::ProcessChannelMode processChannelMode; - QProcess::InputChannelMode inputChannelMode; - QProcess::ProcessError processError; - QProcess::ProcessState processState; + QProcess::ProcessChannelMode processChannelMode = QProcess::SeparateChannels; + QProcess::InputChannelMode inputChannelMode = QProcess::ManagedInputChannel; + QProcess::ProcessError processError = QProcess::UnknownError; + QProcess::ProcessState processState = QProcess::NotRunning; QString workingDirectory; - Q_PID pid; - int sequenceNumber; + Q_PID pid = 0; + int sequenceNumber = 0; - bool dying; - bool emittedReadyRead; - bool emittedBytesWritten; + bool dying = false; + bool emittedReadyRead = false; + bool emittedBytesWritten = false; Channel stdinChannel; Channel stdoutChannel; @@ -327,17 +327,17 @@ public: #endif QProcessEnvironment environment; - Q_PIPE childStartedPipe[2]; + Q_PIPE childStartedPipe[2] = {INVALID_Q_PIPE, INVALID_Q_PIPE}; void destroyPipe(Q_PIPE pipe[2]); - QSocketNotifier *startupSocketNotifier; - QSocketNotifier *deathNotifier; + QSocketNotifier *startupSocketNotifier = nullptr; + QSocketNotifier *deathNotifier = nullptr; - int forkfd; + int forkfd = -1; #ifdef Q_OS_WIN - QTimer *stdinWriteTrigger; - QWinEventNotifier *processFinishedNotifier; + QTimer *stdinWriteTrigger = nullptr; + QWinEventNotifier *processFinishedNotifier = nullptr; #endif void start(QIODevice::OpenMode mode); @@ -361,9 +361,9 @@ public: bool startDetached(qint64 *pPid); - int exitCode; - QProcess::ExitStatus exitStatus; - bool crashed; + int exitCode = 0; + QProcess::ExitStatus exitStatus = QProcess::NormalExit; + bool crashed = false; bool waitForStarted(int msecs = 30000); bool waitForReadyRead(int msecs = 30000); -- cgit v1.2.3