diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-09-07 17:07:26 +0300 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2021-09-08 17:21:05 +0000 |
commit | 400a7c540e966b556f6c02d78888386c4fddc2d6 (patch) | |
tree | 36ca53e8d0cfd98276333981bdbff651865d50f5 | |
parent | a72066f449cefecb2cf6c822b0040b082d0b4156 (diff) |
QWindowsPipeWriter: stop reporting errors from write()
To match the Unix behavior, callers of the write() function (i. e.
QProcess::writeData() or QLocalSocket::writeData()) should return -1
only if the pipe is already closed. All data being written must be
buffered and no state transition is allowed in response to this call.
Considering the fact that all callers ignore the return value of the
write() function, there is no point in returning anything other than
void.
Change-Id: I52480fc453e076920209bb8e3d52813279393d70
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | src/corelib/io/qwindowspipewriter.cpp | 21 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipewriter_p.h | 6 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index e1213e5185..182c3e3c6f 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -126,41 +126,38 @@ qint64 QWindowsPipeWriter::bytesToWrite() const /*! Writes a shallow copy of \a ba to the internal buffer. */ -bool QWindowsPipeWriter::write(const QByteArray &ba) +void QWindowsPipeWriter::write(const QByteArray &ba) { - return writeImpl(ba); + writeImpl(ba); } /*! Writes data to the internal buffer. */ -bool QWindowsPipeWriter::write(const char *data, qint64 size) +void QWindowsPipeWriter::write(const char *data, qint64 size) { - return writeImpl(data, size); + writeImpl(data, size); } template <typename... Args> -inline bool QWindowsPipeWriter::writeImpl(Args... args) +inline void QWindowsPipeWriter::writeImpl(Args... args) { QMutexLocker locker(&mutex); if (lastError != ERROR_SUCCESS) - return false; + return; writeBuffer.append(args...); if (writeSequenceStarted) - return true; + return; stopped = false; // If we don't have an assigned handle yet, defer writing until // setHandle() is called. - if (handle == INVALID_HANDLE_VALUE) - return true; - - startAsyncWriteLocked(&locker); - return true; + if (handle != INVALID_HANDLE_VALUE) + startAsyncWriteLocked(&locker); } /*! diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index 8a3b3068e5..ebd48260ba 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -68,8 +68,8 @@ public: ~QWindowsPipeWriter(); void setHandle(HANDLE hPipeWriteEnd); - bool write(const QByteArray &ba); - bool write(const char *data, qint64 size); + void write(const QByteArray &ba); + void write(const char *data, qint64 size); void stop(); bool checkForWrite() { return consumePendingAndEmit(false); } qint64 bytesToWrite() const; @@ -83,7 +83,7 @@ protected: private: template <typename... Args> - inline bool writeImpl(Args... args); + inline void writeImpl(Args... args); void startAsyncWriteLocked(QMutexLocker<QMutex> *locker); static void CALLBACK waitCallback(PTP_CALLBACK_INSTANCE instance, PVOID context, |