From 79b7b95aed76eb742deef93d046886c20452fb36 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 26 Nov 2007 19:41:34 +0000 Subject: [PATCH] catch unhandled exceptions in POSIX threads implementation the same way wxMSW does git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50257 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/unix/threadpsx.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index 850543d345..0384805c1a 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -27,8 +27,10 @@ #if wxUSE_THREADS #include "wx/thread.h" +#include "wx/except.h" #ifndef WX_PRECOMP + #include "wx/app.h" #include "wx/dynarray.h" #include "wx/intl.h" #include "wx/log.h" @@ -826,11 +828,15 @@ void *wxThreadInternal::PthreadStart(wxThread *thread) _T("Thread %ld about to enter its Entry()."), THR_ID(pthread)); - pthread->m_exitcode = thread->Entry(); + wxTRY + { + pthread->m_exitcode = thread->Entry(); - wxLogTrace(TRACE_THREADS, - _T("Thread %ld Entry() returned %lu."), - THR_ID(pthread), wxPtrToUInt(pthread->m_exitcode)); + wxLogTrace(TRACE_THREADS, + _T("Thread %ld Entry() returned %lu."), + THR_ID(pthread), wxPtrToUInt(pthread->m_exitcode)); + } + wxCATCH_ALL( wxTheApp->OnUnhandledException(); ) { wxCriticalSectionLocker lock(thread->m_critsect); @@ -1542,7 +1548,11 @@ void wxThread::Exit(ExitCode status) // might deadlock if, for example, it signals a condition in OnExit() (a // common case) while the main thread calls any of functions entering // m_critsect on us (almost all of them do) - OnExit(); + wxTRY + { + OnExit(); + } + wxCATCH_ALL( wxTheApp->OnUnhandledException(); ) // delete C++ thread object if this is a detached thread - user is // responsible for doing this for joinable ones -- 2.45.2