X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e528a71bf167f68b19a5cac0f1f63180d7509987..0d53638f7147c18153f63fdfc096b17be6e22a27:/src/unix/apptraits.cpp diff --git a/src/unix/apptraits.cpp b/src/unix/apptraits.cpp index a19b8e0e87..d29f9acdbb 100644 --- a/src/unix/apptraits.cpp +++ b/src/unix/apptraits.cpp @@ -3,7 +3,6 @@ // Purpose: implementation of wxGUIAppTraits for Unix systems // Author: Vadim Zeitlin // Created: 2008-03-22 -// RCS-ID: $Id$ // Copyright: (c) 2008 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -23,11 +22,14 @@ #pragma hdrstop #endif +#include "wx/apptrait.h" + #ifndef WX_PRECOMP + #include "wx/utils.h" #endif // WX_PRECOMP -#include "wx/apptrait.h" #include "wx/unix/execute.h" +#include "wx/evtloop.h" // ============================================================================ // implementation @@ -35,47 +37,15 @@ int wxGUIAppTraits::WaitForChild(wxExecuteData& execData) { - const int flags = execData.flags; - if ( !(flags & wxEXEC_SYNC) || (flags & wxEXEC_NOEVENTS) ) - { - // async or blocking sync cases are already handled by the base class - // just fine, no need to duplicate its code here - return wxAppTraits::WaitForChild(execData); - } - - // here we're dealing with the case of synchronous execution when we want - // to process the GUI events while waiting for the child termination - - wxEndProcessData endProcData; - endProcData.pid = execData.pid; - endProcData.tag = AddProcessCallback - ( - &endProcData, - execData.GetEndProcReadFD() - ); - endProcData.async = false; - - // prepare to wait for the child termination: show to the user that we're // busy and refuse all input unless explicitly told otherwise wxBusyCursor bc; - wxWindowDisabler wd(!(flags & wxEXEC_NODISABLE)); - - // endProcData.pid will be set to 0 from wxHandleProcessTermination() when - // the process terminates - while ( endProcData.pid != 0 ) - { - // don't consume 100% of the CPU while we're sitting in this - // loop - if ( !CheckForRedirectedIO(execData) ) - wxMilliSleep(1); + wxWindowDisabler wd(!(execData.flags & wxEXEC_NODISABLE)); - // give the toolkit a chance to call wxHandleProcessTermination() here - // and also repaint the GUI and handle other accumulated events - wxYield(); - } - - return endProcData.exitcode; + // Allocate an event loop that will be used to wait for the process + // to terminate, will handle stdout, stderr, and any other events and pass + // it to the common (to console and GUI) code which will run it. + wxGUIEventLoop loop; + return RunLoopUntilChildExit(execData, loop); } -