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>
This commit is contained in:
parent
a72066f449
commit
400a7c540e
@ -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);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user