use form of window create which returns an error instead of aborting

This commit is contained in:
Vincent Sanders 2020-04-14 21:08:51 +01:00
parent e2f34232a2
commit 84f0c760e6
4 changed files with 38 additions and 4 deletions

View File

@ -342,6 +342,7 @@ cookie_menu_select(wimp_w w,
*/
static nserror ro_cookie_init(void)
{
os_error *error;
struct ro_cookie_window *ncwin;
nserror res;
static const struct ns_menu cookie_menu_def = {
@ -383,7 +384,14 @@ static nserror ro_cookie_init(void)
}
/* create window from template */
ncwin->core.wh = wimp_create_window(dialog_cookie_template);
error = xwimp_create_window(dialog_cookie_template, &ncwin->core.wh);
if (error) {
NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
free(ncwin);
return NSERROR_NOMEM;
}
ro_gui_set_window_title(ncwin->core.wh, messages_get("Cookies"));

View File

@ -367,6 +367,7 @@ global_history_menu_select(wimp_w w,
*/
static nserror ro_global_history_init(void)
{
os_error *error;
struct ro_global_history_window *ncwin;
nserror res;
static const struct ns_menu global_history_menu_def = {
@ -411,7 +412,15 @@ static nserror ro_global_history_init(void)
}
/* create window from template */
ncwin->core.wh = wimp_create_window(dialog_global_history_template);
error = xwimp_create_window(dialog_global_history_template,
&ncwin->core.wh);
if (error) {
NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
free(ncwin);
return NSERROR_NOMEM;
}
ro_gui_set_window_title(ncwin->core.wh, messages_get("GlobalHistory"));

View File

@ -423,6 +423,7 @@ hotlist_menu_select(wimp_w w,
*/
static nserror ro_hotlist_init(void)
{
os_error *error;
struct ro_hotlist_window *ncwin;
nserror res;
static const struct ns_menu hotlist_menu_def = {
@ -472,7 +473,14 @@ static nserror ro_hotlist_init(void)
}
/* create window from template */
ncwin->core.wh = wimp_create_window(dialog_hotlist_template);
error = xwimp_create_window(dialog_hotlist_template, &ncwin->core.wh);
if (error) {
NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
free(ncwin);
return NSERROR_NOMEM;
}
ro_gui_set_window_title(ncwin->core.wh, messages_get("Hotlist"));

View File

@ -289,6 +289,7 @@ static nserror
ro_local_history_init(struct browser_window *bw,
struct ro_local_history_window **win_out)
{
os_error *error;
struct ro_local_history_window *ncwin;
nserror res;
@ -306,7 +307,15 @@ ro_local_history_init(struct browser_window *bw,
}
/* create window from template */
ncwin->core.wh = wimp_create_window(dialog_local_history_template);
error = xwimp_create_window(dialog_local_history_template,
&ncwin->core.wh);
if (error) {
NSLOG(netsurf, INFO, "xwimp_create_window: 0x%x: %s",
error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
free(ncwin);
return NSERROR_NOMEM;
}
/* initialise callbacks */
ncwin->core.draw = ro_local_history_draw;