summaryrefslogtreecommitdiff
path: root/hw/xwin/winerror.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xwin/winerror.c')
-rw-r--r--hw/xwin/winerror.c60
1 files changed, 53 insertions, 7 deletions
diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c
index cb69c57c2..ea301a927 100644
--- a/hw/xwin/winerror.c
+++ b/hw/xwin/winerror.c
@@ -42,9 +42,12 @@
/* References to external symbols */
extern char * g_pszCommandLine;
extern const char * g_pszLogFile;
+extern Bool g_fSilentDupError;
extern Bool g_fSilentFatalError;
extern Bool g_fLogInited;
+/* Last error reported */
+static char lastError[1024] = "";
#ifdef DDXOSVERRORF
/* Prototype */
@@ -63,6 +66,31 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args)
pthread_mutex_lock (&s_pmPrinting);
#endif
+ /* If we want to silence it,
+ * detect if we are going to abort due to duplication error */
+ if (g_fSilentDupError)
+ {
+ if ((strcmp(pszFormat,
+ "InitOutput - Duplicate invocation on display "
+ "number: %s. Exiting.\n") == 0)
+ || (strcmp(pszFormat,
+ "Server is already active for display %s\n%s %s\n%s\n") == 0)
+ || (strcmp(pszFormat,
+ "MakeAllCOTSServerListeners: server already running\n") == 0))
+ {
+ g_fSilentFatalError = TRUE;
+ }
+ }
+
+ /* Record the error, in case it's a fatal one... */
+ if (strcmp(pszFormat,"\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);
@@ -75,9 +103,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.
*/
@@ -94,10 +125,25 @@ OsVendorFatalError (void)
}
LogClose ();
- 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"));
}