[librsvg] defs: Do the right thing for duplicate ids
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] defs: Do the right thing for duplicate ids
- Date: Thu, 22 Oct 2015 11:15:16 +0000 (UTC)
commit 775178c2d7480895ce1b2bb86477a45e48bd22e4
Author: Benjamin Otte <otte redhat com>
Date: Tue Oct 20 18:11:46 2015 +0200
defs: Do the right thing for duplicate ids
When an id (illegally) exists twice in an SVG file, all renderers keep
the definition that appears first.
Do the same in rsvg.
rsvg-defs.c | 3 +++
tests/fixtures/reftests/duplicate-id-ref.png | Bin 0 -> 155 bytes
tests/fixtures/reftests/duplicate-id.svg | 7 +++++++
3 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/rsvg-defs.c b/rsvg-defs.c
index 280f87f..d2c6a06 100644
--- a/rsvg-defs.c
+++ b/rsvg-defs.c
@@ -135,6 +135,9 @@ rsvg_defs_set (RsvgDefs * defs, const char *name, RsvgNode * val)
void
rsvg_defs_register_name (RsvgDefs * defs, const char *name, RsvgNode * val)
{
+ if (g_hash_table_lookup (defs->hash, name))
+ return;
+
g_hash_table_insert (defs->hash, g_strdup (name), val);
}
diff --git a/tests/fixtures/reftests/duplicate-id-ref.png b/tests/fixtures/reftests/duplicate-id-ref.png
new file mode 100644
index 0000000..162a658
Binary files /dev/null and b/tests/fixtures/reftests/duplicate-id-ref.png differ
diff --git a/tests/fixtures/reftests/duplicate-id.svg b/tests/fixtures/reftests/duplicate-id.svg
new file mode 100644
index 0000000..c05f341
--- /dev/null
+++ b/tests/fixtures/reftests/duplicate-id.svg
@@ -0,0 +1,7 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10" height="10">
+ <defs>
+ <rect fill="chartreuse" id="a" width="10" height="10" />
+ <rect fill="tomato" id="a" width="10" height="10" />
+ </defs>
+ <use xlink:href="#a"/>
+</svg>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]