From 524965b867e9aaef4ba75d6e077fdfd6c0b88401 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 23 Aug 2019 21:58:07 +0100 Subject: Box Conversion: Cancel conversion during html_destroy If dom_to_box is still in progress when we destroy an HTML content, we need to cancel the conversion otherwise we will end up with a scheduled callback into infinity. Signed-off-by: Daniel Silverstone --- content/handlers/html/box_construct.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'content/handlers/html/box_construct.c') diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c index 1f15d82b7..f0d68ac2e 100644 --- a/content/handlers/html/box_construct.c +++ b/content/handlers/html/box_construct.c @@ -163,10 +163,12 @@ static const struct element_entry element_table[] = { * \return netsurf error code indicating status of call */ -nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb) +nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb, void **box_conversion_context) { struct box_construct_ctx *ctx; + assert(box_conversion_context != NULL); + if (c->bctx == NULL) { /* create a context allocation for this box tree */ c->bctx = talloc_zero(0, int); @@ -186,9 +188,28 @@ nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb) ctx->cb = cb; ctx->bctx = c->bctx; + *box_conversion_context = ctx; + return guit->misc->schedule(0, (void *)convert_xml_to_box, ctx); } +nserror cancel_dom_to_box(void *box_conversion_context) +{ + struct box_construct_ctx *ctx = box_conversion_context; + nserror err; + + err = guit->misc->schedule(-1, (void *)convert_xml_to_box, ctx); + if (err != NSERROR_OK) { + return err; + } + + dom_node_unref(ctx->n); + free(ctx); + + return NSERROR_OK; +} + + /* mapping from CSS display to box type * this table must be in sync with libcss' css_display enum */ static const box_type box_map[] = { -- cgit v1.2.3