From: Vadim Zeitlin Date: Thu, 27 Feb 2003 12:18:07 +0000 (+0000) Subject: wxExecute may only be called from the main thread X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/647b8e379ed0f470f0f643fe816ba872be41541d 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 --- diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex index 438c1ce9ee..a4f209a7d1 100644 --- a/docs/latex/wx/function.tex +++ b/docs/latex/wx/function.tex @@ -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 the messages from standard error output in the {\it errors} array. -See also \helpref{wxShell}{wxshell}, \helpref{wxProcess}{wxprocess}, -\helpref{Exec sample}{sampleexec}. +{\bf NB:} Currently wxExecute() can only be used from the main thread, calling +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} diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index b646c56ae2..3fb6d493fe 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -492,6 +492,14 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler) { 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; #if wxUSE_IPC diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index c375770794..a9a3c1156f 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -203,6 +203,16 @@ long wxExecute( const wxString& command, int flags, wxProcess *process ) { 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; wxChar *argv[WXEXECUTE_NARGS]; wxString argument;