Use a MessageBox for fatal messages. Collect eror message into a buffer,

2000-12-25  Tor Lillqvist  <tml@iki.fi>

	* gmessages.c: (Win32) Use a MessageBox for fatal
	messages. Collect eror message into a buffer, and display that.

	* glib.def: Update.

	* glibconfig.h.win32.in: Update. Remove unused wchar and wctype
	macros, add G_MODULE_SUFFIX.
This commit is contained in:
Tor Lillqvist
2000-12-25 22:07:01 +00:00
committed by Tor Lillqvist
parent 855e230f31
commit 7a19b4cae9
13 changed files with 153 additions and 28 deletions

View File

@@ -95,6 +95,14 @@ static GPrivate* g_log_depth = NULL;
static gboolean alloc_console_called = FALSE;
static gboolean gonna_abort = FALSE;
/* This default message will usually be overwritten. */
/* Yes, a fixed size buffer is bad. So sue me. But g_error is never
* with huge strings, is it? */
static char fatal_msg_buf[1000] = "Unspecified fatal error encountered, aborting.";
static char *fatal_msg_ptr = fatal_msg_buf;
/* Just use stdio. If we're out of memory, we're hosed anyway. */
#undef write
static inline int
@@ -102,6 +110,14 @@ dowrite (FILE *fd,
const void *buf,
unsigned int len)
{
if (gonna_abort)
{
memcpy (fatal_msg_ptr, buf, len);
fatal_msg_ptr += len;
*fatal_msg_ptr = 0;
return len;
}
fwrite (buf, len, 1, fd);
fflush (fd);
@@ -115,6 +131,9 @@ ensure_stdout_valid (void)
{
HANDLE handle;
if (gonna_abort)
return;
if (!alloc_console_called)
{
handle = GetStdHandle (STD_OUTPUT_HANDLE);
@@ -413,6 +432,9 @@ g_logv (const gchar *log_domain,
else
abort ();
#else /* !G_ENABLE_DEBUG || !SIGTRAP */
#ifdef G_OS_WIN32
MessageBox (NULL, fatal_msg_buf, NULL, MB_OK);
#endif
abort ();
#endif /* !G_ENABLE_DEBUG || !SIGTRAP */
}
@@ -473,6 +495,7 @@ g_log_default_handler (const gchar *log_domain,
* DOS prompt.
*/
fd = stdout;
gonna_abort = is_fatal;
#else
fd = (log_level > G_LOG_LEVEL_MESSAGE) ? 1 : 2;
#endif