diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2010-04-07 06:22:15 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2010-04-07 06:22:15 +0000 |
commit | cbf55bd418814a943422dffacf37f18c4ab3e839 (patch) | |
tree | 8ad8fd9e6680856cdac9b0560045ffad99903d42 /desktop/textinput.c | |
parent | 72520da221afb0b124bf65d973f81ab05b1402a0 (diff) | |
download | netsurf-cbf55bd418814a943422dffacf37f18c4ab3e839.tar.gz netsurf-cbf55bd418814a943422dffacf37f18c4ab3e839.tar.bz2 |
Fix textarea crash.
I cannot express just how much I hate the necessity of this change: browser windows (and other code in desktop/) should stop poking around inside content objects
svn path=/trunk/netsurf/; revision=10258
Diffstat (limited to 'desktop/textinput.c')
-rw-r--r-- | desktop/textinput.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/desktop/textinput.c b/desktop/textinput.c index 7739140fb..5058ce439 100644 --- a/desktop/textinput.c +++ b/desktop/textinput.c @@ -1664,8 +1664,16 @@ bool textbox_insert(struct browser_window *bw, struct box *text_box, { char *text; struct box *input = text_box->parent->parent; + struct content *current_content; bool hide; + assert(bw != NULL); + assert(bw->current_content != NULL); + + /** \todo Stop poking around inside contents. + * Why is this code in desktop/, anyway? (It's HTML-specific) */ + current_content = hlcache_handle_get_content(bw->current_content); + if (bw->sel->defined) delete_selection(bw->sel); @@ -1702,7 +1710,7 @@ bool textbox_insert(struct browser_window *bw, struct box *text_box, } /* insert in text box */ - text = talloc_realloc(bw->current_content, text_box->text, + text = talloc_realloc(current_content, text_box->text, char, text_box->length + text_box->space + utf8_len + 1); if (!text) { @@ -1961,16 +1969,24 @@ struct box *textarea_insert_break(struct browser_window *bw, struct box *text_box, size_t char_offset) { struct box *new_br, *new_text; - char *text = talloc_array(bw->current_content, char, - text_box->length + 1); + struct content *current_content; + char *text; + + assert(bw != NULL); + assert(bw->current_content != NULL); + + /** \todo Stop poking around inside content objects */ + current_content = hlcache_handle_get_content(bw->current_content); + + text = talloc_array(current_content, char, text_box->length + 1); if (!text) { warn_user("NoMemory", 0); return NULL; } new_br = box_create(text_box->style, 0, 0, text_box->title, 0, - bw->current_content); - new_text = talloc(bw->current_content, struct box); + current_content); + new_text = talloc(current_content, struct box); if (!new_text) { warn_user("NoMemory", 0); return NULL; |