From dc6c58ec4150d933bf7054d55c1d5922ba513228 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 20 Jul 2011 21:39:51 +0000 Subject: Fix transition from LOADING to ERROR state after content has been locked for conversion svn path=/trunk/netsurf/; revision=12614 --- content/content.c | 14 ++++++++++++-- content/content_protected.h | 2 ++ css/css.c | 3 +-- image/png.c | 1 - render/html.c | 14 +++++++------- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/content/content.c b/content/content.c index ed5202009..f792e794a 100644 --- a/content/content.c +++ b/content/content.c @@ -280,8 +280,7 @@ void content_convert(struct content *c) if (c->handler->data_complete != NULL) { c->locked = true; if (c->handler->data_complete(c) == false) { - c->locked = false; - c->status = CONTENT_STATUS_ERROR; + content_set_error(c); } /* Conversion to the READY state will unlock the content */ } else { @@ -322,6 +321,17 @@ void content_set_done(struct content *c) content_broadcast(c, CONTENT_MSG_DONE, msg_data); } +/** + * Put a content in status CONTENT_STATUS_ERROR and unlock the content. + * + * \note We expect the caller to broadcast an error report if needed. + */ + +void content_set_error(struct content *c) +{ + c->locked = false; + c->status = CONTENT_STATUS_ERROR; +} /** * Reformat to new size. diff --git a/content/content_protected.h b/content/content_protected.h index 4fe9b942a..d113508e4 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -148,6 +148,8 @@ nserror content__clone(const struct content *c, struct content *nc); void content_set_ready(struct content *c); void content_set_done(struct content *c); +void content_set_error(struct content *c); + void content_set_status(struct content *c, const char *status_message, ...); void content_broadcast(struct content *c, content_msg msg, union content_msg_data data); diff --git a/css/css.c b/css/css.c index 9fc656848..79eda90b8 100644 --- a/css/css.c +++ b/css/css.c @@ -302,7 +302,6 @@ bool nscss_convert(struct content *c) if (error != CSS_OK) { msg_data.error = "?"; content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - c->status = CONTENT_STATUS_ERROR; return false; } @@ -508,7 +507,7 @@ void nscss_content_done(struct content_css_data *css, void *pw) if (error != CSS_OK) { msg_data.error = "?"; content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - c->status = CONTENT_STATUS_ERROR; + content_set_error(c); return; } c->size += size; diff --git a/image/png.c b/image/png.c index 79ab248dc..15c6e07aa 100644 --- a/image/png.c +++ b/image/png.c @@ -325,7 +325,6 @@ static bool nspng_convert(struct content *c) msg_data.error = messages_get("PNGError"); content_broadcast(c, CONTENT_MSG_ERROR, msg_data); - c->status = CONTENT_STATUS_ERROR; return false; } diff --git a/render/html.c b/render/html.c index 2c9743d04..5284f53c2 100644 --- a/render/html.c +++ b/render/html.c @@ -602,7 +602,7 @@ void html_finish_conversion(html_content *c) if (c->aborted) { msg_data.error = messages_get("Stopped"); content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); - c->base.status = CONTENT_STATUS_ERROR; + content_set_error(&c->base); return; } @@ -613,7 +613,7 @@ void html_finish_conversion(html_content *c) if (c->stylesheets[STYLESHEET_BASE].data.external == NULL) { msg_data.error = "Base stylesheet failed to load"; content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); - c->base.status = CONTENT_STATUS_ERROR; + content_set_error(&c->base); return; } @@ -622,7 +622,7 @@ void html_finish_conversion(html_content *c) if (error != CSS_OK) { msg_data.error = messages_get("NoMemory"); content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); - c->base.status = CONTENT_STATUS_ERROR; + content_set_error(&c->base); return; } @@ -652,7 +652,7 @@ void html_finish_conversion(html_content *c) msg_data.error = messages_get("NoMemory"); content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); - c->base.status = CONTENT_STATUS_ERROR; + content_set_error(&c->base); return; } } @@ -665,7 +665,7 @@ void html_finish_conversion(html_content *c) if (!xml_to_box(html, c)) { msg_data.error = messages_get("NoMemory"); content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); - c->base.status = CONTENT_STATUS_ERROR; + content_set_error(&c->base); return; } #if ALWAYS_DUMP_BOX @@ -681,7 +681,7 @@ void html_finish_conversion(html_content *c) LOG(("imagemap extraction failed")); msg_data.error = messages_get("NoMemory"); content_broadcast(&c->base, CONTENT_MSG_ERROR, msg_data); - c->base.status = CONTENT_STATUS_ERROR; + content_set_error(&c->base); return; } /*imagemap_dump(c);*/ @@ -1733,7 +1733,7 @@ void html_stop(struct content *c) switch (c->status) { case CONTENT_STATUS_LOADING: - /* Clear up objects if we were stopped after queuing up some + /* Clean up objects if we were stopped after queuing up some * fetches within xml_to_box (i.e. gui_multitask is somewhere * in our call stack) */ for (object = htmlc->object_list; object != NULL; -- cgit v1.2.3