eliminate the g_fatal_log array since fatal_printf() shows warning messages immediately.

This commit is contained in:
Kelvin Sherlock 2019-04-11 19:38:29 -04:00
parent f842678e43
commit 1a06196ae7
9 changed files with 13 additions and 97 deletions

View File

@ -44,7 +44,6 @@ extern byte *g_rom_fc_ff_ptr;
extern byte *g_rom_cards_ptr;
extern double g_cur_dcycs;
extern int g_rom_version;
extern int g_fatal_log;
extern word32 g_adb_repeat_vbl;
@ -3183,9 +3182,6 @@ void config_control_panel() {
g_cfg_slotdrive = -1;
g_cfg_select_partition = -1;
while(g_config_control_panel & !(halt_sim&HALT_WANTTOQUIT)) {
if(g_fatal_log > 0) {
x_show_alert(0, 0);
}
cfg_home();
line = 1;
max_line = 1;

View File

@ -421,7 +421,6 @@ void x_dialog_create_gsport_conf(const char *str) {
int x_show_alert(int is_fatal, const char *str) {
// Not implemented yet
adb_all_keys_up();
clear_fatal_logs();
return 0;
}
void x_toggle_status_lines(void) {

View File

@ -14,11 +14,6 @@
extern int x_show_alert(int fatal, const char *str);
#define MAX_FATAL_LOGS 20
int g_fatal_log = 0;
char *g_fatal_log_strs[MAX_FATAL_LOGS];
int glog(const char *s) {
time_t timer;
char buffer[26];
@ -63,33 +58,12 @@ int fatal_printf(const char *fmt, ...) {
va_start(ap, fmt);
if(g_fatal_log < 0) {
g_fatal_log = 0;
}
ret = vsnprintf(buffer, sizeof(buffer), fmt, ap);
glog(buffer);
x_show_alert(1, buffer);
/*
if (g_fatal_log < MAX_FATAL_LOGS) {
g_fatal_log_strs[g_fatal_log++] = strdup(buffer);
}
*/
va_end(ap);
return ret;
}
void clear_fatal_logs() {
int i;
for(i = 0; i < g_fatal_log; i++) {
free(g_fatal_log_strs[i]);
g_fatal_log_strs[i] = 0;
}
g_fatal_log = 0;
}

View File

@ -5,7 +5,6 @@ extern "C" {
int glogf(const char *s, ...);
int fatal_printf(const char *fmt, ...);
void clear_fatal_logs(void);
#ifdef __cplusplus
}

View File

@ -79,19 +79,15 @@ extern int g_screen_mdepth;
Ptr g_mac_fullscreen_state = 0;
Rect g_main_window_saved_rect;
extern char *g_fatal_log_strs[];
extern int g_fatal_log;
int x_show_alert(int is_fatal, const char *str) {
DialogRef alert;
DialogItemIndex out_item_hit;
CFStringRef cfstrref, cfstrref2;
CFStringRef cfstrref;
CFStringRef okstrref;
AlertStdCFStringAlertParamRec alert_param;
OSStatus osstat;
char *bufptr, *buf2ptr;
int sum, len;
int i;
if (!str || !*str) return 0;
/* The dialog eats all events--including key-up events */
/* Call adb_all_keys_up() to prevent annoying key-repeat problems */
@ -100,36 +96,14 @@ int x_show_alert(int is_fatal, const char *str) {
/* auto-repeat will repeat the key, and the dialog re-appears...*/
adb_all_keys_up();
sum = 20;
for(i = 0; i < g_fatal_log; i++) {
sum += strlen(g_fatal_log_strs[i]);
}
bufptr = (char*)malloc(sum);
buf2ptr = bufptr;
for(i = 0; i < g_fatal_log; i++) {
len = strlen(g_fatal_log_strs[i]);
len = MIN(len, sum);
len = MAX(len, 0);
memcpy(bufptr, g_fatal_log_strs[i], MIN(len, sum));
bufptr += len;
bufptr[0] = 0;
sum = sum - len;
}
cfstrref = CFStringCreateWithCString(NULL, buf2ptr,
cfstrref = CFStringCreateWithCString(NULL, str,
kCFStringEncodingMacRoman);
printf("buf2ptr: :%s:\n", buf2ptr);
osstat = GetStandardAlertDefaultParams(&alert_param,
kStdCFStringAlertVersionOne);
if(str) {
// Provide an extra option--create a file
cfstrref2 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
CFSTR("Create ./%s"), str);
alert_param.otherText = cfstrref2;
}
okstrref = CFSTR("Click OK to continue");
if(is_fatal) {
okstrref = CFSTR("Click OK to exit GSplus");
@ -138,12 +112,9 @@ int x_show_alert(int is_fatal, const char *str) {
&alert_param, &alert);
out_item_hit = -1;
RunStandardAlert(alert, NULL, &out_item_hit);
printf("out_item_hit: %d\n", out_item_hit);
free(buf2ptr);
clear_fatal_logs(); /* free the fatal_log string memory */
CFRelease(cfstrref);
return (out_item_hit >= 3);
}
@ -159,28 +130,18 @@ pascal OSStatus quit_event_handler(EventHandlerCallRef call_ref, EventRef event,
}
void show_simple_alert(char *str1, char *str2, char *str3, int num) {
char buf[256];
char buf[4096];
g_fatal_log_strs[0] = gsplus_malloc_str(str1);
g_fatal_log_strs[1] = gsplus_malloc_str(str2);
g_fatal_log_strs[2] = gsplus_malloc_str(str3);
g_fatal_log = 3;
if(num != 0) {
snprintf(buf, 250, ": %d", num);
g_fatal_log_strs[g_fatal_log++] = gsplus_malloc_str(buf);
if (num) {
snprintf(buffer, sizeof(buffer), "%s%s%s: %d", str1, str2, str3, num);
} else {
snprintf(buffer, sizeof(buffer), "%s%s%s", str1, str2, str3);
}
x_show_alert(0, 0);
x_show_alert(0, buf);
}
void x_dialog_create_gsport_conf(const char *str) {
char *path;
char tmp_buf[512];
int ret;
ret = x_show_alert(1, str);
if(ret) {
config_write_config_gsplus_file();
}
config_write_config_gsplus_file();
}
@ -698,11 +659,6 @@ CantGetNibRef:
void xdriver_end() {
printf("xdriver_end\n");
if(g_fatal_log >= 0) {
x_show_alert(1, 0);
}
}

View File

@ -226,7 +226,6 @@ void scc_socket_open_outgoing(int port, double dcycs) {
#endif
scc_socket_close_handle(sockfd);
scc_socket_close(port, 1, dcycs);
x_show_alert(0, 0);
return;
}
memcpy(&sa_in.sin_addr.s_addr, hostentptr->h_addr,

View File

@ -1011,7 +1011,6 @@ int gsplusmain(int argc, char **argv) {
iwm_shut();
fixed_memory_ptrs_shut();
load_roms_shut_memory();
clear_fatal_logs();
// OG Not needed anymore : the emulator will quit gently
//my_exit(0);
@ -1184,8 +1183,6 @@ void setup_gsplus_file(char *outname, int maxlen, int ok_if_missing, int can_cre
x_dialog_create_gsport_conf(*name_ptr);
can_create_file = 0;
// But clear out the fatal_printfs first
clear_fatal_logs();
setup_gsplus_file(outname, maxlen, ok_if_missing, can_create_file, name_ptr);
// It's one-level of recursion--it cannot loop since we
// clear can_create_file.

View File

@ -58,6 +58,7 @@ void x_dialog_create_gsport_conf(const char *str) {
int x_show_alert(int is_fatal, const char *str) {
if (str && *str) {
adb_all_keys_up();
MessageBox(NULL, str, "GS+", is_fatal ? MB_ICONERROR : MB_ICONWARNING);
}
return 0;
@ -143,10 +144,6 @@ int main(int argc, char **argv) {
size.cx, size.cy,
NULL, NULL, GetModuleHandle(NULL), NULL);
printf("g_hwnd_main = %p, height = %d\n", hwnd, size.cx);
GetWindowRect(hwnd, &rect);
printf("...rect is: %ld, %ld, %ld, %ld\n", rect.left, rect.top,
rect.right, rect.bottom);
// Enable non-blocking, character-at-a-time console I/O.
// win_nonblock_read_stdin() expects this behavior.

View File

@ -254,7 +254,6 @@ int x_show_alert(int is_fatal, const char *str) {
/* Not implemented yet */
adb_all_keys_up();
clear_fatal_logs();
return 0;
}