Avoid outputting the assert message twice in non-GUI code.

As we always log the assert message in ::ShowAssertDialog() itself there is no
need to log it again in wxAppTraitsBase::ShowAssertDialog().

Also show the "please wait while generating stack trace information" in
wxAppTraitsBase::GetAssertStackTrace() itself instead of doing it in both
places which call it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-12-09 14:59:26 +00:00
parent 61c18e1a3d
commit 021efd6510
2 changed files with 17 additions and 18 deletions

View File

@@ -872,22 +872,19 @@ void WXDLLIMPEXP_BASE wxMutexGuiLeave()
bool wxAppTraitsBase::ShowAssertDialog(const wxString& msgOriginal)
{
#if wxDEBUG_LEVEL
wxString msg = msgOriginal;
wxString msg;
#if wxUSE_STACKWALKER
#if !defined(__WXMSW__)
// on Unix stack frame generation may take some time, depending on the
// size of the executable mainly... warn the user that we are working
wxFprintf(stderr, wxT("[Debug] Generating a stack trace... please wait"));
fflush(stderr);
#endif
const wxString stackTrace = GetAssertStackTrace();
if ( !stackTrace.empty() )
{
msg << wxT("\n\nCall stack:\n") << stackTrace;
wxMessageOutputDebug().Output(msg);
}
#endif // wxUSE_STACKWALKER
return DoShowAssertDialog(msg);
return DoShowAssertDialog(msgOriginal + msg);
#else // !wxDEBUG_LEVEL
wxUnusedVar(msgOriginal);
@@ -899,6 +896,15 @@ bool wxAppTraitsBase::ShowAssertDialog(const wxString& msgOriginal)
wxString wxAppTraitsBase::GetAssertStackTrace()
{
#if wxDEBUG_LEVEL
#if !defined(__WXMSW__)
// on Unix stack frame generation may take some time, depending on the
// size of the executable mainly... warn the user that we are working
wxFprintf(stderr, "Collecting stack trace information, please wait...");
fflush(stderr);
#endif // !__WXMSW__
wxString stackTrace;
class StackDump : public wxStackWalker
@@ -1186,12 +1192,10 @@ bool DoShowAssertDialog(const wxString& msg)
//case IDNO: nothing to do
}
#else // !__WXMSW__
wxMessageOutputDebug().Output(msg);
// TODO: ask the user whether to trap on the console?
wxUnusedVar(msg);
#endif // __WXMSW__/!__WXMSW__
// continue with the asserts
// continue with the asserts by default
return false;
}

View File

@@ -465,11 +465,6 @@ bool wxGUIAppTraitsBase::ShowAssertDialog(const wxString& msg)
wxString msgDlg = msg;
#if wxUSE_STACKWALKER
// on Unix stack frame generation may take some time, depending on the
// size of the executable mainly... warn the user that we are working
wxFprintf(stderr, wxT("[Debug] Generating a stack trace... please wait"));
fflush(stderr);
const wxString stackTrace = GetAssertStackTrace();
if ( !stackTrace.empty() )
msgDlg << wxT("\n\nCall stack:\n") << stackTrace;