diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2010-03-12 14:38:51 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-03-10 13:22:50 +0000 |
commit | 7ee41b6040f9f39d3b677f606b2366a9dd376aee (patch) | |
tree | 4b094b803a47e7205c24ee039a3d74d17a7a5af9 | |
parent | b22bc7991f9aa12490e2692351e1d6190d5230f3 (diff) |
hw/xwin: Show any fatal error message
Report the fatal error message in the dialog we pop up, rather
than just referring the user to the logfile.
(This can be done a better way if the patch "Pass the FatalError
message to OsVendorFatalError" lands)
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r-- | hw/xwin/winerror.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c index 5c54e9f23..cd1c51aa1 100644 --- a/hw/xwin/winerror.c +++ b/hw/xwin/winerror.c @@ -35,6 +35,9 @@ #include <../xfree86/common/xorgVersion.h> #include "win.h" +/* Last error reported */ +static char lastError[1024] = ""; + #ifdef DDXOSVERRORF /* Prototype */ void @@ -68,6 +71,16 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args) } } + /* Record the error, in case it's a fatal one... */ + if ((strcmp(pszFormat,"\n") != 0) && + (strcmp(pszFormat,"Server terminated %s (%d). Closing log file.\n") != 0)) + { + va_list va_args_copy; + va_copy(va_args_copy, va_args); + vsnprintf(lastError, sizeof(lastError), pszFormat, va_args_copy); + va_end(va_args_copy); + } + /* Print the error message to a log file, could be stderr */ LogVWrite (0, pszFormat, va_args); @@ -80,9 +93,12 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args) /* - * os/util.c/FatalError () calls our vendor ErrorF, so the message - * from a FatalError will be logged. Thus, the message for the - * fatal error is not passed to this function. + * os/log.c:FatalError () calls our vendor ErrorF, so the message + * from a FatalError will be logged. + * + * But the message for the fatal error is not passed to this + * function, so we stash the log string in lastError so we can + * also report it here * * Attempt to do last-ditch, safe, important cleanup here. */ @@ -99,10 +115,25 @@ OsVendorFatalError (void) } LogClose (EXIT_ERR_ABORT); - winMessageBoxF ( - "A fatal error has occurred and " PROJECT_NAME " will now exit.\n" \ - "Please open %s for more information.\n", - MB_ICONERROR, (g_pszLogFile?g_pszLogFile:"the logfile")); + /* + Sometimes the error message we capture in lastError + needs some cosmetic cleaning up for use in a dialog box... + */ + { + char *s; + while ((s = strstr(lastError, "\n\t")) != NULL) + { + s[0] = ' '; + s[1] = '\n'; + } + } + + winMessageBoxF("A fatal error has occurred and " PROJECT_NAME " will now exit.\n\n" \ + "%s\n\n" \ + "Please open %s for more information.\n", + MB_ICONERROR, + lastError, + (g_pszLogFile ? g_pszLogFile : "the logfile")); } |