From bac4df147de363a0774548acd63d367a09ab50d3 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 20 Sep 2012 22:40:55 +0200 Subject: some memleak fixes (Bug #1043571) (bzr r11686) --- src/extension/dbus/document-interface.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/extension/dbus/document-interface.cpp') diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 66d1c5dfa..56d1dfdbd 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -223,11 +223,12 @@ dbus_create_node (SPDesktop *desk, const gchar *type) */ gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inkscape::XML::Node *newNode, gchar *desc) { - SPCSSAttr *style = sp_desktop_get_style(object->desk, TRUE); if (style) { - newNode->setAttribute("style", sp_repr_css_write_string(style), TRUE); + Glib::ustring str; + sp_repr_css_write_string(style, str); + newNode->setAttribute("style", str.c_str(), TRUE); } else { newNode->setAttribute("style", "fill:#0000ff;fill-opacity:1;stroke:#c900b9;stroke-width:0;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none", TRUE); @@ -530,7 +531,7 @@ gchar *document_interface_node(DocumentInterface *object, gchar *type, GError ** } /**************************************************************************** - ENVIORNMENT FUNCTIONS + ENVIRONMENT FUNCTIONS ****************************************************************************/ gdouble document_interface_document_get_width (DocumentInterface *object) @@ -547,7 +548,9 @@ document_interface_document_get_height (DocumentInterface *object) gchar *document_interface_document_get_css(DocumentInterface *object, GError ** /*error*/) { SPCSSAttr *current = (object->desk)->current; - return sp_repr_css_write_string(current); + Glib::ustring str; + sp_repr_css_write_string(current, str); + return (str.empty() ? NULL : g_strdup (str.c_str())); } gboolean document_interface_document_merge_css(DocumentInterface *object, @@ -768,7 +771,9 @@ document_interface_modify_css (DocumentInterface *object, gchar *shape, SPCSSAttr * oldstyle = sp_repr_css_attr (node, style); sp_repr_css_set_property(oldstyle, cssattrb, newval); - node->setAttribute (style, sp_repr_css_write_string (oldstyle), TRUE); + Glib::ustring str; + sp_repr_css_write_string (oldstyle, str); + node->setAttribute (style, str.c_str(), TRUE); return TRUE; } @@ -791,7 +796,10 @@ document_interface_merge_css (DocumentInterface *object, gchar *shape, SPCSSAttr * oldstyle = sp_repr_css_attr (node, style); sp_repr_css_merge(oldstyle, newstyle); - node->setAttribute (style, sp_repr_css_write_string (oldstyle), TRUE); + Glib::ustring str; + sp_repr_css_write_string (oldstyle, str); + node->setAttribute (style, str.c_str(), TRUE); + return TRUE; } -- cgit v1.2.3