jcs
/amend
/amendments
/75
util: Fix possible corruption/crash in progress()
Don't reset the port back to what we thought it was at the beginning
since it may have changed between progress("") and progress(NULL), and
SetPort with a bogus window might be what's causing crashes later
Also constify DITL definitions while we're here
jcs made amendment 75 over 2 years ago
--- util.c Thu Feb 3 17:20:28 2022
+++ util.c Wed Jun 15 10:03:39 2022
@@ -29,7 +29,7 @@ static char err_str[ERROR_STRING_SIZE];
/* basic DITL with an ok button (1), text area (2), and icon (3) */
#define ALERT_DITL_ICON 3
-static char alert_ditl[] = {
+static const char alert_ditl[] = {
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
0x00, 0xE6, 0x00, 0x5A, 0x01, 0x20, 0x04, 0x02,
0x4F, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A,
@@ -41,7 +41,7 @@ static char alert_ditl[] = {
static Handle alert_ditl_h = NULL;
/* DITL with a Yes button (1), No button (2), text (3), and icon (4) */
-static char ask_ditl[] = {
+static const char ask_ditl[] = {
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
0x00, 0xE6, 0x00, 0x5A, 0x01, 0x20, 0x04, 0x03,
0x59, 0x65, 0x73, 0x21, 0x00, 0x00, 0x00, 0x00,
@@ -55,7 +55,7 @@ static char ask_ditl[] = {
static Handle ask_ditl_h = NULL;
/* DITL with just a text view */
-static char progress_ditl[] = {
+static const char progress_ditl[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14,
0x00, 0x1E, 0x00, 0x32, 0x01, 0x3B, 0x08, 0x02,
0x5E, 0x30
@@ -419,7 +419,6 @@ progress(char *format, ...)
va_list argptr;
Rect bounds = { 100, 90, 160, 420 }; /* tlbr */
Rect trect;
- static WindowPtr progress_win;
short ttype;
if (format == NULL) {
@@ -428,7 +427,6 @@ progress(char *format, ...)
DisposHandle(progress_ditl_h);
progress_dialog = NULL;
}
- SetPort(progress_win);
return;
}
@@ -438,8 +436,6 @@ progress(char *format, ...)
CtoPstr(progress_s);
if (progress_dialog == NULL) {
- GetPort(&progress_win);
-
progress_ditl_h = xNewHandle(sizeof(progress_ditl));
HLock(progress_ditl_h);
memcpy(*progress_ditl_h, progress_ditl, sizeof(progress_ditl));