X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f81bc2ba5e51269c2a079a0524a919fc2f0fcaf0..0d53638f7147c18153f63fdfc096b17be6e22a27:/src/common/utilscmn.cpp diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index a451976b17..6c597072a9 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -4,7 +4,6 @@ // Author: Julian Smart // Modified by: // Created: 29/01/98 -// RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -618,13 +617,15 @@ bool wxGetEnvMap(wxEnvVariableHashMap *map) // 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(); @@ -671,17 +672,16 @@ static long wxDoExecuteWithCapture(const wxString& command, 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); @@ -713,9 +713,9 @@ long wxExecute(const wxString& command, // ---------------------------------------------------------------------------- // Id generation -static long wxCurrentId = 100; +static int wxCurrentId = 100; -long wxNewId() +int wxNewId() { // skip the part of IDs space that contains hard-coded values: if (wxCurrentId == wxID_LOWEST) @@ -724,11 +724,11 @@ long wxNewId() return wxCurrentId++; } -long +int wxGetCurrentId(void) { return wxCurrentId; } void -wxRegisterId (long id) +wxRegisterId (int id) { if (id >= wxCurrentId) wxCurrentId = id + 1;