diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2018-11-05 22:37:54 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2018-11-05 22:37:54 +0000 |
| commit | 8fe8df064850bdaf5cd0c6015430c4b12132c8ab (patch) | |
| tree | 2ef547a667ff1f1a3ba8fc66dc8350b5ae3c4089 /src | |
| parent | Replacement for xmlBuildRelativeURI (diff) | |
| download | inkscape-8fe8df064850bdaf5cd0c6015430c4b12132c8ab.tar.gz inkscape-8fe8df064850bdaf5cd0c6015430c4b12132c8ab.zip | |
remove Inkscape::URI::toString
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop-style.cpp | 8 | ||||
| -rw-r--r-- | src/extension/internal/javafx-out.cpp | 4 | ||||
| -rw-r--r-- | src/object/box3d.cpp | 5 | ||||
| -rw-r--r-- | src/object/sp-conn-end-pair.cpp | 5 | ||||
| -rw-r--r-- | src/object/sp-filter.cpp | 5 | ||||
| -rw-r--r-- | src/object/sp-gradient.cpp | 5 | ||||
| -rw-r--r-- | src/object/sp-item.cpp | 14 | ||||
| -rw-r--r-- | src/object/sp-tag-use.cpp | 5 | ||||
| -rw-r--r-- | src/object/sp-tref.cpp | 4 | ||||
| -rw-r--r-- | src/object/sp-use.cpp | 5 | ||||
| -rw-r--r-- | src/object/uri-references.cpp | 4 | ||||
| -rw-r--r-- | src/object/uri.h | 11 | ||||
| -rw-r--r-- | src/style.cpp | 5 | ||||
| -rw-r--r-- | src/style.h | 8 |
14 files changed, 28 insertions, 60 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index ae1863723..ae2afe141 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -627,15 +627,11 @@ objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_re paint_res->colorSet = paint->colorSet; paint_res->paintOrigin = paint->paintOrigin; if (paint_res->set && paint_effectively_set && paint->isPaintserver()) { // copy the server - gchar const *string = nullptr; // memory leak results if style->get* called inside sp_style_set_to_uri_string. if (isfill) { - string = style->getFillURI(); - sp_style_set_to_uri_string (style_res, true, string); + sp_style_set_to_uri(style_res, true, style->getFillURI()); } else { - string = style->getStrokeURI(); - sp_style_set_to_uri_string (style_res, false, string); + sp_style_set_to_uri(style_res, false, style->getStrokeURI()); } - if(string)g_free((void *) string); } paint_res->set = paint_effectively_set; style_res->fill_rule.computed = style->fill_rule.computed; // no averaging on this, just use the last one diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 6c6ebaa84..cc5fc12bb 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -391,14 +391,12 @@ bool JavaFXOutput::doStyle(SPStyle *style) } else if (fill.isPaintserver()){ if (fill.value.href && fill.value.href->getURI() ){ - gchar *str = fill.value.href->getURI()->toString(); - String uri = (str ? str : ""); + String uri = fill.value.href->getURI()->str(); /* trim the anchor '#' from the front */ if (uri.size() > 0 && uri[0]=='#') { uri = uri.substr(1); } out(" fill: %s()\n", sanatize(uri).c_str()); - g_free(str); } } diff --git a/src/object/box3d.cpp b/src/object/box3d.cpp index 98dfddbb4..94920e419 100644 --- a/src/object/box3d.cpp +++ b/src/object/box3d.cpp @@ -217,9 +217,8 @@ Inkscape::XML::Node* SPBox3D::write(Inkscape::XML::Document *xml_doc, Inkscape:: /* box is not yet linked to a perspective; use the document's current perspective */ SPDocument *doc = object->document; if (box->persp_ref->getURI()) { - gchar *uri_string = box->persp_ref->getURI()->toString(); - repr->setAttribute("inkscape:perspectiveID", uri_string); - g_free(uri_string); + auto uri_string = box->persp_ref->getURI()->str(); + repr->setAttribute("inkscape:perspectiveID", uri_string.c_str()); } else { Glib::ustring href = "#"; href += doc->getCurrentPersp3D()->getId(); diff --git a/src/object/sp-conn-end-pair.cpp b/src/object/sp-conn-end-pair.cpp index f05b211da..160d48aca 100644 --- a/src/object/sp-conn-end-pair.cpp +++ b/src/object/sp-conn-end-pair.cpp @@ -143,9 +143,8 @@ void SPConnEndPair::writeRepr(Inkscape::XML::Node *const repr) const for (unsigned handle_ix = 0; handle_ix < 2; ++handle_ix) { const Inkscape::URI* U = this->_connEnd[handle_ix]->ref.getURI(); if (U) { - gchar *str = U->toString(); - repr->setAttribute(attr_strs[handle_ix], str); - g_free(str); + auto str = U->str(); + repr->setAttribute(attr_strs[handle_ix], str.c_str()); } } repr->setAttribute("inkscape:connector-curvature", Glib::Ascii::dtostr(_connCurvature).c_str()); diff --git a/src/object/sp-filter.cpp b/src/object/sp-filter.cpp index ef61e4fdb..4c012fbdf 100644 --- a/src/object/sp-filter.cpp +++ b/src/object/sp-filter.cpp @@ -316,9 +316,8 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML } if (this->href->getURI()) { - gchar *uri_string = this->href->getURI()->toString(); - repr->setAttribute("xlink:href", uri_string); - g_free(uri_string); + auto uri_string = this->href->getURI()->str(); + repr->setAttribute("xlink:href", uri_string.c_str()); } SPObject::write(doc, repr, flags); diff --git a/src/object/sp-gradient.cpp b/src/object/sp-gradient.cpp index c8e7f92b0..9aee288be 100644 --- a/src/object/sp-gradient.cpp +++ b/src/object/sp-gradient.cpp @@ -629,9 +629,8 @@ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscap } if (this->ref->getURI()) { - gchar *uri_string = this->ref->getURI()->toString(); - repr->setAttribute("xlink:href", uri_string); - g_free(uri_string); + auto uri_string = this->ref->getURI()->str(); + repr->setAttribute("xlink:href", uri_string.c_str()); } if ((flags & SP_OBJECT_WRITE_ALL) || this->units_set) { diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index 3a641eca2..bc5922b3f 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -749,20 +749,14 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X if (item->clip_ref){ if (item->clip_ref->getObject()) { - gchar *uri = item->clip_ref->getURI()->toString(); - const gchar *value = g_strdup_printf ("url(%s)", uri); - repr->setAttribute ("clip-path", value); - g_free ((void *) value); - g_free ((void *) uri); + auto value = item->clip_ref->getURI()->cssStr(); + repr->setAttribute("clip-path", value.c_str()); } } if (item->mask_ref){ if (item->mask_ref->getObject()) { - gchar *uri = item->mask_ref->getURI()->toString(); - const gchar *value = g_strdup_printf ("url(%s)", uri); - repr->setAttribute ("mask", value); - g_free ((void *) value); - g_free ((void *) uri); + auto value = item->clip_ref->getURI()->cssStr(); + repr->setAttribute("mask", value.c_str()); } } if (item->_highlightColor){ diff --git a/src/object/sp-tag-use.cpp b/src/object/sp-tag-use.cpp index e1dae8167..c9180c693 100644 --- a/src/object/sp-tag-use.cpp +++ b/src/object/sp-tag-use.cpp @@ -128,9 +128,8 @@ SPTagUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, gui SPObject::write(xml_doc, repr, flags); if (ref->getURI()) { - gchar *uri_string = ref->getURI()->toString(); - repr->setAttribute("xlink:href", uri_string); - g_free(uri_string); + auto uri_string = ref->getURI()->str(); + repr->setAttribute("xlink:href", uri_string.c_str()); } return repr; diff --git a/src/object/sp-tref.cpp b/src/object/sp-tref.cpp index c3db8780f..ef5b6c106 100644 --- a/src/object/sp-tref.cpp +++ b/src/object/sp-tref.cpp @@ -173,10 +173,10 @@ Inkscape::XML::Node* SPTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::X this->attributes.writeTo(repr); if (this->uriOriginalRef->getURI()) { - gchar *uri_string = this->uriOriginalRef->getURI()->toString(); + auto uri = this->uriOriginalRef->getURI()->str(); + auto uri_string = uri.c_str(); debug("uri_string=%s", uri_string); repr->setAttribute("xlink:href", uri_string); - g_free(uri_string); } SPItem::write(xml_doc, repr, flags); diff --git a/src/object/sp-use.cpp b/src/object/sp-use.cpp index 876c822e6..941bb6274 100644 --- a/src/object/sp-use.cpp +++ b/src/object/sp-use.cpp @@ -172,9 +172,8 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM repr->setAttribute("height", sp_svg_length_write_with_units(this->height).c_str()); if (this->ref->getURI()) { - gchar *uri_string = this->ref->getURI()->toString(); - repr->setAttribute("xlink:href", uri_string); - g_free(uri_string); + auto uri_string = this->ref->getURI()->str(); + repr->setAttribute("xlink:href", uri_string.c_str()); } SPShape *shape = dynamic_cast<SPShape *>(child); diff --git a/src/object/uri-references.cpp b/src/object/uri-references.cpp index b4af31278..24bef48aa 100644 --- a/src/object/uri-references.cpp +++ b/src/object/uri-references.cpp @@ -120,7 +120,7 @@ void URIReference::attach(const URI &uri) // createChildDoc() assumes that the referenced file is an SVG. // PNG and JPG files are allowed (in the case of feImage). - gchar *filename = uri.toString(); + gchar const *filename = uri.getPath() ? uri.getPath() : ""; bool skip = false; if (g_str_has_suffix(filename, ".jpg") || g_str_has_suffix(filename, ".JPG") || g_str_has_suffix(filename, ".png") || g_str_has_suffix(filename, ".PNG")) { @@ -139,10 +139,8 @@ void URIReference::attach(const URI &uri) } if (!document) { g_warning("Can't get document for referenced URI: %s", filename); - g_free(filename); return; } - g_free(filename); gchar const *fragment = uri.getFragment(); if (!uri.isRelative() || uri.getQuery() || !fragment) { diff --git a/src/object/uri.h b/src/object/uri.h index 8cfccfed0..9944d2219 100644 --- a/src/object/uri.h +++ b/src/object/uri.h @@ -137,17 +137,6 @@ public: std::string toNativeFilename() const; /** - * Returns a glib string version of this URI. - * - * The returned string must be freed with \c g_free(). - * - * @return a glib string version of this URI. - * - * @todo remove this method and use str() instead - */ - char *toString() const { return _impl->toString(); } - - /** * Return the string representation of this URI * * @param baseuri Return a relative path if this URI shares protocol and host with @a baseuri diff --git a/src/style.cpp b/src/style.cpp index 802cfb22d..6c7e849dc 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -1221,10 +1221,9 @@ sp_style_set_ipaint_to_uri_string (SPStyle *style, SPIPaint *paint, const gchar } // Called in: desktop-style.cpp -void -sp_style_set_to_uri_string (SPStyle *style, bool isfill, const gchar *uri) +void sp_style_set_to_uri(SPStyle *style, bool isfill, Inkscape::URI const *uri) { - sp_style_set_ipaint_to_uri_string (style, isfill? &style->fill : &style->stroke, uri); + sp_style_set_ipaint_to_uri(style, isfill ? &style->fill : &style->stroke, uri, style->document); } // Called in: widgets/font-selector.cpp, widgets/text-toolbar.cpp, ui/dialog/text-edit.cpp diff --git a/src/style.h b/src/style.h index 6e82b78d0..303e8dcbb 100644 --- a/src/style.h +++ b/src/style.h @@ -312,15 +312,15 @@ public: SPObject *getFilter() { return (filter.href) ? filter.href->getObject() : nullptr; } SPObject const *getFilter() const { return (filter.href) ? filter.href->getObject() : nullptr; } - char const *getFilterURI() const { return (filter.href) ? filter.href->getURI()->toString() : nullptr; } + Inkscape::URI const *getFilterURI() const { return (filter.href) ? filter.href->getURI() : nullptr; } SPPaintServer *getFillPaintServer() { return (fill.value.href) ? fill.value.href->getObject() : nullptr; } SPPaintServer const *getFillPaintServer() const { return (fill.value.href) ? fill.value.href->getObject() : nullptr; } - char const *getFillURI() const { return (fill.value.href) ? fill.value.href->getURI()->toString() : nullptr; } + Inkscape::URI const *getFillURI() const { return (fill.value.href) ? fill.value.href->getURI() : nullptr; } SPPaintServer *getStrokePaintServer() { return (stroke.value.href) ? stroke.value.href->getObject() : nullptr; } SPPaintServer const *getStrokePaintServer() const { return (stroke.value.href) ? stroke.value.href->getObject() : nullptr; } - char const *getStrokeURI() const { return (stroke.value.href) ? stroke.value.href->getURI()->toString() : nullptr; } + Inkscape::URI const *getStrokeURI() const { return (stroke.value.href) ? stroke.value.href->getURI() : nullptr; } /** * Return a font feature string useful for Pango. @@ -333,7 +333,7 @@ SPStyle *sp_style_ref(SPStyle *style); // SPStyle::ref(); SPStyle *sp_style_unref(SPStyle *style); // SPStyle::unref(); -void sp_style_set_to_uri_string (SPStyle *style, bool isfill, const char *uri); // ? +void sp_style_set_to_uri(SPStyle *style, bool isfill, Inkscape::URI const *uri); // ? char const *sp_style_get_css_unit_string(int unit); // No change? |
