wxEVT_COMMAND_MENU_SELECTED is now wxEVT_MENU (but the old name remains
available for compatibility) (Catalin Raceanu).
- Fix wxExecute() implementation under Unix (Rob Bresalier).
+- Also fix reading output from children exiting with -1 () (Jonathan Dagresta).
- Add wxEvtHandler::CallAfter() method for asynchronous method calls.
- Add support for symlinks to wxFileName (David Hart).
- Add wxDIR_NO_FOLLOW flag for wxDir traversal (David Hart).
wxLogStatus("Command \"%s\" terminated after %ldms; exit code %d.",
cmd, sw.Time(), code);
- if ( code != -1 )
- {
- ShowOutput(cmd, output, wxT("Output"));
- ShowOutput(cmd, errors, wxT("Errors"));
- }
+ ShowOutput(cmd, output, wxT("Output"));
+ ShowOutput(cmd, errors, wxT("Errors"));
}
else // async exec
{
// wxExecute
// ----------------------------------------------------------------------------
-// wxDoExecuteWithCapture() helper: reads an entire stream into one array
+// wxDoExecuteWithCapture() helper: reads an entire stream into one array if
+// the stream is non-NULL (it doesn't do anything if it's NULL).
//
// returns true if ok, false if error
#if wxUSE_STREAMS
static bool ReadAll(wxInputStream *is, wxArrayString& output)
{
- wxCHECK_MSG( is, false, wxT("NULL stream in wxExecute()?") );
+ if ( !is )
+ return true;
// the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state
is->Reset();
long rc = wxExecute(command, wxEXEC_SYNC | flags, process, env);
#if wxUSE_STREAMS
- if ( rc != -1 )
+ // Notice that while -1 indicates an error exit code for us, a program
+ // exiting with this code could still have written something to its stdout
+ // and, especially, stderr, so we still need to read from them.
+ if ( !ReadAll(process->GetInputStream(), output) )
+ rc = -1;
+
+ if ( error )
{
- if ( !ReadAll(process->GetInputStream(), output) )
+ if ( !ReadAll(process->GetErrorStream(), *error) )
rc = -1;
-
- if ( error )
- {
- if ( !ReadAll(process->GetErrorStream(), *error) )
- rc = -1;
- }
-
}
#else
wxUnusedVar(output);