X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a278e7befe2b9989526067dede645fb11ad779b..c7382f913cc2d3ddcc782b876574c58865e7d842:/samples/exec/exec.cpp?ds=sidebyside diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index 969f242b46..3ee7e3b60e 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -1053,9 +1053,9 @@ MyPipeFrame::MyPipeFrame(wxFrame *parent, : wxFrame(parent, wxID_ANY, cmd), m_process(process), // in a real program we'd check that the streams are !NULL here + m_out(*process->GetOutputStream()), m_in(*process->GetInputStream()), - m_err(*process->GetErrorStream()), - m_out(*process->GetOutputStream()) + m_err(*process->GetErrorStream()) { m_process->SetNextHandler(this); @@ -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;