Use "m_" prefix for wxExecuteData members
No real changes, just rename the members to use the standard prefix which is more consistent with the rest of wxWidgets and also allows to avoid both the hacks with "foo_" names for the arguments of some functions that were used to avoid the conflicts with member "foo" and at least one remaining shadowing warning for "exitcode".
This commit is contained in:
parent
5020a810db
commit
5d770e5cbe
@ -27,17 +27,17 @@ class wxExecuteData
|
|||||||
public:
|
public:
|
||||||
wxExecuteData()
|
wxExecuteData()
|
||||||
{
|
{
|
||||||
flags =
|
m_flags =
|
||||||
pid = 0;
|
m_pid = 0;
|
||||||
exitcode = -1;
|
m_exitcode = -1;
|
||||||
|
|
||||||
process = NULL;
|
m_process = NULL;
|
||||||
|
|
||||||
syncEventLoop = NULL;
|
m_syncEventLoop = NULL;
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
fdOut =
|
m_fdOut =
|
||||||
fdErr = wxPipe::INVALID_FD;
|
m_fdErr = wxPipe::INVALID_FD;
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,36 +51,36 @@ public:
|
|||||||
void OnExit(int exitcode);
|
void OnExit(int exitcode);
|
||||||
|
|
||||||
// Return true if we should (or already did) redirect the child IO.
|
// Return true if we should (or already did) redirect the child IO.
|
||||||
bool IsRedirected() const { return process && process->IsRedirected(); }
|
bool IsRedirected() const { return m_process && m_process->IsRedirected(); }
|
||||||
|
|
||||||
|
|
||||||
// wxExecute() flags
|
// wxExecute() flags
|
||||||
int flags;
|
int m_flags;
|
||||||
|
|
||||||
// the pid of the child process
|
// the pid of the child process
|
||||||
int pid;
|
int m_pid;
|
||||||
|
|
||||||
// The exit code of the process, set once the child terminates.
|
// The exit code of the process, set once the child terminates.
|
||||||
int exitcode;
|
int m_exitcode;
|
||||||
|
|
||||||
// the associated process object or NULL
|
// the associated process object or NULL
|
||||||
wxProcess *process;
|
wxProcess *m_process;
|
||||||
|
|
||||||
// Local event loop used to wait for the child process termination in
|
// Local event loop used to wait for the child process termination in
|
||||||
// synchronous execution case. We can't create it ourselves as its exact
|
// synchronous execution case. We can't create it ourselves as its exact
|
||||||
// type depends on the application kind (console/GUI), so we rely on
|
// type depends on the application kind (console/GUI), so we rely on
|
||||||
// wxAppTraits setting up this pointer to point to the appropriate object.
|
// wxAppTraits setting up this pointer to point to the appropriate object.
|
||||||
wxEventLoopBase *syncEventLoop;
|
wxEventLoopBase *m_syncEventLoop;
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
// the input buffer bufOut is connected to stdout, this is why it is
|
// the input buffer bufOut is connected to stdout, this is why it is
|
||||||
// called bufOut and not bufIn
|
// called bufOut and not bufIn
|
||||||
wxStreamTempInputBuffer bufOut,
|
wxStreamTempInputBuffer m_bufOut,
|
||||||
bufErr;
|
m_bufErr;
|
||||||
|
|
||||||
// the corresponding FDs, -1 if not redirected
|
// the corresponding FDs, -1 if not redirected
|
||||||
int fdOut,
|
int m_fdOut,
|
||||||
fdErr;
|
m_fdErr;
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ int wxGUIAppTraits::WaitForChild(wxExecuteData& execData)
|
|||||||
// prepare to wait for the child termination: show to the user that we're
|
// prepare to wait for the child termination: show to the user that we're
|
||||||
// busy and refuse all input unless explicitly told otherwise
|
// busy and refuse all input unless explicitly told otherwise
|
||||||
wxBusyCursor bc;
|
wxBusyCursor bc;
|
||||||
wxWindowDisabler wd(!(execData.flags & wxEXEC_NODISABLE));
|
wxWindowDisabler wd(!(execData.m_flags & wxEXEC_NODISABLE));
|
||||||
|
|
||||||
// Allocate an event loop that will be used to wait for the process
|
// 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
|
// to terminate, will handle stdout, stderr, and any other events and pass
|
||||||
|
@ -535,25 +535,25 @@ int BlockUntilChildExit(wxExecuteData& execData)
|
|||||||
stdoutHandler.reset(new wxExecuteFDIOHandler
|
stdoutHandler.reset(new wxExecuteFDIOHandler
|
||||||
(
|
(
|
||||||
dispatcher,
|
dispatcher,
|
||||||
execData.fdOut,
|
execData.m_fdOut,
|
||||||
execData.bufOut
|
execData.m_bufOut
|
||||||
));
|
));
|
||||||
stderrHandler.reset(new wxExecuteFDIOHandler
|
stderrHandler.reset(new wxExecuteFDIOHandler
|
||||||
(
|
(
|
||||||
dispatcher,
|
dispatcher,
|
||||||
execData.fdErr,
|
execData.m_fdErr,
|
||||||
execData.bufErr
|
execData.m_bufErr
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
// And dispatch until the PID is reset from wxExecuteData::OnExit().
|
// And dispatch until the PID is reset from wxExecuteData::OnExit().
|
||||||
while ( execData.pid )
|
while ( execData.m_pid )
|
||||||
{
|
{
|
||||||
dispatcher.Dispatch();
|
dispatcher.Dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
return execData.exitcode;
|
return execData.m_exitcode;
|
||||||
#else // !wxUSE_SELECT_DISPATCHER
|
#else // !wxUSE_SELECT_DISPATCHER
|
||||||
wxFAIL_MSG( wxS("Can't block until child exit without wxSelectDispatcher") );
|
wxFAIL_MSG( wxS("Can't block until child exit without wxSelectDispatcher") );
|
||||||
|
|
||||||
@ -601,8 +601,8 @@ long wxExecute(const char* const* argv, int flags, wxProcess* process,
|
|||||||
wxScopedPtr<wxExecuteData> execDataPtr(new wxExecuteData);
|
wxScopedPtr<wxExecuteData> execDataPtr(new wxExecuteData);
|
||||||
wxExecuteData& execData = *execDataPtr;
|
wxExecuteData& execData = *execDataPtr;
|
||||||
|
|
||||||
execData.flags = flags;
|
execData.m_flags = flags;
|
||||||
execData.process = process;
|
execData.m_process = process;
|
||||||
|
|
||||||
// create pipes for inter process communication
|
// create pipes for inter process communication
|
||||||
wxPipe pipeIn, // stdin
|
wxPipe pipeIn, // stdin
|
||||||
@ -805,11 +805,11 @@ long wxExecute(const char* const* argv, int flags, wxProcess* process,
|
|||||||
|
|
||||||
if ( flags & wxEXEC_SYNC )
|
if ( flags & wxEXEC_SYNC )
|
||||||
{
|
{
|
||||||
execData.bufOut.Init(outStream);
|
execData.m_bufOut.Init(outStream);
|
||||||
execData.bufErr.Init(errStream);
|
execData.m_bufErr.Init(errStream);
|
||||||
|
|
||||||
execData.fdOut = fdOut;
|
execData.m_fdOut = fdOut;
|
||||||
execData.fdErr = fdErr;
|
execData.m_fdErr = fdErr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAS_PIPE_STREAMS
|
#endif // HAS_PIPE_STREAMS
|
||||||
@ -1498,8 +1498,8 @@ wxAppTraits::RunLoopUntilChildExit(wxExecuteData& execData,
|
|||||||
// It is possible that wxExecuteData::OnExit() had already been called
|
// It is possible that wxExecuteData::OnExit() had already been called
|
||||||
// and reset the PID to 0, in which case we don't need to do anything
|
// and reset the PID to 0, in which case we don't need to do anything
|
||||||
// at all.
|
// at all.
|
||||||
if ( !execData.pid )
|
if ( !execData.m_pid )
|
||||||
return execData.exitcode;
|
return execData.m_exitcode;
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
// Monitor the child streams if necessary.
|
// Monitor the child streams if necessary.
|
||||||
@ -1510,24 +1510,24 @@ wxAppTraits::RunLoopUntilChildExit(wxExecuteData& execData,
|
|||||||
{
|
{
|
||||||
stdoutHandler.reset(new wxExecuteEventLoopSourceHandler
|
stdoutHandler.reset(new wxExecuteEventLoopSourceHandler
|
||||||
(
|
(
|
||||||
execData.fdOut, execData.bufOut
|
execData.m_fdOut, execData.m_bufOut
|
||||||
));
|
));
|
||||||
stderrHandler.reset(new wxExecuteEventLoopSourceHandler
|
stderrHandler.reset(new wxExecuteEventLoopSourceHandler
|
||||||
(
|
(
|
||||||
execData.fdErr, execData.bufErr
|
execData.m_fdErr, execData.m_bufErr
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
// Store the event loop in the data associated with the child
|
// Store the event loop in the data associated with the child
|
||||||
// process so that it could exit the loop when the child exits.
|
// process so that it could exit the loop when the child exits.
|
||||||
execData.syncEventLoop = &loop;
|
execData.m_syncEventLoop = &loop;
|
||||||
|
|
||||||
// And run it.
|
// And run it.
|
||||||
loop.Run();
|
loop.Run();
|
||||||
|
|
||||||
// The exit code will have been set when the child termination was detected.
|
// The exit code will have been set when the child termination was detected.
|
||||||
return execData.exitcode;
|
return execData.m_exitcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -1626,7 +1626,7 @@ void wxExecuteData::OnSomeChildExited(int WXUNUSED(sig))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxExecuteData::OnStart(int pid_)
|
void wxExecuteData::OnStart(int pid)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( wxTheApp,
|
wxCHECK_RET( wxTheApp,
|
||||||
wxS("Ensure wxTheApp is set before calling wxExecute()") );
|
wxS("Ensure wxTheApp is set before calling wxExecute()") );
|
||||||
@ -1640,21 +1640,21 @@ void wxExecuteData::OnStart(int pid_)
|
|||||||
|
|
||||||
|
|
||||||
// Remember the child PID to be able to wait for it later.
|
// Remember the child PID to be able to wait for it later.
|
||||||
pid = pid_;
|
m_pid = pid;
|
||||||
|
|
||||||
// Also save it in wxProcess where it will be accessible to the user code.
|
// Also save it in wxProcess where it will be accessible to the user code.
|
||||||
if ( process )
|
if ( m_process )
|
||||||
process->SetPid(pid);
|
m_process->SetPid(m_pid);
|
||||||
|
|
||||||
// Add this object itself to the list of child processes so that
|
// Add this object itself to the list of child processes so that
|
||||||
// we can check for its termination the next time we get SIGCHLD.
|
// we can check for its termination the next time we get SIGCHLD.
|
||||||
ms_childProcesses[pid] = this;
|
ms_childProcesses[m_pid] = this;
|
||||||
|
|
||||||
// However, if the child exited before we finished setting up above,
|
// However, if the child exited before we finished setting up above,
|
||||||
// we may have already missed its SIGCHLD. So we also do an explicit
|
// we may have already missed its SIGCHLD. So we also do an explicit
|
||||||
// check here before returning.
|
// check here before returning.
|
||||||
int exitcode;
|
int exitcode;
|
||||||
if ( CheckForChildExit(pid, &exitcode) )
|
if ( CheckForChildExit(m_pid, &exitcode) )
|
||||||
{
|
{
|
||||||
// Handle its termination if it did.
|
// Handle its termination if it did.
|
||||||
// This call will implicitly remove it from ms_childProcesses
|
// This call will implicitly remove it from ms_childProcesses
|
||||||
@ -1663,18 +1663,18 @@ void wxExecuteData::OnStart(int pid_)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxExecuteData::OnExit(int exitcode_)
|
void wxExecuteData::OnExit(int exitcode)
|
||||||
{
|
{
|
||||||
// Remove this process from the hash list of child processes that are
|
// Remove this process from the hash list of child processes that are
|
||||||
// still open as soon as possible to ensure we don't process it again even
|
// still open as soon as possible to ensure we don't process it again even
|
||||||
// if another SIGCHLD happens.
|
// if another SIGCHLD happens.
|
||||||
if ( !ms_childProcesses.erase(pid) )
|
if ( !ms_childProcesses.erase(m_pid) )
|
||||||
{
|
{
|
||||||
wxFAIL_MSG(wxString::Format(wxS("Data for PID %d not in the list?"), pid));
|
wxFAIL_MSG(wxString::Format(wxS("Data for PID %d not in the list?"), m_pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exitcode = exitcode_;
|
m_exitcode = exitcode;
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
if ( IsRedirected() )
|
if ( IsRedirected() )
|
||||||
@ -1682,16 +1682,16 @@ void wxExecuteData::OnExit(int exitcode_)
|
|||||||
// Read the remaining data in a blocking way: this is fine because the
|
// Read the remaining data in a blocking way: this is fine because the
|
||||||
// child has already exited and hence all the data must be already
|
// child has already exited and hence all the data must be already
|
||||||
// available in the streams buffers.
|
// available in the streams buffers.
|
||||||
bufOut.ReadAll();
|
m_bufOut.ReadAll();
|
||||||
bufErr.ReadAll();
|
m_bufErr.ReadAll();
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
// Notify user about termination if required
|
// Notify user about termination if required
|
||||||
if ( !(flags & wxEXEC_SYNC) )
|
if ( !(m_flags & wxEXEC_SYNC) )
|
||||||
{
|
{
|
||||||
if ( process )
|
if ( m_process )
|
||||||
process->OnTerminate(pid, exitcode);
|
m_process->OnTerminate(m_pid, m_exitcode);
|
||||||
|
|
||||||
// in case of asynchronous execution we don't need this object any more
|
// in case of asynchronous execution we don't need this object any more
|
||||||
// after the child terminates
|
// after the child terminates
|
||||||
@ -1700,10 +1700,10 @@ void wxExecuteData::OnExit(int exitcode_)
|
|||||||
else // sync execution
|
else // sync execution
|
||||||
{
|
{
|
||||||
// let wxExecute() know that the process has terminated
|
// let wxExecute() know that the process has terminated
|
||||||
pid = 0;
|
m_pid = 0;
|
||||||
|
|
||||||
// Stop the event loop for synchronous wxExecute() if we're running one.
|
// Stop the event loop for synchronous wxExecute() if we're running one.
|
||||||
if ( syncEventLoop )
|
if ( m_syncEventLoop )
|
||||||
syncEventLoop->ScheduleExit();
|
m_syncEventLoop->ScheduleExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user