X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/110ffa16374c64e38f37ac73e486cea197783f33..0bdd807424210ce9b4c14bae5dcd2943fcb1b13a:/src/mac/corefoundation/utilsexc_cf.cpp diff --git a/src/mac/corefoundation/utilsexc_cf.cpp b/src/mac/corefoundation/utilsexc_cf.cpp index 5eadfff570..f9f5227660 100644 --- a/src/mac/corefoundation/utilsexc_cf.cpp +++ b/src/mac/corefoundation/utilsexc_cf.cpp @@ -21,6 +21,8 @@ #include "wx/thread.h" #include "wx/process.h" +#include + // Use polling instead of Mach ports, which doesn't work on Intel // due to task_for_pid security issues. @@ -33,6 +35,7 @@ #if USE_POLLING +#if wxUSE_THREADS class wxProcessTerminationEventHandler: public wxEvtHandler { public: @@ -91,7 +94,7 @@ void* wxProcessTerminationThread::Entry() break; } } - + return NULL; } @@ -100,9 +103,9 @@ int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid) if (pid < 1) return -1; - wxProcessTerminationEventHandler* handler = new wxProcessTerminationEventHandler(proc_data); + wxProcessTerminationEventHandler* handler = new wxProcessTerminationEventHandler(proc_data); wxProcessTerminationThread* thread = new wxProcessTerminationThread(proc_data, handler); - + if (thread->Create() != wxTHREAD_NO_ERROR) { wxLogDebug(wxT("Could not create termination detection thread.")); @@ -112,14 +115,20 @@ int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid) } thread->Run(); - + return 0; } +#else // !wxUSE_THREADS +int wxAddProcessCallbackForPid(wxEndProcessData*, int) +{ + wxLogDebug(wxT("Could not create termination detection thread.")); + return -1; +} +#endif // wxUSE_THREADS/!wxUSE_THREADS -#else +#else // !USE_POLLING #include -#include extern "C" { #include } @@ -132,13 +141,13 @@ void wxMAC_MachPortEndProcessDetect(CFMachPortRef port, void *data) int rc = waitpid(abs(proc_data->pid), &status, WNOHANG); if(!rc) { - wxLogDebug(wxT("Mach port was invalidated, but process hasn't terminated!")); - return; + wxLogDebug(wxT("Mach port was invalidated, but process hasn't terminated!")); + return; } if((rc != -1) && WIFEXITED(status)) - proc_data->exitcode = WEXITSTATUS(status); + proc_data->exitcode = WEXITSTATUS(status); else - proc_data->exitcode = -1; + proc_data->exitcode = -1; wxHandleProcessTermination(proc_data); } @@ -201,7 +210,7 @@ int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid) wxLogDebug(wxT("Couldn't create runloopsource")); return -1; } - + CFRelease(CFMachPortForProcess); CFRunLoopAddSource(CFRunLoopGetCurrent(),runloopsource,kCFRunLoopDefaultMode); @@ -210,14 +219,17 @@ int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid) return 0; } -#endif - // USE_POLLING +#endif // USE_POLLING/!USE_POLLING -// NOTE: This doens't really belong here but this was a handy file to +// NOTE: This doesn't really belong here but this was a handy file to // put it in because it's already compiled for wxCocoa and wxMac GUI lib. +#if wxUSE_GUI + static wxStandardPathsCF gs_stdPaths; wxStandardPathsBase& wxGUIAppTraits::GetStandardPaths() { return gs_stdPaths; } +#endif // wxUSE_GUI +