X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsp-root.cpp;h=c555c78a00bce3c97f12f468225fcad3730b8d93;hb=5e230ff5b88fa5522aeaf72d6222c38e4470557d;hp=1bb77ccc78f8615e31780947a66db35dad056396;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 1bb77ccc7..c555c78a0 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -353,9 +353,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 node - it is not beautiful, but works */ for (c = sp_object_first_child(SP_OBJECT(group)) ; c != NULL; c = SP_OBJECT_NEXT(c) ) { @@ -385,7 +385,6 @@ static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child) } if (!iter) { /* we should probably create a new here? */ - g_critical("Last removed"); root->defs = NULL; } } @@ -578,7 +577,8 @@ sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) 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) { @@ -603,7 +603,7 @@ sp_root_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) Inkscape::SVGOStringStream os; os << root->viewBox.x0 << " " << root->viewBox.y0 << " " << root->viewBox.x1 - root->viewBox.x0 << " " << root->viewBox.y1 - root->viewBox.y0; repr->setAttribute("viewBox", os.str().c_str()); - } + } if (((SPObjectClass *) (parent_class))->write) ((SPObjectClass *) (parent_class))->write(object, repr, flags);