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
This commit is contained in:
John Mark Bell 2010-04-07 06:22:15 +00:00
parent 72520da221
commit cbf55bd418
2 changed files with 32 additions and 10 deletions

View File

@ -2315,9 +2315,15 @@ void browser_window_form_select(struct browser_window *bw,
struct box *inline_box;
struct form_option *o;
int count;
struct content *current_content;
assert(bw);
assert(control);
assert(bw != NULL);
assert(control != NULL);
assert(bw->current_content != NULL);
/** \todo This must die. Browser windows have no business poking
* around inside contents */
current_content = hlcache_handle_get_content(bw->current_content);
inline_box = control->box->children->children;
@ -2346,13 +2352,13 @@ void browser_window_form_select(struct browser_window *bw,
talloc_free(inline_box->text);
inline_box->text = 0;
if (control->data.select.num_selected == 0)
inline_box->text = talloc_strdup(bw->current_content,
inline_box->text = talloc_strdup(current_content,
messages_get("Form_None"));
else if (control->data.select.num_selected == 1)
inline_box->text = talloc_strdup(bw->current_content,
inline_box->text = talloc_strdup(current_content,
control->data.select.current->text);
else
inline_box->text = talloc_strdup(bw->current_content,
inline_box->text = talloc_strdup(current_content,
messages_get("Form_Many"));
if (!inline_box->text) {
warn_user("NoMemory", 0);

View File

@ -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;