summaryrefslogtreecommitdiffstats
path: root/src/sp-object.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2017-09-27 08:15:49 +0000
committerTavmjong Bah <tavmjong@free.fr>2017-09-27 08:15:49 +0000
commit40d24d185b7e050deac650960464630f9af4b073 (patch)
treeec019942c30f0ae0ee010a86c2fdc6f04af713c2 /src/sp-object.cpp
parentFix error when vertical text has 'text-orientation' value 'sideways'. (diff)
parentRemove usage of GString in sp-object.cpp (diff)
downloadinkscape-40d24d185b7e050deac650960464630f9af4b073.tar.gz
inkscape-40d24d185b7e050deac650960464630f9af4b073.zip
Merge branch 'jali/inkscape-ustring_refactor'
Removes usage of GString.
Diffstat (limited to 'src/sp-object.cpp')
-rw-r--r--src/sp-object.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 9f15935ac..fc222f701 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -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.