summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2021-09-11 17:32:09 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2021-09-18 13:50:28 +0300
commitb2c3b3e8fe0d8bdc88051d0120aaa8d5cf8acce0 (patch)
tree6d3bdfc75dfb1870202b82ef4fcba19e30d6ede6 /src/corelib/io
parentf4aaba593c743af870fe224b4186225d67b617fc (diff)
Q{LocalSocket|Process}/Win: handle write errors
To match the Unix behavior, we should emit errorOccurred() signal and close the channel if the write operation fails. Change-Id: Iac3acb18dbbfe6e7e8afb2555d9adaff1fe98d0f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qprocess_p.h1
-rw-r--r--src/corelib/io/qprocess_win.cpp8
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp1
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h1
4 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 74ab6ab409..4b38f191d5 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -287,6 +287,7 @@ public:
#ifdef Q_OS_WIN
qint64 pipeWriterBytesToWrite() const;
void _q_bytesWritten(qint64 bytes);
+ void _q_writeFailed();
#else
bool _q_canWrite();
bool writeToStdin();
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index f935e4f491..b2e8beaa53 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -841,6 +841,8 @@ qint64 QProcess::writeData(const char *data, qint64 len)
d->stdinChannel.writer = new QWindowsPipeWriter(d->stdinChannel.pipe[1], this);
QObjectPrivate::connect(d->stdinChannel.writer, &QWindowsPipeWriter::bytesWritten,
d, &QProcessPrivate::_q_bytesWritten);
+ QObjectPrivate::connect(d->stdinChannel.writer, &QWindowsPipeWriter::writeFailed,
+ d, &QProcessPrivate::_q_writeFailed);
}
if (d->isWriteChunkCached(data, len))
@@ -872,6 +874,12 @@ void QProcessPrivate::_q_bytesWritten(qint64 bytes)
closeWriteChannel();
}
+void QProcessPrivate::_q_writeFailed()
+{
+ closeWriteChannel();
+ setErrorAndEmit(QProcess::WriteError);
+}
+
// Use ShellExecuteEx() to trigger an UAC prompt when CreateProcess()fails
// with ERROR_ELEVATION_REQUIRED.
static bool startDetachedUacPrompt(const QString &programIn, const QStringList &arguments,
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index 843ff6a00b..3024742d34 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -341,6 +341,7 @@ bool QWindowsPipeWriter::consumePendingAndEmit(bool allowWinActPosting)
if (alive) {
writeBuffer.clear();
completionState = WriteDisabled;
+ emit writeFailed();
}
} else if (emitBytesWritten) {
emit bytesWritten(numberOfBytesWritten);
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h
index 81a586dc3d..71e47c9787 100644
--- a/src/corelib/io/qwindowspipewriter_p.h
+++ b/src/corelib/io/qwindowspipewriter_p.h
@@ -78,6 +78,7 @@ public:
Q_SIGNALS:
void bytesWritten(qint64 bytes);
+ void writeFailed();
protected:
bool event(QEvent *e) override;