]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/exec/exec.cpp
SetBackgroundStyle(wxBG_STYLE_CUSTOM) can now be used to optimize
[wxWidgets.git] / samples / exec / exec.cpp
index 969f242b46d09b4d2a90dfb8c725217e167075bc..3ee7e3b60e7b7571df452c679fded09e910f1a87 100644 (file)
@@ -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;