RSVG content handler: Convert to using content_broadcast_errorcode().

This commit is contained in:
Michael Drake 2017-08-28 10:21:11 +01:00
parent cae1c44f8f
commit 9e64f37846
2 changed files with 8 additions and 15 deletions

View File

@ -62,8 +62,6 @@ typedef struct rsvg_content {
static nserror rsvg_create_svg_data(rsvg_content *c)
{
union content_msg_data msg_data;
c->rsvgh = NULL;
c->cs = NULL;
c->ct = NULL;
@ -71,8 +69,7 @@ static nserror rsvg_create_svg_data(rsvg_content *c)
if ((c->rsvgh = rsvg_handle_new()) == NULL) {
LOG("rsvg_handle_new() returned NULL.");
msg_data.error = messages_get("NoMemory");
content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data);
content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
return NSERROR_NOMEM;
}
@ -115,14 +112,12 @@ static bool rsvg_process_data(struct content *c, const char *data,
unsigned int size)
{
rsvg_content *d = (rsvg_content *) c;
union content_msg_data msg_data;
GError *err = NULL;
if (rsvg_handle_write(d->rsvgh, (const guchar *)data, (gsize)size,
&err) == FALSE) {
LOG("rsvg_handle_write returned an error: %s", err->message);
msg_data.error = err->message;
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
content_broadcast_errorcode(c, NSERROR_SVG_ERROR);
return false;
}
@ -161,14 +156,12 @@ static inline void rsvg_argb_to_abgr(uint8_t *pixels,
static bool rsvg_convert(struct content *c)
{
rsvg_content *d = (rsvg_content *) c;
union content_msg_data msg_data;
RsvgDimensionData rsvgsize;
GError *err = NULL;
if (rsvg_handle_close(d->rsvgh, &err) == FALSE) {
LOG("rsvg_handle_close returned an error: %s", err->message);
msg_data.error = err->message;
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
content_broadcast_errorcode(c, NSERROR_SVG_ERROR);
return false;
}
@ -186,7 +179,7 @@ static bool rsvg_convert(struct content *c)
BITMAP_NEW)) == NULL) {
LOG("Failed to create bitmap for rsvg render.");
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
content_broadcast_errorcode(c, NSERROR_NOMEM);
return false;
}
@ -196,15 +189,13 @@ static bool rsvg_convert(struct content *c)
c->width, c->height,
guit->bitmap->get_rowstride(d->bitmap))) == NULL) {
LOG("Failed to create Cairo image surface for rsvg render.");
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
content_broadcast_errorcode(c, NSERROR_NOMEM);
return false;
}
if ((d->ct = cairo_create(d->cs)) == NULL) {
LOG("Failed to create Cairo drawing context for rsvg render.");
msg_data.error = messages_get("NoMemory");
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
content_broadcast_errorcode(c, NSERROR_NOMEM);
return false;
}

View File

@ -55,6 +55,8 @@ typedef enum {
NSERROR_PNG_ERROR, /**< A PNG error occurred */
NSERROR_SVG_ERROR, /**< A SVG error occurred */
NSERROR_BAD_ENCODING, /**< The character set is unknown */
NSERROR_NEED_DATA, /**< More data needed */