[librsvg] Check that RsvgHandle is not yet started loading for some API entry points
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Check that RsvgHandle is not yet started loading for some API entry points
- Date: Tue, 11 Dec 2018 17:03:34 +0000 (UTC)
commit a851150bc535a5a226f08cbb99b0bc1151317d71
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Dec 11 10:56:51 2018 -0600
Check that RsvgHandle is not yet started loading for some API entry points
librsvg/rsvg-handle.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index a5367959..2071dc48 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -899,6 +899,17 @@ get_base_uri_from_filename (const gchar * filename)
return base_uri;
}
+static gboolean
+is_at_start_for_setting_base_file (RsvgHandle *handle)
+{
+ if (handle->priv->hstate == RSVG_HANDLE_STATE_START) {
+ return TRUE;
+ } else {
+ g_warning ("Please set the base file or URI before loading any data into RsvgHandle");
+ return FALSE;
+ }
+}
+
/**
* rsvg_handle_set_base_uri:
* @handle: A #RsvgHandle
@@ -917,8 +928,13 @@ rsvg_handle_set_base_uri (RsvgHandle * handle, const char *base_uri)
g_return_if_fail (RSVG_IS_HANDLE (handle));
- if (base_uri == NULL)
+ if (!is_at_start_for_setting_base_file (handle)) {
return;
+ }
+
+ if (base_uri == NULL) {
+ return;
+ }
if (path_is_uri (base_uri))
uri = g_strdup (base_uri);
@@ -953,6 +969,10 @@ rsvg_handle_set_base_gfile (RsvgHandle *handle,
g_return_if_fail (RSVG_IS_HANDLE (handle));
g_return_if_fail (G_IS_FILE (base_file));
+ if (!is_at_start_for_setting_base_file (handle)) {
+ return;
+ }
+
priv = handle->priv;
uri = g_file_get_uri (base_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]