fixed crash from breaking mred too early

svn: r285
This commit is contained in:
Matthew Flatt 2005-06-30 21:18:38 +00:00
parent f2f6a71402
commit 051db368f1
3 changed files with 50 additions and 33 deletions

View File

@ -3766,35 +3766,16 @@ static unsigned long get_deeper_base()
/****************************************************************************/
#if defined(wx_mac) || defined(wx_msw)
void wxDrop_Runtime(char **argv, int argc)
{
int i;
mz_jmp_buf *save, newbuf;
save = scheme_current_thread->error_buf;
scheme_current_thread->error_buf = &newbuf;
if (scheme_setjmp(newbuf)) {
/* give up on rest */
scheme_clear_escape();
} else {
for (i = 0; i < argc; i++) {
Scheme_Object *p[1];
p[0] = scheme_make_path(argv[i]);
scheme_apply(wxs_app_file_proc, 1, p);
}
}
scheme_current_thread->error_buf = save;
}
#endif
#if defined(wx_mac) || defined(wx_msw)
static void wxDo(Scheme_Object *proc)
static void wxDo(Scheme_Object *proc, int argc, Scheme_Object **argv)
{
mz_jmp_buf * volatile save, newbuf;
volatile int block_descriptor;
if (!proc) {
/* Oops --- too early. */
return;
}
/* wxDo might be called when MrEd is sleeping (i.e.,
blocked on WNE in OS X). Since we're hijacking the
thread, save an restore block information. */
@ -3809,7 +3790,7 @@ static void wxDo(Scheme_Object *proc)
if (scheme_setjmp(newbuf)) {
scheme_clear_escape();
} else {
scheme_apply(proc, 0, NULL);
scheme_apply(proc, argc, argv);
}
scheme_current_thread->error_buf = save;
@ -3818,6 +3799,18 @@ static void wxDo(Scheme_Object *proc)
scheme_end_atomic_no_swap();
}
#if defined(wx_mac) || defined(wx_msw)
void wxDrop_Runtime(char **argv, int argc)
{
int i;
for (i = 0; i < argc; i++) {
Scheme_Object *p[1];
wxDo(wxs_app_file_proc, 1, p);
}
}
#endif
void wxDrop_Quit()
{
if (ioFrame) {
@ -3825,20 +3818,20 @@ void wxDrop_Quit()
ioFrame->Show(FALSE);
}
wxDo(wxs_app_quit_proc);
wxDo(wxs_app_quit_proc, 0, NULL);
}
#endif
#ifdef wx_mac
void wxDo_About()
{
wxDo(wxs_app_about_proc);
wxDo(wxs_app_about_proc, 0, NULL);
}
void wxDo_Pref()
{
if (!SCHEME_FALSEP(wxs_app_pref_proc))
wxDo(wxs_app_pref_proc);
wxDo(wxs_app_pref_proc, 0, NULL);
}
int wxCan_Do_Pref()

View File

@ -226,7 +226,14 @@ static int do_main_loop(FinishArgs *fa)
}
#endif
{
mz_jmp_buf * volatile save, newbuf;
save = scheme_current_thread->error_buf;
scheme_current_thread->error_buf = &newbuf;
if (!scheme_setjmp(newbuf))
wxDoMainLoop();
scheme_current_thread->error_buf = save;
}
return 0;
}

View File

@ -303,15 +303,32 @@ static int finish_cmd_line_run(FinishArgs *fa, Repl_Proc repl)
#ifndef DONT_RUN_REP
if (!fa->no_rep && !fa->script_mode) {
/* enter read-eval-print loop */
mz_jmp_buf * volatile save, newbuf;
save = scheme_current_thread->error_buf;
scheme_current_thread->error_buf = &newbuf;
if (!scheme_setjmp(newbuf)) {
repl(fa->global_env);
exit_val = 0;
} else {
exit_val = 1;
#ifdef VERSION_YIELD_FLAG
fa->add_yield = 0;
#endif
}
scheme_current_thread->error_buf = save;
}
#endif /* DONT_RUN_REP */
#ifdef VERSION_YIELD_FLAG
if (fa->add_yield) {
mz_jmp_buf * volatile save, newbuf;
save = scheme_current_thread->error_buf;
scheme_current_thread->error_buf = &newbuf;
if (!scheme_setjmp(newbuf)) {
yield_indefinitely();
}
scheme_current_thread->error_buf = save;
}
#endif
return exit_val;