X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a3261ffb75f938c1ed6e0853db86c747d15af766..3b2f109dbbea2847114c62315676eed7a3986dbc:/src/mac/corefoundation/utilsexc_cf.cpp diff --git a/src/mac/corefoundation/utilsexc_cf.cpp b/src/mac/corefoundation/utilsexc_cf.cpp index d32a8c8a5a..93dc45dd5d 100644 --- a/src/mac/corefoundation/utilsexc_cf.cpp +++ b/src/mac/corefoundation/utilsexc_cf.cpp @@ -17,6 +17,7 @@ #endif //ndef WX_PRECOMP #include "wx/unix/execute.h" #include "wx/stdpaths.h" +#include "wx/app.h" #include "wx/apptrait.h" #include "wx/thread.h" #include "wx/process.h" @@ -51,7 +52,14 @@ class wxProcessTerminationEventHandler: public wxEvtHandler { Disconnect(-1, wxEVT_END_PROCESS, wxProcessEventHandler(wxProcessTerminationEventHandler::OnTerminate)); wxHandleProcessTermination(m_data); - delete this; + + // NOTE: We don't use this to delay destruction until the next idle run but rather to + // avoid killing ourselves while our caller (which is our wxEvtHandler superclass + // ProcessPendingEvents) still needs our m_eventsLocker to be valid. + // Since we're in the GUI library we can guarantee that ScheduleForDestroy is using + // the GUI implementation which delays destruction and not the base implementation + // which does it immediately. + wxTheApp->GetTraits()->ScheduleForDestroy(this); } wxEndProcessData* m_data; @@ -135,7 +143,7 @@ extern "C" { #include } -void wxMAC_MachPortEndProcessDetect(CFMachPortRef port, void *data) +void wxMAC_MachPortEndProcessDetect(CFMachPortRef WXUNUSED(port), void *data) { wxEndProcessData *proc_data = (wxEndProcessData*)data; wxLogDebug(wxT("Process ended")); @@ -232,7 +240,11 @@ int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid) Called due to source signal detected by the CFRunLoop. This is nearly identical to the wxGTK equivalent. */ -extern "C" void WXCF_EndProcessDetector(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, void const *data, void *info) +extern "C" void WXCF_EndProcessDetector(CFSocketRef s, + CFSocketCallBackType WXUNUSED(callbackType), + CFDataRef WXUNUSED(address), + void const *WXUNUSED(data), + void *info) { wxEndProcessData * const proc_data = static_cast(info); @@ -309,13 +321,13 @@ int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) CFSocketRef cfSocket = CFSocketCreateWithNative(kCFAllocatorDefault,fd,kCFSocketReadCallBack,&WXCF_EndProcessDetector,&context); if(cfSocket == NULL) { - wxLogError("Failed to create socket for end process detection"); + wxLogError(wxT("Failed to create socket for end process detection")); return 0; } CFRunLoopSourceRef runLoopSource = CFSocketCreateRunLoopSource(kCFAllocatorDefault, cfSocket, /*highest priority:*/0); if(runLoopSource == NULL) { - wxLogError("Failed to create CFRunLoopSource from CFSocket for end process detection"); + wxLogError(wxT("Failed to create CFRunLoopSource from CFSocket for end process detection")); // closes the fd.. we can't really stop it, nor do we necessarily want to. CFSocketInvalidate(cfSocket); CFRelease(cfSocket);