diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-03 00:10:02 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-03 00:10:02 +0000 |
| commit | d2df0412f728dd5bb54537dfdfe7c35b34d40e0e (patch) | |
| tree | e2703384779e83312c456399999997fcc289c5cf /src/sp-object.cpp | |
| parent | Merge branch 'master' into powerpencil (diff) | |
| parent | change assignment to equality (diff) | |
| download | inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.tar.gz inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.zip | |
Merge branch 'master' into powerpencil
Diffstat (limited to 'src/sp-object.cpp')
| -rw-r--r-- | src/sp-object.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 9f15935ac..bc930a430 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -199,7 +199,7 @@ typedef Debug::SimpleEvent<Debug::Event::REFCOUNT> BaseRefCountEvent; class RefCountEvent : public BaseRefCountEvent { public: - RefCountEvent(SPObject *object, int bias, Util::ptr_shared<char> name) + RefCountEvent(SPObject *object, int bias, Util::ptr_shared name) : BaseRefCountEvent(name) { _addProperty("object", Util::format("%p", object)); @@ -1540,7 +1540,10 @@ char * SPObject::getTitleOrDesc(gchar const *svg_tagname) const char *result = NULL; SPObject *elem = findFirstChild(svg_tagname); if ( elem ) { - result = elem->textualContent(); + //This string copy could be avoided by changing + //the return type of SPObject::getTitleOrDesc + //to std::unique_ptr<Glib::ustring> + result = g_strdup(elem->textualContent().c_str()); } return result; } @@ -1625,24 +1628,22 @@ SPObject* SPObject::findFirstChild(gchar const *tagname) const return nullptr; } -char* SPObject::textualContent() const +Glib::ustring SPObject::textualContent() const { - GString* text = g_string_new(""); + Glib::ustring text; for (auto& child: children) { Inkscape::XML::NodeType child_type = child.repr->type(); if (child_type == Inkscape::XML::ELEMENT_NODE) { - char* new_string = child.textualContent(); - g_string_append(text, new_string); - g_free(new_string); + text += child.textualContent(); } else if (child_type == Inkscape::XML::TEXT_NODE) { - g_string_append(text, child.repr->content()); + text += child.repr->content(); } } - return g_string_free(text, FALSE); + return text; } // For debugging: Print SP tree structure. |
