From 0b3f4469005be4fdcabae830fd1ef516794eabb8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 25 Feb 2008 13:43:07 +0000 Subject: [PATCH] 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 --- src/common/appbase.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 86f141ce63..caf83ebb04 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -70,6 +70,8 @@ #include "wx/msw/debughlp.h" #endif #endif // wxUSE_STACKWALKER + + #include "wx/recguard.h" #endif // __WXDEBUG__ // wxABI_VERSION can be defined when compiling applications but it should be @@ -683,20 +685,17 @@ void wxOnAssert(const wxChar *szFile, const wxChar *szMsg) { // 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(); - s_bInAssert = false; - return; } - s_bInAssert = true; - // __FUNCTION__ is always in ASCII, convert it to wide char if needed const wxString strFunc = wxString::FromAscii(szFunc); @@ -711,8 +710,6 @@ void wxOnAssert(const wxChar *szFile, // let the app process it as it wants wxTheApp->OnAssertFailure(szFile, nLine, strFunc, szCond, szMsg); } - - s_bInAssert = false; } #endif // __WXDEBUG__