mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
elinks_object: use usrerror if there is no term
Currently, elinks_alert assumes that smjs_ses is not NULL and crashes if it is. Change elinks_alert to check whether smjs_term is NULL, try get_default_terminal if so, and fall back on printing to stderr using usrerror if no terminal is found.
This commit is contained in:
parent
e310843a2a
commit
68801b7382
@ -76,6 +76,7 @@ elinks_alert(JSContext *ctx, uintN argc, jsval *rval)
|
|||||||
jsval val;
|
jsval val;
|
||||||
jsval *argv = JS_ARGV(ctx, rval);
|
jsval *argv = JS_ARGV(ctx, rval);
|
||||||
unsigned char *string;
|
unsigned char *string;
|
||||||
|
struct terminal *term;
|
||||||
|
|
||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
@ -84,8 +85,19 @@ elinks_alert(JSContext *ctx, uintN argc, jsval *rval)
|
|||||||
if (!*string)
|
if (!*string)
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
|
||||||
info_box(smjs_ses->tab->term, MSGBOX_NO_TEXT_INTL,
|
if (smjs_ses) {
|
||||||
|
term = smjs_ses->tab->term;
|
||||||
|
} else {
|
||||||
|
term = get_default_terminal();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (term) {
|
||||||
|
info_box(term, MSGBOX_NO_TEXT_INTL,
|
||||||
N_("User script alert"), ALIGN_LEFT, string);
|
N_("User script alert"), ALIGN_LEFT, string);
|
||||||
|
} else {
|
||||||
|
usrerror("%s", string);
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
|
||||||
undef_to_jsval(ctx, &val);
|
undef_to_jsval(ctx, &val);
|
||||||
JS_SET_RVAL(ctx, rval, val);
|
JS_SET_RVAL(ctx, rval, val);
|
||||||
|
Loading…
Reference in New Issue
Block a user