diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2018-12-13 20:43:49 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2018-12-13 20:43:49 +0000 |
| commit | d4312f7cac4f6947719cda047645024a34c8795e (patch) | |
| tree | 180cea4ed59fbca47eb3740f8b8a940e18a97e25 /src/object | |
| parent | remove most of Inkscape::URI::Impl (diff) | |
| download | inkscape-d4312f7cac4f6947719cda047645024a34c8795e.tar.gz inkscape-d4312f7cac4f6947719cda047645024a34c8795e.zip | |
extract_uri: fix, test, document
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/sp-item.cpp | 14 | ||||
| -rw-r--r-- | src/object/uri-references.cpp | 7 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index d6d1bdf56..edf216481 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -441,15 +441,14 @@ void SPItem::set(SPAttributeEnum key, gchar const* value) { break; } case SP_PROP_CLIP_PATH: { - gchar *uri = extract_uri(value); - if (uri) { + auto uri = extract_uri(value); + if (!uri.empty()) { try { - item->clip_ref->attach(Inkscape::URI(uri)); + item->clip_ref->attach(Inkscape::URI(uri.c_str())); } catch (Inkscape::BadURIException &e) { g_warning("%s", e.what()); item->clip_ref->detach(); } - g_free(uri); } else { item->clip_ref->detach(); } @@ -457,15 +456,14 @@ void SPItem::set(SPAttributeEnum key, gchar const* value) { break; } case SP_PROP_MASK: { - gchar *uri = extract_uri(value); - if (uri) { + auto uri = extract_uri(value); + if (!uri.empty()) { try { - item->mask_ref->attach(Inkscape::URI(uri)); + item->mask_ref->attach(Inkscape::URI(uri.c_str())); } catch (Inkscape::BadURIException &e) { g_warning("%s", e.what()); item->mask_ref->detach(); } - g_free(uri); } else { item->mask_ref->detach(); } diff --git a/src/object/uri-references.cpp b/src/object/uri-references.cpp index 3e11cd26c..69ed140e0 100644 --- a/src/object/uri-references.cpp +++ b/src/object/uri-references.cpp @@ -243,10 +243,9 @@ SPObject *sp_css_uri_reference_resolve(SPDocument *document, const gchar *uri) SPObject *ref = nullptr; if (document && uri && (strncmp(uri, "url(", 4) == 0)) { - gchar *trimmed = extract_uri(uri); - if (trimmed) { - ref = sp_uri_reference_resolve(document, trimmed); - g_free(trimmed); + auto trimmed = extract_uri(uri); + if (!trimmed.empty()) { + ref = sp_uri_reference_resolve(document, trimmed.c_str()); } } |
