X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e2478fde622a16d25c66690af353dfdc37e7b582..d223107206e4dfa6768e0bc2455325dd49e4d2bb:/src/unix/utilsunx.cpp diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index f6d60dcf32..2447a559fd 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -15,12 +15,16 @@ // headers // ---------------------------------------------------------------------------- +// for compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + #include "wx/defs.h" #include "wx/string.h" #include "wx/intl.h" #include "wx/log.h" #include "wx/app.h" +#include "wx/apptrait.h" #include "wx/utils.h" #include "wx/process.h" @@ -30,7 +34,15 @@ #include "wx/unix/execute.h" -#ifdef __WXBASE__ +#if wxUSE_STREAMS + +// define this to let wxexec.cpp know that we know what we're doing +#define _WX_USED_BY_WXEXECUTE_ +#include "../common/execcmn.cpp" + +#endif // wxUSE_STREAMS + +#if wxUSE_BASE #if defined( __MWERKS__ ) && defined(__MACH__) #define WXWIN_OS_DESCRIPTION "MacOS X" @@ -346,22 +358,6 @@ bool wxShutdown(wxShutdownFlags wFlags) #if wxUSE_STREAMS -// ---------------------------------------------------------------------------- -// wxPipeInputStream: stream for reading from a pipe -// ---------------------------------------------------------------------------- - -class wxPipeInputStream : public wxFileInputStream -{ -public: - wxPipeInputStream(int fd) : wxFileInputStream(fd) { } - - // return TRUE if the pipe is still opened - bool IsOpened() const { return !Eof(); } - - // return TRUE if we have anything to read, don't block - virtual bool CanRead() const; -}; - bool wxPipeInputStream::CanRead() const { if ( m_lasterror == wxSTREAM_EOF ) @@ -398,10 +394,6 @@ bool wxPipeInputStream::CanRead() const } } -// define this to let wxexec.cpp know that we know what we're doing -#define _WX_USED_BY_WXEXECUTE_ -#include "../common/execcmn.cpp" - #endif // wxUSE_STREAMS // ---------------------------------------------------------------------------- @@ -585,6 +577,9 @@ long wxExecute(wxChar **argv, { ARGS_CLEANUP; + // save it for WaitForChild() use + execData.pid = pid; + // prepare for IO redirection #if wxUSE_STREAMS @@ -828,17 +823,6 @@ wxString wxGetOsDescription() #endif // !__WXMAC__ -int wxGetOsVersion(int *verMaj, int *verMin) -{ - // we want this function to work even if there is no wxApp - wxConsoleAppTraits traitsConsole; - wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL; - if ( ! traits ) - traits = &traitsConsole; - - return traits->GetOSVersion(verMaj, verMin); -} - unsigned long wxGetProcessId() { return (unsigned long)getpid(); @@ -1060,7 +1044,7 @@ void wxFatalError( const wxString &msg, const wxString &title ) #endif // WXWIN_COMPATIBILITY_2_2 -#endif // __WXBASE__ +#endif // wxUSE_BASE #if wxUSE_GUI @@ -1079,7 +1063,7 @@ bool wxGUIAppTraits::CreateEndProcessPipe(wxExecuteData& execData) bool wxGUIAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd) { - return fd == execData.pipeEndProcDetect[wxPipe::Write] + return fd == (execData.pipeEndProcDetect)[wxPipe::Write]; } void wxGUIAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& execData) @@ -1157,14 +1141,27 @@ int wxGUIAppTraits::WaitForChild(wxExecuteData& execData) // process terminates while ( endProcData->pid != 0 ) { + bool idle = true; + #if wxUSE_STREAMS if ( execData.bufOut ) + { execData.bufOut->Update(); + idle = false; + } if ( execData.bufErr ) + { execData.bufErr->Update(); + idle = false; + } #endif // wxUSE_STREAMS + // don't consume 100% of the CPU while we're sitting this in this + // loop + if ( idle ) + wxUsleep(1); + // give GTK+ a chance to call GTK_EndProcessDetector here and // also repaint the GUI wxYield(); @@ -1182,6 +1179,9 @@ int wxGUIAppTraits::WaitForChild(wxExecuteData& execData) } } +#endif // wxUSE_GUI +#if wxUSE_BASE + void wxHandleProcessTermination(wxEndProcessData *proc_data) { // notify user about termination if required @@ -1202,5 +1202,4 @@ void wxHandleProcessTermination(wxEndProcessData *proc_data) } } -#endif // wxUSE_GUI - +#endif // wxUSE_BASE