From 69cea38f41b411ca9e55db365cf94339f4be891c Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 26 Apr 2016 12:14:56 +0100 Subject: update scrollbar_create error handling to return nserror --- desktop/frames.c | 14 ++++++++------ desktop/scrollbar.c | 10 ++++------ desktop/textarea.c | 12 +++++++----- 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'desktop') diff --git a/desktop/frames.c b/desktop/frames.c index 394deb2ad..7be75ce77 100644 --- a/desktop/frames.c +++ b/desktop/frames.c @@ -147,10 +147,11 @@ void browser_window_handle_scrollbars(struct browser_window *bw) if (bw->scroll_y == NULL) { /* create vertical scrollbar */ - if (!scrollbar_create(false, length, c_height, visible, - bw, browser_window_scroll_callback, - &(bw->scroll_y))) + if (scrollbar_create(false, length, c_height, visible, + bw, browser_window_scroll_callback, + &(bw->scroll_y)) != NSERROR_OK) { return; + } } else { /* update vertical scrollbar */ scrollbar_set_extents(bw->scroll_y, length, @@ -164,10 +165,11 @@ void browser_window_handle_scrollbars(struct browser_window *bw) if (bw->scroll_x == NULL) { /* create horizontal scrollbar */ - if (!scrollbar_create(true, length, c_width, visible, - bw, browser_window_scroll_callback, - &(bw->scroll_x))) + if (scrollbar_create(true, length, c_width, visible, + bw, browser_window_scroll_callback, + &(bw->scroll_x)) != NSERROR_OK) { return; + } } else { /* update horizontal scrollbar */ scrollbar_set_extents(bw->scroll_x, length, diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c index caed13fbc..82fcac1c9 100644 --- a/desktop/scrollbar.c +++ b/desktop/scrollbar.c @@ -70,9 +70,9 @@ struct scrollbar { /* - * Exported function. Documented in scrollbar.h + * Exported function. Documented in desktop/scrollbar.h */ -bool scrollbar_create(bool horizontal, int length, int full_size, +nserror scrollbar_create(bool horizontal, int length, int full_size, int visible_size, void *client_data, scrollbar_client_callback client_callback, struct scrollbar **s) @@ -82,10 +82,8 @@ bool scrollbar_create(bool horizontal, int length, int full_size, scrollbar = malloc(sizeof(struct scrollbar)); if (scrollbar == NULL) { - LOG("malloc failed"); - warn_user("NoMemory", 0); *s = NULL; - return false; + return NSERROR_NOMEM; } scrollbar->horizontal = horizontal; @@ -109,7 +107,7 @@ bool scrollbar_create(bool horizontal, int length, int full_size, *s = scrollbar; - return true; + return NSERROR_OK; } diff --git a/desktop/textarea.c b/desktop/textarea.c index 4a7e008bc..467965d39 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -1029,10 +1029,11 @@ static bool textarea_reflow_multiline(struct textarea *ta, if (x > avail_width && ta->bar_x == NULL) { /* We need to insert a horizontal scrollbar */ int w = ta->vis_width - 2 * ta->border_width; - if (!scrollbar_create(true, w, w, w, + if (scrollbar_create(true, w, w, w, ta, textarea_scrollbar_callback, - &(ta->bar_x))) + &(ta->bar_x)) != NSERROR_OK) { return false; + } if (ta->bar_y != NULL) scrollbar_make_pair(ta->bar_x, ta->bar_y); @@ -1120,10 +1121,11 @@ static bool textarea_reflow_multiline(struct textarea *ta, if (line > scroll_lines && ta->bar_y == NULL) { /* Add vertical scrollbar */ int h = ta->vis_height - 2 * ta->border_width; - if (!scrollbar_create(false, h, h, h, - ta, textarea_scrollbar_callback, - &(ta->bar_y))) + if (scrollbar_create(false, h, h, h, + ta, textarea_scrollbar_callback, + &(ta->bar_y)) != NSERROR_OK) { return false; + } if (ta->bar_x != NULL) scrollbar_make_pair(ta->bar_x, ta->bar_y); -- cgit v1.2.3