]> git.saurik.com Git - wxWidgets.git/commitdiff
wxLogFatalError() now always aborts the program and doesn't use the active log target...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Feb 2002 18:13:10 +0000 (18:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Feb 2002 18:13:10 +0000 (18:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14349 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/tlog.tex
src/common/log.cpp

index 69e642f69a8cefed652ba70a13a4a66122fb0e24..2b2fab3e840456ed564829e63df3a027e07e1b16 100644 (file)
@@ -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.
index 9d9b21c6608c8a32d7a0951d6bb907beb59f6fb5..ca6e355e28afbea2a590074f35e4764e6d6706d7 100644 (file)
@@ -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)
 {