From 021efd65100322b3c152cc1017cfb961664d30a4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 Dec 2009 14:59:26 +0000 Subject: [PATCH] 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 --- src/common/appbase.cpp | 30 +++++++++++++++++------------- src/common/appcmn.cpp | 5 ----- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index fbc1cf78ba..6523195492 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -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; } diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index ca3c6fdc75..003debce41 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -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; -- 2.45.2