Win32 inconvenience: a call to g_error will terminate the program and the user won...
authorUlf Lamping <ulf.lamping@web.de>
Thu, 9 Feb 2006 21:37:14 +0000 (21:37 -0000)
committerUlf Lamping <ulf.lamping@web.de>
Thu, 9 Feb 2006 21:37:14 +0000 (21:37 -0000)
To avoid this, the log handler in the error case:

- opens a console window (regardless of the users settings)
- waits for a keypress before continuing to terminate the program

This way, the user will be notified that there's a problem, instead of simply seeing a terminating program only.

svn path=/trunk/; revision=17236

gtk/main.c

index 12de6d8442c74c8ddbe3c12fa47d87d78a1bcad6..77476c8a719a1d7f4e88034b1d6203d2e6808027 100644 (file)
@@ -2927,7 +2927,8 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level,
   today = localtime(&curr);    
 
 #ifdef _WIN32
-  if (prefs.gui_console_open != console_open_never) {
+  if (prefs.gui_console_open != console_open_never || log_level & G_LOG_LEVEL_ERROR) {
+    /* the user wants a console or the application will terminate immediately */
     create_console();
   }
   if (has_console) {
@@ -2966,6 +2967,12 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level,
             log_domain != NULL ? log_domain : "",
             level, message);
 #ifdef _WIN32
+    if(log_level & G_LOG_LEVEL_ERROR) {
+        /* wait for a key press before the following error handler will terminate the program 
+           this way the user at least can read the error message */
+        printf("\n\nPress any key to exit\n");
+        _getch();
+    }
   } else {
     g_log_default_handler(log_domain, log_level, message, user_data);
   }