reset s_bInAssert in wxDoOnAssert() in an exception-safe way (replaces patch 1900613) [backport of r52078 from trunk]

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52093 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-02-25 13:43:07 +00:00
parent 16f2c0f6e0
commit 0b3f446900

View File

@@ -70,6 +70,8 @@
#include "wx/msw/debughlp.h" #include "wx/msw/debughlp.h"
#endif #endif
#endif // wxUSE_STACKWALKER #endif // wxUSE_STACKWALKER
#include "wx/recguard.h"
#endif // __WXDEBUG__ #endif // __WXDEBUG__
// wxABI_VERSION can be defined when compiling applications but it should be // wxABI_VERSION can be defined when compiling applications but it should be
@@ -683,20 +685,17 @@ void wxOnAssert(const wxChar *szFile,
const wxChar *szMsg) const wxChar *szMsg)
{ {
// FIXME MT-unsafe // FIXME MT-unsafe
static bool s_bInAssert = false; static int s_bInAssert = 0;
if ( s_bInAssert ) wxRecursionGuard guard(s_bInAssert);
if ( guard.IsInside() )
{ {
// He-e-e-e-elp!! we're trapped in endless loop // can't use assert here to avoid infinite loops, so just trap
wxTrap(); wxTrap();
s_bInAssert = false;
return; return;
} }
s_bInAssert = true;
// __FUNCTION__ is always in ASCII, convert it to wide char if needed // __FUNCTION__ is always in ASCII, convert it to wide char if needed
const wxString strFunc = wxString::FromAscii(szFunc); const wxString strFunc = wxString::FromAscii(szFunc);
@@ -711,8 +710,6 @@ void wxOnAssert(const wxChar *szFile,
// let the app process it as it wants // let the app process it as it wants
wxTheApp->OnAssertFailure(szFile, nLine, strFunc, szCond, szMsg); wxTheApp->OnAssertFailure(szFile, nLine, strFunc, szCond, szMsg);
} }
s_bInAssert = false;
} }
#endif // __WXDEBUG__ #endif // __WXDEBUG__