From 1800689f23ce25c2f897081536ab39afcc692da4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 22 Feb 2002 18:13:10 +0000 Subject: [PATCH] wxLogFatalError() now always aborts the program and doesn't use the active log target but always shows the standard message box git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14349 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/tlog.tex | 5 +++-- src/common/log.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/latex/wx/tlog.tex b/docs/latex/wx/tlog.tex index 69e642f69a..2b2fab3e84 100644 --- a/docs/latex/wx/tlog.tex +++ b/docs/latex/wx/tlog.tex @@ -26,8 +26,9 @@ arguments or a variable argument list pointer. Here are all of them: \begin{itemize}\itemsep=0pt \item{\bf wxLogFatalError} which is like {\it wxLogError}, but also -terminates the program with the exit code 3 (using {\it abort()} standard -function also terminates the program with this exit code). +terminates the program with the exit code $3$ (using {\it abort()} standard +function). Unlike for all the other logging functions, this function can't be +overridden by a log target. \item{\bf wxLogError} is the function to use for error messages, i.e. the messages that must be shown to the user. The default processing is to pop up a message box to inform the user about it. diff --git a/src/common/log.cpp b/src/common/log.cpp index 9d9b21c660..ca6e355e28 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -36,6 +36,7 @@ #if wxUSE_GUI #include "wx/window.h" + #include "wx/msgdlg.h" #ifdef __WXMSW__ #include "wx/msw/private.h" #endif @@ -145,17 +146,39 @@ void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...) { \ va_list argptr; \ va_start(argptr, szFormat); \ - wxVLog##level(szFormat, argptr); \ + wxVLog##level(szFormat, argptr); \ va_end(argptr); \ } -IMPLEMENT_LOG_FUNCTION(FatalError) IMPLEMENT_LOG_FUNCTION(Error) IMPLEMENT_LOG_FUNCTION(Warning) IMPLEMENT_LOG_FUNCTION(Message) IMPLEMENT_LOG_FUNCTION(Info) IMPLEMENT_LOG_FUNCTION(Status) +// fatal errors can't be suppressed nor handled by the custom log target and +// always terminate the program +void wxVLogFatalError(const wxChar *szFormat, va_list argptr) +{ + wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); + +#if wxUSE_GUI + wxMessageBox(s_szBuf, _("Fatal Error"), wxID_OK | wxICON_STOP); +#else + fprintf(stderr, _("Fatal error: %s\n"), s_szBuf); +#endif + + abort(); +} + +void wxLogFatalError(const wxChar *szFormat, ...) +{ + va_list argptr; + va_start(argptr, szFormat); + wxVLogFatalError(szFormat, argptr); + va_end(argptr); +} + // same as info, but only if 'verbose' mode is on void wxVLogVerbose(const wxChar *szFormat, va_list argptr) { -- 2.47.2