diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index b3946cfee9bf90d3b640db5db4d71e3ca6a73f60..6ad5ff6385798398609a62eb89c2c6b993c5ba15 100644 (file)
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <cstring>
+#include <string>
#include "svg/svg.h"
#include "display/nr-arena-group.h"
@@ -353,9 +358,9 @@ sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML:
(* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref);
SPObject *co = object->document->getObjectByRepr(child);
- g_assert(co != NULL);
+ g_assert (co != NULL || !strcmp("comment", child->name())); // comment repr node has no object
- if (SP_IS_DEFS(co)) {
+ if (co && SP_IS_DEFS(co)) {
SPObject *c;
/* We search for first <defs> node - it is not beautiful, but works */
for (c = sp_object_first_child(SP_OBJECT(group)) ; c != NULL; c = SP_OBJECT_NEXT(c) ) {
SPRoot *root = SP_ROOT(object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
- repr = sp_repr_new("svg:svg");
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
+ repr = xml_doc->createElement("svg:svg");
}
if (flags & SP_OBJECT_WRITE_EXT) {