Skip to content

Commit

Permalink
Win32 inconvenience: a call to g_error will terminate the program and…
Browse files Browse the repository at this point in the history
… the user won't see anything.

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
  • Loading branch information
ulflulfl committed Feb 9, 2006
1 parent 48c4f86 commit ba7b92b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gtk/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit ba7b92b

Please sign in to comment.