From: Vadim Zeitlin Date: Wed, 21 Jul 2004 10:41:17 +0000 (+0000) Subject: corrected code to not suppose that Write() always writes all the data it was given X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/42d0aa30b801d8c2ea7cd16a2a191bec4fbfa876?hp=3338a5bde55eabf53f0aea4eb9f01a8b45b4039d corrected code to not suppose that Write() always writes all the data it was given git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28351 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index 969f242b46..2ff98f2610 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -1114,9 +1114,11 @@ void MyPipeFrame::OnBtnSendFile(wxCommandEvent& WXUNUSED(event)) while ( len ) { const size_t CHUNK_SIZE = 4096; - size_t lenChunk = len > CHUNK_SIZE ? CHUNK_SIZE : len; + m_out.Write(pc, len > CHUNK_SIZE ? CHUNK_SIZE : len); - m_out.Write(pc, lenChunk); + // note that not all data could have been written as we don't block on + // the write end of the pipe + const size_t lenChunk = m_out.LastWrite(); pc += lenChunk; len -= lenChunk;