Patch name: patch.carbon-startup
Authors: Br'fin, Bryce - for MacOSX/Carbon, if you start the app by double clicking in the finder, there is no text console. So in logfunctions::fatal(), display the final message in a Carbon dialog instead of using fprintf. - in the text-mode config interface, return an error code if the user tries to use the text menus when there's no text console. Back in bxmain() this error code causes a panic "Bochs needed the text console, but it was not usable" - if a config file was not found, normally we turn off quick start and drop into the text menus. However in the no-console case the text menus won't work, so we added a panic: Unable to start Bochs without a bochsrc.txt and without a text console. This is a much more useful error than the generic one above. - removed ensure_text_console() which was making matters worse instead of better. Modified Files: logio.cc main.cc gui/siminterface.cc gui/siminterface.h gui/textconfig.cc
This commit is contained in:
parent
2e2a3085ad
commit
6a44ca37ed
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.cc,v 1.92 2002-12-17 03:36:53 yakovlev Exp $
|
||||
// $Id: siminterface.cc,v 1.93 2002-12-17 05:58:44 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// See siminterface.h for description of the siminterface concept.
|
||||
@ -131,6 +131,7 @@ public:
|
||||
if (bx_gui != NULL)
|
||||
bx_gui->set_display_mode (newmode);
|
||||
}
|
||||
virtual bool test_for_text_console ();
|
||||
};
|
||||
|
||||
bx_param_c *
|
||||
@ -747,6 +748,23 @@ bool bx_real_sim_c::is_sim_thread ()
|
||||
return (*is_sim_thread_func)();
|
||||
}
|
||||
|
||||
// check if the text console exists. On some platforms, if Bochs is
|
||||
// started from the "Start Menu" or by double clicking on it on a Mac,
|
||||
// there may be nothing attached to stdin/stdout/stderr. This function
|
||||
// tests if stdin/stdout/stderr are usable and returns false if not.
|
||||
bool
|
||||
bx_real_sim_c::test_for_text_console ()
|
||||
{
|
||||
#if BX_WITH_CARBON
|
||||
// In a Carbon application, you have a text console if you run the app from
|
||||
// the command line, but if you start it from the finder you don't.
|
||||
if(!isatty(STDIN_FILENO)) return false;
|
||||
#endif
|
||||
// default: yes
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// define methods of bx_param_* and family
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: siminterface.h,v 1.96 2002-12-17 03:36:53 yakovlev Exp $
|
||||
// $Id: siminterface.h,v 1.97 2002-12-17 05:58:45 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Before I can describe what this file is for, I have to make the
|
||||
@ -1157,6 +1157,10 @@ typedef struct {
|
||||
#include <setjmp.h>
|
||||
|
||||
enum ci_command_t { CI_START, CI_RUNTIME_CONFIG, CI_SHUTDOWN };
|
||||
enum ci_return_t {
|
||||
CI_OK, // normal return value
|
||||
CI_ERR_NO_TEXT_CONSOLE // err: can't work because there's no text console
|
||||
};
|
||||
typedef int (*config_interface_callback_t)(void *userdata, ci_command_t command);
|
||||
|
||||
// bx_gui->set_display_mode() changes the mode between the configuration
|
||||
@ -1284,6 +1288,7 @@ public:
|
||||
// provide interface to bx_gui->set_display_mode() method for config
|
||||
// interfaces to use.
|
||||
virtual void set_display_mode (disp_mode_t newmode) {}
|
||||
virtual bool test_for_text_console () { return true; }
|
||||
};
|
||||
|
||||
BOCHSAPI extern bx_simulator_interface_c *SIM;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: textconfig.cc,v 1.7 2002-12-12 18:31:20 bdenney Exp $
|
||||
// $Id: textconfig.cc,v 1.8 2002-12-17 05:58:45 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is code for a text-mode configuration interfac. Note that this file
|
||||
@ -974,8 +974,11 @@ static int ci_callback (void *userdata, ci_command_t command)
|
||||
bx_config_interface_init ();
|
||||
if (SIM->get_param_enum(BXP_BOCHS_START)->get () == BX_QUICK_START)
|
||||
bx_config_interface (BX_CI_START_SIMULATION);
|
||||
else
|
||||
else {
|
||||
if (!SIM->test_for_text_console ())
|
||||
return CI_ERR_NO_TEXT_CONSOLE;
|
||||
bx_config_interface (BX_CI_START_MENU);
|
||||
}
|
||||
break;
|
||||
case CI_RUNTIME_CONFIG:
|
||||
bx_config_interface (BX_CI_RUNTIME);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: logio.cc,v 1.39 2002-12-17 03:36:53 yakovlev Exp $
|
||||
// $Id: logio.cc,v 1.40 2002-12-17 05:58:43 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
@ -30,6 +30,10 @@
|
||||
#include <assert.h>
|
||||
#include "state_file.h"
|
||||
|
||||
#if BX_WITH_CARBON
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
// Just for the iofunctions
|
||||
|
||||
|
||||
@ -524,10 +528,59 @@ logfunctions::ask (int level, const char *prefix, const char *fmt, va_list ap)
|
||||
in_ask_already = 0;
|
||||
}
|
||||
|
||||
#if BX_WITH_CARBON
|
||||
/* Panic button to display fatal errors.
|
||||
Completely self contained, can't rely on carbon.cc being available */
|
||||
static void carbonFatalDialog(const char *error, const char *exposition)
|
||||
{
|
||||
DialogRef alertDialog;
|
||||
CFStringRef cfError;
|
||||
CFStringRef cfExposition;
|
||||
DialogItemIndex index;
|
||||
AlertStdCFStringAlertParamRec alertParam = {0};
|
||||
|
||||
// Init libraries
|
||||
InitCursor();
|
||||
// Assemble dialog
|
||||
cfError = CFStringCreateWithCString(NULL, error, kCFStringEncodingASCII);
|
||||
if(exposition != NULL)
|
||||
{
|
||||
cfExposition = CFStringCreateWithCString(NULL, exposition, kCFStringEncodingASCII);
|
||||
}
|
||||
else { cfExposition = NULL; }
|
||||
alertParam.version = kStdCFStringAlertVersionOne;
|
||||
alertParam.defaultText = CFSTR("Quit");
|
||||
alertParam.position = kWindowDefaultPosition;
|
||||
alertParam.defaultButton = kAlertStdAlertOKButton;
|
||||
// Display Dialog
|
||||
CreateStandardAlert(
|
||||
kAlertStopAlert,
|
||||
cfError,
|
||||
cfExposition, /* can be NULL */
|
||||
&alertParam, /* can be NULL */
|
||||
&alertDialog);
|
||||
RunStandardAlert( alertDialog, NULL, &index);
|
||||
// Cleanup
|
||||
CFRelease( cfError );
|
||||
if( cfExposition != NULL ) { CFRelease( cfExposition ); }
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
logfunctions::fatal (const char *prefix, const char *fmt, va_list ap, int exit_status)
|
||||
{
|
||||
bx_atexit();
|
||||
#if BX_WITH_CARBON
|
||||
if(!isatty(STDIN_FILENO) && !SIM->get_init_done())
|
||||
{
|
||||
char buf1[1024];
|
||||
char buf2[1024];
|
||||
vsprintf (buf1, fmt, ap);
|
||||
sprintf (buf2, "Bochs startup error\n%s", buf1);
|
||||
carbonFatalDialog(buf2,
|
||||
"For more information, try running Bochs within Terminal by clicking on \"bochs.scpt\".");
|
||||
}
|
||||
#endif
|
||||
#if !BX_WITH_WX
|
||||
static char *divider = "========================================================================";
|
||||
fprintf (stderr, "%s\n", divider);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: main.cc,v 1.211 2002-12-17 03:36:53 yakovlev Exp $
|
||||
// $Id: main.cc,v 1.212 2002-12-17 05:58:44 bdenney Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
@ -1471,30 +1471,6 @@ static void carbonFatalDialog(const char *error, const char *exposition)
|
||||
}
|
||||
#endif
|
||||
|
||||
// In some situations, there is no way to display stdin/stdout. In that case
|
||||
// running the text configure interface is useless and confusing because the
|
||||
// program will either quit instantly or freeze. Instead just show a message
|
||||
// telling the user what they should do instead. If the text console is
|
||||
// ok to use, this function should return true. If not, it should display
|
||||
// a warning and return false.
|
||||
bx_bool ensure_text_console_exists ()
|
||||
{
|
||||
#if BX_WITH_SDL && defined(WIN32)
|
||||
// insert Win32 way of displaying a message dialog
|
||||
// win32dialog ("Please run Bochs by clicking on the ___ instead, or run from the command line with -q");
|
||||
// return false;
|
||||
#endif
|
||||
#if BX_WITH_CARBON
|
||||
if(!isatty(STDIN_FILENO))
|
||||
{
|
||||
carbonFatalDialog("Bochs was unable to load the \"bochsrc.txt\" configuration file",
|
||||
"Copy Bochs to a directory with a valid \"bochsrc.txt\" configuration file. (Such as the dlxlinux directory) or Run Bochs within Terminal by clicking on \"bochs.scpt\".");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
int bxmain () {
|
||||
bx_init_siminterface (); // create the SIM object
|
||||
static jmp_buf context;
|
||||
@ -1507,8 +1483,6 @@ int bxmain () {
|
||||
bx_param_enum_c *ci_param = SIM->get_param_enum (BXP_SEL_CONFIG_INTERFACE);
|
||||
char *ci_name = ci_param->get_choice (ci_param->get ());
|
||||
if (!strcmp(ci_name, "textconfig")) {
|
||||
if (!ensure_text_console_exists ())
|
||||
SIM->quit_sim (1);
|
||||
init_text_config_interface (); // in textconfig.h
|
||||
}
|
||||
#if BX_WITH_WX
|
||||
@ -1519,7 +1493,9 @@ int bxmain () {
|
||||
else {
|
||||
BX_PANIC (("unsupported configuration interface '%s'", ci_name));
|
||||
}
|
||||
SIM->configuration_interface (ci_name, CI_START);
|
||||
int status = SIM->configuration_interface (ci_name, CI_START);
|
||||
if (status == CI_ERR_NO_TEXT_CONSOLE)
|
||||
BX_PANIC (("Bochs needed the text console, but it was not usable"));
|
||||
// user quit the config interface, so just quit
|
||||
} else {
|
||||
// quit via longjmp
|
||||
@ -1866,7 +1842,10 @@ bx_init_main (int argc, char *argv[])
|
||||
// Switch off quick start so that we will drop into the configuration
|
||||
// interface.
|
||||
if (SIM->get_param_enum(BXP_BOCHS_START)->get() == BX_QUICK_START) {
|
||||
BX_ERROR (("Switching off quick start, because no configuration file was found."));
|
||||
if (!SIM->test_for_text_console ())
|
||||
BX_PANIC(("Unable to start Bochs without a bochsrc.txt and without a text console"));
|
||||
else
|
||||
BX_ERROR (("Switching off quick start, because no configuration file was found."));
|
||||
}
|
||||
SIM->get_param_enum(BXP_BOCHS_START)->set (BX_LOAD_START);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user