Commit a905f74e authored by Dom Lachowicz's avatar Dom Lachowicz

rsvg_handle_set_base_uri() in rsvg_handle_new_from_file() is too late

* rsvg-base-file-util.c: rsvg_handle_set_base_uri() in rsvg_handle_new_from_file()
	  is too late (#335450)
parent e3e53077
2006-03-22 Dom Lachowicz <cinamod@hotmail.com>
* rsvg-base-file-util.c: rsvg_handle_set_base_uri() in rsvg_handle_new_from_file()
is too late (#335450)
2006-03-19 Dom Lachowicz <cinamod@hotmail.com>
* rsvg-base.c: Fix a crash exposed by bug 335107
......
......@@ -27,6 +27,23 @@
#include "rsvg.h"
#include "rsvg-private.h"
static gboolean
rsvg_handle_fill_with_data (RsvgHandle * handle,
const guint8 *data,
gsize data_len,
GError **error)
{
g_return_val_if_fail(data != NULL, FALSE);
g_return_val_if_fail(data_len != 0, FALSE);
if(!rsvg_handle_write (handle, data, data_len, error))
return FALSE;
if(!rsvg_handle_close(handle, error))
return FALSE;
return TRUE;
}
/**
* rsvg_handle_new_from_data:
* @data: The SVG data
......@@ -44,20 +61,12 @@ RsvgHandle * rsvg_handle_new_from_data (const guint8 *data,
{
RsvgHandle * handle;
g_return_val_if_fail(data != NULL, NULL);
g_return_val_if_fail(data_len != 0, NULL);
handle = rsvg_handle_new ();
if(handle) {
if(!rsvg_handle_write (handle, data, data_len, error)) {
if (!rsvg_handle_fill_with_data (handle, data, data_len, error)) {
g_object_unref(G_OBJECT(handle));
handle = NULL;
} else {
if(!rsvg_handle_close(handle, error)) {
g_object_unref (G_OBJECT(handle));
handle = NULL;
}
}
}
......@@ -88,9 +97,14 @@ RsvgHandle * rsvg_handle_new_from_file (const gchar *file_name,
if (f)
{
handle = rsvg_handle_new_from_data (f->data, f->len, error);
if (handle)
handle = rsvg_handle_new ();
if (handle) {
rsvg_handle_set_base_uri (handle, base_uri);
if(!rsvg_handle_fill_with_data (handle, f->data, f->len, error)) {
g_object_unref (G_OBJECT (handle));
handle = NULL;
}
}
g_byte_array_free (f, TRUE);
}
......
......@@ -726,9 +726,10 @@ rsvg_get_base_uri_from_filename(const gchar * file_name)
* @handle: A #RsvgHandle
* @base_uri: The base uri
*
* Set the base URI for this SVG
* Set the base URI for this SVG. This can only be called before rsvg_handle_write()
* has been called.
*
* Since: 2.9 (really present in 2.8 as well)
* Since: 2.9
*/
void rsvg_handle_set_base_uri (RsvgHandle *handle,
const char *base_uri)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment