]> git.saurik.com Git - wxWidgets.git/commitdiff
wxExecute may only be called from the main thread
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 27 Feb 2003 12:18:07 +0000 (12:18 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 27 Feb 2003 12:18:07 +0000 (12:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19363 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/function.tex
src/msw/utilsexc.cpp
src/unix/utilsunx.cpp

index 438c1ce9ee229e59fdd80d2dc4f755f71cf0f898..a4f209a7d16872c8ea55697c5b23aeaf32faa711 100644 (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
 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}
 
index b646c56ae2b2f7e2c525adb99e516c5c923c929a..3fb6d493fe743285aa50b096b484e83a2d58faf6 100644 (file)
@@ -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
index c375770794adfcdde339e5d25ccb84bf67c08fab..a9a3c1156f824177a24d5af69f2c1e918f60d0d3 100644 (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") );
 
+#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;