- don't wait for the 'enter' key on the win32 console if the user has pressed

the power button or has chosen "kill simulation" in the "ask" dialog
This commit is contained in:
Volker Ruppert 2003-05-27 18:19:13 +00:00
parent b6ff1e6d9d
commit 04ad96b585
4 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.68 2003-05-25 18:34:03 vruppert Exp $
// $Id: gui.cc,v 1.69 2003-05-27 18:19:12 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -302,6 +302,7 @@ bx_gui_c::power_handler(void)
{
// the user pressed power button, so there's no doubt they want bochs
// to quit. Change panics to fatal for the GUI and then do a panic.
bx_user_quit = 1;
LOG_THIS setonoff(LOGLEV_PANIC, ACT_FATAL);
BX_PANIC (("POWER button turned off."));
// shouldn't reach this point, but if you do, QUIT!!!

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.100 2003-05-03 16:37:17 cbothamy Exp $
// $Id: siminterface.h,v 1.101 2003-05-27 18:19:13 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Before I can describe what this file is for, I have to make the
@ -1366,3 +1366,4 @@ typedef struct BOCHSAPI {
} bx_startup_flags_t;
BOCHSAPI extern bx_startup_flags_t bx_startup_flags;
BOCHSAPI extern bx_bool bx_user_quit;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: logio.cc,v 1.40 2002-12-17 05:58:43 bdenney Exp $
// $Id: logio.cc,v 1.41 2003-05-27 18:19:12 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -488,6 +488,7 @@ logfunctions::ask (int level, const char *prefix, const char *fmt, va_list ap)
setonoff (level, ACT_REPORT);
break;
case BX_LOG_ASK_CHOICE_DIE:
bx_user_quit = 1;
in_ask_already = 0; // because fatal will longjmp out
fatal (prefix, fmt, ap, 1);
// should never get here

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.226 2003-05-03 16:37:16 cbothamy Exp $
// $Id: main.cc,v 1.227 2003-05-27 18:19:12 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -85,6 +85,7 @@ static logfunctions thePluginLog;
logfunctions *pluginlog = &thePluginLog;
bx_startup_flags_t bx_startup_flags;
bx_bool bx_user_quit;
/* typedefs */
@ -1524,6 +1525,7 @@ static void carbonFatalDialog(const char *error, const char *exposition)
#endif
int bxmain () {
bx_user_quit = 0;
bx_init_siminterface (); // create the SIM object
static jmp_buf context;
if (setjmp (context) == 0) {
@ -1554,11 +1556,14 @@ int bxmain () {
}
SIM->set_quit_context (NULL);
#if defined(WIN32)
// ask user to press ENTER before exiting, so that they can read messages
// before the console window is closed.
fprintf (stderr, "\nBochs is exiting. Press ENTER when you're ready to close this window.\n");
char buf[16];
fgets (buf, sizeof(buf), stdin);
if (!bx_user_quit) {
// ask user to press ENTER before exiting, so that they can read messages
// before the console window is closed. This isn't necessary after pressing
// the power button.
fprintf (stderr, "\nBochs is exiting. Press ENTER when you're ready to close this window.\n");
char buf[16];
fgets (buf, sizeof(buf), stdin);
}
#endif
return SIM->get_exit_code ();
}