[librsvg/librsvg-2.44] 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/librsvg-2.44] Check that RsvgHandle is not yet started loading for some API entry points
- Date: Tue, 11 Dec 2018 17:32:47 +0000 (UTC)
commit 4ff0cb87a8e7af7dcd0306a1d6b74fcbe1607f7b
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 | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index c1511bf0..af66b5e8 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -876,6 +876,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
@@ -892,10 +903,15 @@ rsvg_handle_set_base_uri (RsvgHandle * handle, const char *base_uri)
gchar *uri;
GFile *file;
- g_return_if_fail (handle != NULL);
+ g_return_if_fail (RSVG_IS_HANDLE (handle));
+
+ if (!is_at_start_for_setting_base_file (handle)) {
+ return;
+ }
- if (base_uri == NULL)
+ if (base_uri == NULL) {
return;
+ }
if (path_is_uri (base_uri))
uri = g_strdup (base_uri);
@@ -928,6 +944,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;
g_object_ref (base_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]