wxExecute may only be called from the main thread

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19363 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-02-27 12:18:07 +00:00
parent 9e023db73b
commit 647b8e379e
3 changed files with 25 additions and 2 deletions

View File

@@ -535,8 +535,13 @@ a process (always synchronously) and capture its output in the array
{\it output}. The fourth version adds the possibility to additionally capture {\it output}. The fourth version adds the possibility to additionally capture
the messages from standard error output in the {\it errors} array. the messages from standard error output in the {\it errors} array.
See also \helpref{wxShell}{wxshell}, \helpref{wxProcess}{wxprocess}, {\bf NB:} Currently wxExecute() can only be used from the main thread, calling
\helpref{Exec sample}{sampleexec}. this function from another thread will result in an assert failure in debug
build and won't work.
\wxheading{See also}
\helpref{wxShell}{wxshell}, \helpref{wxProcess}{wxprocess}, \helpref{Exec sample}{sampleexec}.
\wxheading{Parameters} \wxheading{Parameters}

View File

@@ -492,6 +492,14 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler)
{ {
wxCHECK_MSG( !!cmd, 0, wxT("empty command in wxExecute") ); wxCHECK_MSG( !!cmd, 0, wxT("empty command in wxExecute") );
#if wxUSE_THREADS
// for many reasons, the code below breaks down if it's called from another
// thread -- this could be fixed, but as Unix versions don't support this
// neither I don't want to waste time on this now
wxASSERT_MSG( wxThread::IsMain(),
_T("wxExecute() can be called only from the main thread") );
#endif // wxUSE_THREADS
wxString command; wxString command;
#if wxUSE_IPC #if wxUSE_IPC

View File

@@ -203,6 +203,16 @@ long wxExecute( const wxString& command, int flags, wxProcess *process )
{ {
wxCHECK_MSG( !command.IsEmpty(), 0, wxT("can't exec empty command") ); wxCHECK_MSG( !command.IsEmpty(), 0, wxT("can't exec empty command") );
#if wxUSE_THREADS
// fork() doesn't mix well with POSIX threads: on many systems the program
// deadlocks or crashes for some reason. Probably our code is buggy and
// doesn't do something which must be done to allow this to work, but I
// don't know what yet, so for now just warn the user (this is the least we
// can do) about it
wxASSERT_MSG( wxThread::IsMain(),
_T("wxExecute() can be called only from the main thread") );
#endif // wxUSE_THREADS
int argc = 0; int argc = 0;
wxChar *argv[WXEXECUTE_NARGS]; wxChar *argv[WXEXECUTE_NARGS];
wxString argument; wxString argument;