AmendHub

Download:

jcs

/

subtext

/

amendments

/

122

util: vwarn can't re-use its alert DITL handle, make a new one

But still pre-allocate one at startup

jcs made amendment 122 over 2 years ago
--- util.c Wed Jun 1 13:11:54 2022 +++ util.c Tue Jun 7 14:04:37 2022 @@ -275,7 +275,7 @@ vwarn(short alert_func, const char *format, va_list ap bounds.top = GetMBarHeight() + ((screenBits.bounds.bottom - height) / 2.5); bounds.bottom = bounds.top + height; - + ParamText(CtoPstr(err_str), "\p", "\p", "\p"); dialog = NewDialog(nil, &bounds, "\p", false, dBoxProc, @@ -306,6 +306,19 @@ vwarn(short alert_func, const char *format, va_list ap } DisposDialog(dialog); + /* + * Pre-allocate for the next one while we have memory. We can't use + * xNewHandle because we might already be alerting about an OOM + * condition. + */ + DisposHandle(alert_ditl_h); + alert_ditl_h = NewHandle(sizeof(alert_ditl)); + if (alert_ditl_h == NULL) + ExitToShell(); + HLock(alert_ditl_h); + memcpy(*alert_ditl_h, alert_ditl, sizeof(alert_ditl)); + HUnlock(alert_ditl_h); + SetPort(win); if (quit) @@ -405,7 +418,7 @@ ask(const char *format, ...) break; } DisposDialog(dialog); - DisposHandle(alert_ditl_h); + DisposHandle(ask_ditl); SetPort(win);