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:
Vadim Zeitlin 2019-04-22 14:09:28 +02:00
parent 5020a810db
commit 5d770e5cbe
3 changed files with 54 additions and 54 deletions

View File

@ -27,17 +27,17 @@ class wxExecuteData
public:
wxExecuteData()
{
flags =
pid = 0;
exitcode = -1;
m_flags =
m_pid = 0;
m_exitcode = -1;
process = NULL;
m_process = NULL;
syncEventLoop = NULL;
m_syncEventLoop = NULL;
#if wxUSE_STREAMS
fdOut =
fdErr = wxPipe::INVALID_FD;
m_fdOut =
m_fdErr = wxPipe::INVALID_FD;
#endif // wxUSE_STREAMS
}
@ -51,36 +51,36 @@ public:
void OnExit(int exitcode);
// 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
int flags;
int m_flags;
// the pid of the child process
int pid;
int m_pid;
// The exit code of the process, set once the child terminates.
int exitcode;
int m_exitcode;
// the associated process object or NULL
wxProcess *process;
wxProcess *m_process;
// Local event loop used to wait for the child process termination in
// synchronous execution case. We can't create it ourselves as its exact
// type depends on the application kind (console/GUI), so we rely on
// wxAppTraits setting up this pointer to point to the appropriate object.
wxEventLoopBase *syncEventLoop;
wxEventLoopBase *m_syncEventLoop;
#if wxUSE_STREAMS
// the input buffer bufOut is connected to stdout, this is why it is
// called bufOut and not bufIn
wxStreamTempInputBuffer bufOut,
bufErr;
wxStreamTempInputBuffer m_bufOut,
m_bufErr;
// the corresponding FDs, -1 if not redirected
int fdOut,
fdErr;
int m_fdOut,
m_fdErr;
#endif // wxUSE_STREAMS

View File

@ -40,7 +40,7 @@ int wxGUIAppTraits::WaitForChild(wxExecuteData& execData)
// 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(!(execData.flags & wxEXEC_NODISABLE));
wxWindowDisabler wd(!(execData.m_flags & wxEXEC_NODISABLE));
// 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

View File

@ -535,25 +535,25 @@ int BlockUntilChildExit(wxExecuteData& execData)
stdoutHandler.reset(new wxExecuteFDIOHandler
(
dispatcher,
execData.fdOut,
execData.bufOut
execData.m_fdOut,
execData.m_bufOut
));
stderrHandler.reset(new wxExecuteFDIOHandler
(
dispatcher,
execData.fdErr,
execData.bufErr
execData.m_fdErr,
execData.m_bufErr
));
}
#endif // wxUSE_STREAMS
// And dispatch until the PID is reset from wxExecuteData::OnExit().
while ( execData.pid )
while ( execData.m_pid )
{
dispatcher.Dispatch();
}
return execData.exitcode;
return execData.m_exitcode;
#else // !wxUSE_SELECT_DISPATCHER
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);
wxExecuteData& execData = *execDataPtr;
execData.flags = flags;
execData.process = process;
execData.m_flags = flags;
execData.m_process = process;
// create pipes for inter process communication
wxPipe pipeIn, // stdin
@ -805,11 +805,11 @@ long wxExecute(const char* const* argv, int flags, wxProcess* process,
if ( flags & wxEXEC_SYNC )
{
execData.bufOut.Init(outStream);
execData.bufErr.Init(errStream);
execData.m_bufOut.Init(outStream);
execData.m_bufErr.Init(errStream);
execData.fdOut = fdOut;
execData.fdErr = fdErr;
execData.m_fdOut = fdOut;
execData.m_fdErr = fdErr;
}
}
#endif // HAS_PIPE_STREAMS
@ -1498,8 +1498,8 @@ wxAppTraits::RunLoopUntilChildExit(wxExecuteData& execData,
// 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
// at all.
if ( !execData.pid )
return execData.exitcode;
if ( !execData.m_pid )
return execData.m_exitcode;
#if wxUSE_STREAMS
// Monitor the child streams if necessary.
@ -1510,24 +1510,24 @@ wxAppTraits::RunLoopUntilChildExit(wxExecuteData& execData,
{
stdoutHandler.reset(new wxExecuteEventLoopSourceHandler
(
execData.fdOut, execData.bufOut
execData.m_fdOut, execData.m_bufOut
));
stderrHandler.reset(new wxExecuteEventLoopSourceHandler
(
execData.fdErr, execData.bufErr
execData.m_fdErr, execData.m_bufErr
));
}
#endif // wxUSE_STREAMS
// Store the event loop in the data associated with the child
// process so that it could exit the loop when the child exits.
execData.syncEventLoop = &loop;
execData.m_syncEventLoop = &loop;
// And run it.
loop.Run();
// 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,
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.
pid = pid_;
m_pid = pid;
// Also save it in wxProcess where it will be accessible to the user code.
if ( process )
process->SetPid(pid);
if ( m_process )
m_process->SetPid(m_pid);
// Add this object itself to the list of child processes so that
// 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,
// we may have already missed its SIGCHLD. So we also do an explicit
// check here before returning.
int exitcode;
if ( CheckForChildExit(pid, &exitcode) )
if ( CheckForChildExit(m_pid, &exitcode) )
{
// Handle its termination if it did.
// 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
// still open as soon as possible to ensure we don't process it again even
// 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 ( IsRedirected() )
@ -1682,16 +1682,16 @@ void wxExecuteData::OnExit(int exitcode_)
// 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
// available in the streams buffers.
bufOut.ReadAll();
bufErr.ReadAll();
m_bufOut.ReadAll();
m_bufErr.ReadAll();
}
#endif // wxUSE_STREAMS
// Notify user about termination if required
if ( !(flags & wxEXEC_SYNC) )
if ( !(m_flags & wxEXEC_SYNC) )
{
if ( process )
process->OnTerminate(pid, exitcode);
if ( m_process )
m_process->OnTerminate(m_pid, m_exitcode);
// in case of asynchronous execution we don't need this object any more
// after the child terminates
@ -1700,10 +1700,10 @@ void wxExecuteData::OnExit(int exitcode_)
else // sync execution
{
// 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.
if ( syncEventLoop )
syncEventLoop->ScheduleExit();
if ( m_syncEventLoop )
m_syncEventLoop->ScheduleExit();
}
}