diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-04-15 13:02:32 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-04-15 12:17:25 +0000 |
commit | a07203f182052f2f590dba03f6ee902fdc2aeebb (patch) | |
tree | 32da5a68fce406bf3272eff5ff352f5a9c26d5f4 /src | |
parent | dcbb9872d3ef87e809e58329a00414f2e6a11f25 (diff) |
Session handling: Do not ignore return value of I/O functions
... on Windows.
Task-number: QTCREATORBUG-23839
Change-Id: I7b2bc8318dd5fe39583bc7ed0367425e1d062171
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/app/qbs/stdinreader.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/app/qbs/stdinreader.cpp b/src/app/qbs/stdinreader.cpp index 1ae662aab..5f00d7de4 100644 --- a/src/app/qbs/stdinreader.cpp +++ b/src/app/qbs/stdinreader.cpp @@ -124,14 +124,22 @@ private: // (how would we abort that one?), but ideally we'd like // to have a signal-based approach like in the Unix variant. const auto timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, [this] { + connect(timer, &QTimer::timeout, this, [this, timer] { char buf[1024]; DWORD bytesAvail; - PeekNamedPipe(m_stdinHandle, nullptr, 0, nullptr, &bytesAvail, nullptr); + if (!PeekNamedPipe(m_stdinHandle, nullptr, 0, nullptr, &bytesAvail, nullptr)) { + timer->stop(); + emit errorOccurred(tr("Failed to read from input channel.")); + return; + } while (bytesAvail > 0) { DWORD bytesRead; - ReadFile(m_stdinHandle, buf, std::min<DWORD>(bytesAvail, sizeof buf), &bytesRead, - nullptr); + if (!ReadFile(m_stdinHandle, buf, std::min<DWORD>(bytesAvail, sizeof buf), + &bytesRead, nullptr)) { + timer->stop(); + emit errorOccurred(tr("Failed to read from input channel.")); + return; + } emit dataAvailable(QByteArray(buf, bytesRead)); bytesAvail -= bytesRead; } |