1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

952, 954: Add ecmascript_detach_form_view stub

Anything that frees struct form_view must now call the new function
ecmascript_detach_form_view.  This function should then clear out any
dangling pointers, but that has not yet been implemented.
This commit is contained in:
Kalle Olavi Niemitalo 2008-07-18 19:43:30 +03:00 committed by Kalle Olavi Niemitalo
parent bbadb99dd1
commit 759fbb1142
7 changed files with 36 additions and 4 deletions

View File

@ -214,6 +214,16 @@ ecmascript_eval_boolback(struct ecmascript_interpreter *interpreter,
return result;
}
void
ecmascript_detach_form_view(struct form_view *fv)
{
#ifdef CONFIG_ECMASCRIPT_SEE
see_detach_form_view(fv);
#else
spidermonkey_detach_form_view(fv);
#endif
}
void ecmascript_detach_form_state(struct form_state *fs)
{
#ifdef CONFIG_ECMASCRIPT_SEE
@ -242,6 +252,8 @@ ecmascript_reset_state(struct view_state *vs)
* ecmascript_obj pointers are also NULL. However, they might
* be non-NULL if the ECMAScript objects have been lazily
* created because of scripts running in sibling HTML frames. */
foreach (fv, vs->forms)
ecmascript_detach_form_view(fv);
for (i = 0; i < vs->form_info_len; i++)
ecmascript_detach_form_state(&vs->form_info[i]);
@ -249,9 +261,6 @@ ecmascript_reset_state(struct view_state *vs)
if (vs->ecmascript)
ecmascript_put_interpreter(vs->ecmascript);
foreach (fv, vs->forms)
fv->ecmascript_obj = NULL;
vs->ecmascript = ecmascript_get_interpreter(vs);
if (!vs->ecmascript)
vs->ecmascript_fragile = 1;

View File

@ -9,6 +9,7 @@
#include "util/time.h"
struct form_state;
struct form_view;
struct string;
struct terminal;
struct uri;
@ -71,6 +72,7 @@ void ecmascript_free_urls(struct module *module);
struct ecmascript_interpreter *ecmascript_get_interpreter(struct view_state*vs);
void ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter);
void ecmascript_detach_form_view(struct form_view *fv);
void ecmascript_detach_form_state(struct form_state *fs);
void ecmascript_moved_form_state(struct form_state *fs);

View File

@ -7,6 +7,7 @@ struct string;
void *see_get_interpreter(struct ecmascript_interpreter *interpreter);
void see_put_interpreter(struct ecmascript_interpreter *interpreter);
#define see_detach_form_view(fv) ((fv)->ecmascript_obj = NULL)
#define see_detach_form_state(fs) ((fs)->ecmascript_obj = NULL)
#define see_moved_form_state(fs) ((void) (fs))

View File

@ -7,6 +7,7 @@ struct string;
void *spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter);
void spidermonkey_put_interpreter(struct ecmascript_interpreter *interpreter);
#define spidermonkey_detach_form_view(fv) ((fv)->ecmascript_obj = NULL)
#define spidermonkey_detach_form_state(fs) ((fs)->ecmascript_obj = NULL)
#define spidermonkey_moved_form_state(fs) ((void) (fs))

View File

@ -347,6 +347,18 @@ done_form_state(struct form_state *fs)
mem_free_if(fs->value);
}
/** Free @a fv and any data owned by it. This does not call
* del_from_list(fv), so the caller must usually do that first.
* @relates form_view */
void
done_form_view(struct form_view *fv)
{
#ifdef CONFIG_ECMASCRIPT
ecmascript_detach_form_view(fv);
#endif
mem_free(fv);
}
int
get_current_state(struct session *ses)
{

View File

@ -114,6 +114,7 @@ struct form_view *find_form_view(struct document_view *doc_view, struct form *fo
struct form *find_form_by_form_view(struct document *document, struct form_view *fv);
void done_form_state(struct form_state *);
void done_form_view(struct form_view *);
enum frame_event_status field_op(struct session *ses, struct document_view *doc_view, struct link *link, struct term_event *ev);

View File

@ -45,14 +45,20 @@ init_vs(struct view_state *vs, struct uri *uri, int plain)
void
destroy_vs(struct view_state *vs, int blast_ecmascript)
{
struct form_view *fv, *next;
/* form_state contains a pointer to form_view, so it's safest
* to delete the form_state first. */
for (; vs->form_info_len > 0; vs->form_info_len--)
done_form_state(&vs->form_info[vs->form_info_len - 1]);
mem_free_set(&vs->form_info, NULL);
foreachsafe (fv, next, vs->forms) {
del_from_list(fv);
done_form_view(fv);
}
if (vs->uri) done_uri(vs->uri);
free_list(vs->forms);
#ifdef CONFIG_ECMASCRIPT
if (blast_ecmascript && vs->ecmascript)
ecmascript_put_interpreter(vs->ecmascript);