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
This commit is contained in:
Vadim Zeitlin
2002-02-22 18:13:10 +00:00
parent b795f9ca5f
commit 1800689f23
2 changed files with 28 additions and 4 deletions

View File

@@ -26,8 +26,9 @@ arguments or a variable argument list pointer. Here are all of them:
\begin{itemize}\itemsep=0pt \begin{itemize}\itemsep=0pt
\item{\bf wxLogFatalError} which is like {\it wxLogError}, but also \item{\bf wxLogFatalError} which is like {\it wxLogError}, but also
terminates the program with the exit code 3 (using {\it abort()} standard terminates the program with the exit code $3$ (using {\it abort()} standard
function also terminates the program with this exit code). 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 \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 messages that must be shown to the user. The default processing is to pop up a
message box to inform the user about it. message box to inform the user about it.

View File

@@ -36,6 +36,7 @@
#if wxUSE_GUI #if wxUSE_GUI
#include "wx/window.h" #include "wx/window.h"
#include "wx/msgdlg.h"
#ifdef __WXMSW__ #ifdef __WXMSW__
#include "wx/msw/private.h" #include "wx/msw/private.h"
#endif #endif
@@ -149,13 +150,35 @@ void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
va_end(argptr); \ va_end(argptr); \
} }
IMPLEMENT_LOG_FUNCTION(FatalError)
IMPLEMENT_LOG_FUNCTION(Error) IMPLEMENT_LOG_FUNCTION(Error)
IMPLEMENT_LOG_FUNCTION(Warning) IMPLEMENT_LOG_FUNCTION(Warning)
IMPLEMENT_LOG_FUNCTION(Message) IMPLEMENT_LOG_FUNCTION(Message)
IMPLEMENT_LOG_FUNCTION(Info) IMPLEMENT_LOG_FUNCTION(Info)
IMPLEMENT_LOG_FUNCTION(Status) 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 // same as info, but only if 'verbose' mode is on
void wxVLogVerbose(const wxChar *szFormat, va_list argptr) void wxVLogVerbose(const wxChar *szFormat, va_list argptr)
{ {